Skip to content

Commit fe9f764

Browse files
authored
feat: Update dependency management to uv (camel-ai#1745)
1 parent a3c9211 commit fe9f764

File tree

19 files changed

+7306
-10548
lines changed

19 files changed

+7306
-10548
lines changed

.container/Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
FROM python:3.10-bookworm
22

3-
# Install Poetry
4-
RUN curl -sSL https://install.python-poetry.org | python3 - && \
5-
ln -s /root/.local/bin/poetry /usr/local/bin/poetry
6-
7-
# Configurate Poetry
8-
RUN poetry config virtualenvs.create false
3+
# Install uv
4+
RUN pip install uv
95

106
COPY . /app/camel
117

128
WORKDIR /app/camel
139

14-
RUN poetry install --with dev,docs -E all
15-
16-
RUN pre-commit install
10+
# Setup virtual environment and install dependencies
11+
RUN uv venv .venv --python=3.10 && \
12+
. .venv/bin/activate && \
13+
uv pip install -e ".[all, dev]" && \
14+
pip install pre-commit mypy && \
15+
pre-commit install
1716

1817
CMD ["tail", "-f", "/dev/null"]
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
FROM python:3.10-bookworm
22

3-
# Install Poetry
4-
RUN curl -sSL https://install.python-poetry.org | python3 - && \
5-
ln -s /root/.local/bin/poetry /usr/local/bin/poetry
6-
7-
# Configurate Poetry
8-
RUN poetry config virtualenvs.create false
3+
# Install uv
4+
RUN pip install uv
95

106
COPY . /app/camel
117

128
WORKDIR /app/camel
139

14-
RUN poetry install
10+
# Setup virtual environment and install dependencies
11+
RUN uv venv .venv --python=3.10 && \
12+
. .venv/bin/activate && \
13+
uv pip install -e ".[all, dev]" && \
14+
pip install pre-commit mypy
1515

1616
CMD ["tail", "-f", "/dev/null"]

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Go over all the following points, and put an `x` in all the boxes that apply.
88

99
- [ ] I have read the [CONTRIBUTION](https://github.com/camel-ai/camel/blob/master/CONTRIBUTING.md) guide (**required**)
1010
- [ ] I have linked this PR to an issue using the Development section on the right sidebar or by adding `Fixes #issue-number` in the PR description (**required**)
11-
- [ ] I have checked if any dependencies need to be added or updated in `pyproject.toml` and `poetry.lock`
11+
- [ ] I have checked if any dependencies need to be added or updated in `pyproject.toml` and `uv lock`
1212
- [ ] I have updated the tests accordingly (*required for a bug fix or a new feature*)
1313
- [ ] I have updated the documentation if needed:
1414
- [ ] I have added examples if this is a new feature
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'camel_install'
2-
description: 'Setup python environment and install dependencies for CAMEL by poetry.'
2+
description: 'Setup python environment and install dependencies for CAMEL using uv.'
33
inputs:
44
python-version:
55
description: 'Python version.'
@@ -12,25 +12,28 @@ runs:
1212
uses: actions/setup-python@v3
1313
with:
1414
python-version: '${{ inputs.python-version }}'
15-
- name: Install poetry
16-
uses: abatilo/actions-poetry@v2
17-
- name: Setup poetry virtual environment
15+
- name: Install uv
1816
run: |
19-
poetry config virtualenvs.create true --local
20-
poetry config virtualenvs.in-project true --local
17+
pip install uv
18+
shell: bash
19+
- name: Setup virtual environment
20+
run: |
21+
uv venv .venv --python=${{ inputs.python-version }}
2122
shell: bash
2223
- uses: actions/cache/restore@v3
2324
id: cache-restore
24-
name: Restore caches for the virtual environment based on poetry.lock
25+
name: Restore caches for the virtual environment based on uv.lock
2526
with:
2627
path: ./.venv
27-
key: venv-${{ hashFiles('poetry.lock') }}
28+
key: venv-${{ hashFiles('uv.lock') }}
2829
- name: Install the project dependencies
29-
run: poetry install --with dev,docs -E all
30+
run: |
31+
source .venv/bin/activate
32+
uv pip install -e ".[all, dev]"
3033
shell: bash
3134
- uses: actions/cache/save@v3
32-
name: Save caches based on poetry.lock
35+
name: Save caches based on uv.lock
3336
if: ${{ !steps.cache-restore.outputs.cache-hit }}
3437
with:
3538
path: ./.venv
36-
key: venv-${{ hashFiles('poetry.lock') }}
39+
key: venv-${{ hashFiles('uv.lock') }}

.github/workflows/build_package.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,45 @@ jobs:
1818
sudo rm -rf $HOME/.cache/pip
1919
df -h
2020
21-
- name: Set up Python environment and install dependencies
21+
- name: Set up Python environment
2222
uses: actions/setup-python@v3
2323
with:
2424
python-version: "3.10"
2525

26+
- name: Install uv
27+
run: |
28+
pip install uv
29+
30+
- name: Create virtual environment
31+
run: |
32+
uv venv .venv --python=3.10
33+
2634
- name: Install dependencies
2735
run: |
28-
pip install poetry
29-
poetry install
36+
source .venv/bin/activate
37+
uv pip install -e ".[all, dev]"
3038
3139
- name: Build
32-
run: poetry build
40+
run: |
41+
source .venv/bin/activate
42+
uv pip install -e ".[all, dev]"
43+
uv pip install build
44+
python -m build
3345
3446
- name: Set up test environment
3547
run: |
36-
python -m venv venv
37-
source venv/bin/activate
48+
python -m venv test_venv
49+
source test_venv/bin/activate
3850
3951
- name: Install the package
4052
run: |
53+
source test_venv/bin/activate
4154
WHEEL_FILE=$(ls dist/*.whl)
4255
pip install "${WHEEL_FILE}[all,test]"
4356
4457
- name: Test import
4558
run: |
46-
source venv/bin/activate
59+
source test_venv/bin/activate
4760
python -c "import camel"
4861
4962
- name: Run tests with Pytest
@@ -85,7 +98,7 @@ jobs:
8598
AIML_API_KEY: "${{ secrets.AIML_API_KEY }}"
8699
NVIDIA_API_KEY: "${{ secrets.NVIDIA_API_KEY }}"
87100
run: |
88-
source venv/bin/activate
101+
source test_venv/bin/activate
89102
pytest --fast-test-mode ./test
90103
91104
- name: Clean up after build

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Sphinx build
2828
run: |
2929
cd docs
30-
poetry run make html
30+
make html
3131
3232
- name: Deploy
3333
uses: peaceiris/actions-gh-pages@v4

.github/workflows/pre_commit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ jobs:
1616
with:
1717
python-version: "3.10"
1818
- name: Run pre-commit
19-
run: poetry run pre-commit run --all-files
19+
run: |
20+
source .venv/bin/activate
21+
pre-commit run --all-files
22+
shell: bash

.github/workflows/publish_release.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,32 @@ jobs:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
2020

21-
- name: Build and publish to PyPI
22-
uses: JRubics/[email protected]
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
2323
with:
24-
python_version: '3.10'
25-
pypi_token: ${{ secrets.PYPI_API_KEY }}
24+
python-version: '3.10'
25+
26+
- name: Install uv
27+
run: pip install uv
28+
29+
- name: Setup virtual environment
30+
run: uv venv .venv --python=3.10
31+
32+
- name: Build package
33+
run: |
34+
source .venv/bin/activate
35+
uv pip install -e ".[all, dev]"
36+
uv pip install build
37+
python -m build
38+
39+
- name: Publish to PyPI
40+
env:
41+
TWINE_USERNAME: __token__
42+
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}
43+
run: |
44+
source .venv/bin/activate
45+
uv pip install twine
46+
twine upload dist/*
2647
2748
- name: Upload built artifacts
2849
uses: actions/upload-artifact@v4

.github/workflows/pytest_apps.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ jobs:
2828
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
2929
GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}"
3030
SEARCH_ENGINE_ID: "${{ secrets.SEARCH_ENGINE_ID }}"
31-
run: poetry run pytest -v apps/
31+
run: |
32+
source .venv/bin/activate
33+
uv pip install -e ".[all, dev]"
34+
pytest -v apps/
3235
3336
pytest_examples:
3437

@@ -50,4 +53,7 @@ jobs:
5053
MOONSHOT_API_KEY: "${{ secrets.MOONSHOT_API_KEY }}"
5154
SILICONFLOW_API_KEY: "${{ secrets.SILICONFLOW_API_KEY }}"
5255
AIML_API_KEY: "${{ secrets.AIML_API_KEY }}"
53-
run: poetry run pytest -v examples/
56+
run: |
57+
source .venv/bin/activate
58+
uv pip install -e ".[all,test]"
59+
pytest -v examples/

.github/workflows/pytest_package.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ jobs:
6262
MOONSHOT_API_KEY: "${{ secrets.MOONSHOT_API_KEY }}"
6363
SILICONFLOW_API_KEY: "${{ secrets.SILICONFLOW_API_KEY }}"
6464
AIML_API_KEY: "${{ secrets.AIML_API_KEY }}"
65-
run: poetry run pytest --fast-test-mode test/
65+
run: |
66+
source .venv/bin/activate
67+
uv pip install -e ".[all, dev]"
68+
pytest --fast-test-mode test/
6669
6770
pytest_package_llm_test:
6871
runs-on: ubuntu-latest
@@ -113,7 +116,10 @@ jobs:
113116
MOONSHOT_API_KEY: "${{ secrets.MOONSHOT_API_KEY }}"
114117
SILICONFLOW_API_KEY: "${{ secrets.SILICONFLOW_API_KEY }}"
115118
AIML_API_KEY: "${{ secrets.AIML_API_KEY }}"
116-
run: poetry run pytest --llm-test-only test/
119+
run: |
120+
source .venv/bin/activate
121+
uv pip install -e ".[all, dev]"
122+
pytest --llm-test-only test/
117123
118124
pytest_package_very_slow_test:
119125
runs-on: ubuntu-latest
@@ -162,4 +168,7 @@ jobs:
162168
INTERNLM_API_KEY: "${{ secrets.INTERNLM_API_KEY }}"
163169
JINA_API_KEY: "${{ secrets.JINA_API_KEY }}"
164170
MOONSHOT_API_KEY: "${{ secrets.MOONSHOT_API_KEY }}"
165-
run: poetry run pytest --very-slow-test-only test/
171+
run: |
172+
source .venv/bin/activate
173+
uv pip install -e ".[all, dev]"
174+
pytest --very-slow-test-only test/

0 commit comments

Comments
 (0)