Skip to content

Commit 1996b52

Browse files
authored
chore: migrate to uv package manager (#355)
- Migrate from `poetry` to `uv`. - Relates: apify/crawlee-python#628
1 parent 443b113 commit 1996b52

File tree

12 files changed

+1594
-1915
lines changed

12 files changed

+1594
-1915
lines changed

.github/workflows/_async_docstrings_check.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55

66
env:
7-
PYTHON_VERSION: 3.12
7+
PYTHON_VERSION: 3.13
88

99
jobs:
1010
async_docstring_check:
@@ -20,10 +20,13 @@ jobs:
2020
with:
2121
python-version: ${{ env.PYTHON_VERSION }}
2222

23+
- name: Set up uv package manager
24+
uses: astral-sh/setup-uv@v5
25+
with:
26+
python-version: ${{ env.PYTHON_VERSION }}
27+
2328
- name: Install dependencies
24-
run: |
25-
pipx install --python ${{ env.PYTHON_VERSION }} poetry
26-
make install-dev
29+
run: make install-dev
2730

2831
- name: Run async docstrings check
2932
run: make check-async-docstrings

.github/workflows/build_and_deploy_docs.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
NODE_VERSION: 20
11-
PYTHON_VERSION: 3.12
11+
PYTHON_VERSION: 3.13
1212

1313
jobs:
1414
build_and_deploy_docs:
@@ -54,10 +54,13 @@ jobs:
5454
with:
5555
python-version: ${{ env.PYTHON_VERSION }}
5656

57+
- name: Set up uv package manager
58+
uses: astral-sh/setup-uv@v5
59+
with:
60+
python-version: ${{ env.PYTHON_VERSION }}
61+
5762
- name: Install Python dependencies
58-
run: |
59-
pipx install --python ${{ env.PYTHON_VERSION }} poetry
60-
make install-dev
63+
run: make install-dev
6164

6265
- name: Build generated API reference
6366
run: make build-api-reference

.github/workflows/pre_release.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
2222
changelog: ${{ steps.release_metadata.outputs.changelog }}
2323
steps:
24-
- uses: apify/workflows/git-cliff-release@main
24+
- uses: apify/workflows/git-cliff-release@switch-to-uv
2525
id: release_metadata
2626
name: Prepare release metadata
2727
with:
@@ -30,29 +30,29 @@ jobs:
3030

3131
lint_check:
3232
name: Lint check
33-
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
33+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@switch-to-uv
3434

3535
type_check:
3636
name: Type check
37-
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
37+
uses: apify/workflows/.github/workflows/python_type_check.yaml@switch-to-uv
3838

3939
unit_tests:
4040
name: Unit tests
41-
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
41+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@switch-to-uv
4242

4343
async_docstrings:
4444
name: Async dostrings check
4545
uses: ./.github/workflows/_async_docstrings_check.yaml
4646

4747
integration_tests:
4848
name: Integration tests
49-
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
49+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@switch-to-uv
5050
secrets: inherit
5151

5252
update_changelog:
5353
name: Update changelog
5454
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
55-
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
55+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@switch-to-uv
5656
with:
5757
version_number: ${{ needs.release_metadata.outputs.version_number }}
5858
changelog: ${{ needs.release_metadata.outputs.changelog }}
@@ -71,7 +71,7 @@ jobs:
7171
url: https://pypi.org/project/apify-client
7272
steps:
7373
- name: Prepare distribution
74-
uses: apify/workflows/prepare-pypi-distribution@main
74+
uses: apify/workflows/prepare-pypi-distribution@switch-to-uv
7575
with:
7676
package_name: apify-client
7777
is_prerelease: "yes"

.github/workflows/release.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ jobs:
2525
release_metadata:
2626
name: Prepare release metadata
2727
runs-on: ubuntu-latest
28-
outputs:
28+
outputs:
2929
version_number: ${{ steps.release_metadata.outputs.version_number }}
3030
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
3131
changelog: ${{ steps.release_metadata.outputs.changelog }}
3232
release_notes: ${{ steps.release_metadata.outputs.release_notes }}
3333
steps:
34-
- uses: apify/workflows/git-cliff-release@main
34+
- uses: apify/workflows/git-cliff-release@switch-to-uv
3535
name: Prepare release metadata
3636
id: release_metadata
3737
with:
@@ -41,33 +41,33 @@ jobs:
4141

4242
lint_check:
4343
name: Lint check
44-
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
44+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@switch-to-uv
4545

4646
type_check:
4747
name: Type check
48-
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
48+
uses: apify/workflows/.github/workflows/python_type_check.yaml@switch-to-uv
4949

5050
unit_tests:
5151
name: Unit tests
52-
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
52+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@switch-to-uv
5353

5454
async_docstrings:
5555
name: Async dostrings check
5656
uses: ./.github/workflows/_async_docstrings_check.yaml
5757

5858
integration_tests:
5959
name: Integration tests
60-
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
60+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@switch-to-uv
6161
secrets: inherit
6262

6363
update_changelog:
6464
name: Update changelog
6565
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
66-
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
66+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@switch-to-uv
6767
with:
6868
version_number: ${{ needs.release_metadata.outputs.version_number }}
6969
changelog: ${{ needs.release_metadata.outputs.changelog }}
70-
secrets:
70+
secrets:
7171
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
7272

7373
create_github_release:
@@ -97,8 +97,8 @@ jobs:
9797
url: https://pypi.org/project/apify-client
9898
steps:
9999
- name: Prepare distribution
100-
uses: apify/workflows/prepare-pypi-distribution@main
101-
with:
100+
uses: apify/workflows/prepare-pypi-distribution@switch-to-uv
101+
with:
102102
package_name: apify-client
103103
is_prerelease: ""
104104
version_number: ${{ needs.release_metadata.outputs.version_number }}

.github/workflows/run_code_checks.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ on:
99
jobs:
1010
lint_check:
1111
name: Lint check
12-
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
12+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@switch-to-uv
1313

1414
type_check:
1515
name: Type check
16-
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
16+
uses: apify/workflows/.github/workflows/python_type_check.yaml@switch-to-uv
1717

1818
unit_tests:
1919
name: Unit tests
20-
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
20+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@switch-to-uv
2121

2222
async_docstrings:
2323
name: Async dostrings check
2424
uses: ./.github/workflows/_async_docstrings_check.yaml
2525

2626
docs_check:
2727
name: Docs check
28-
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main
28+
uses: apify/workflows/.github/workflows/python_docs_check.yaml@switch-to-uv
2929

3030
integration_tests:
3131
name: Integration tests
3232
needs: [lint_check, type_check, unit_tests]
33-
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
33+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@switch-to-uv
3434
secrets: inherit

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ __pycache__
1010
.envrc
1111
.python-version
1212

13-
# Poetry
14-
poetry.toml
15-
1613
# Mise
1714
mise.toml
1815
.mise.toml

CONTRIBUTING.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Here you'll find a contributing guide to get started with development.
66

77
For local development, it is required to have Python 3.9 (or a later version) installed.
88

9-
We use [Poetry](https://python-poetry.org/) for project management. Install it and set up your IDE accordingly.
9+
We use [uv](https://docs.astral.sh/uv/) for project management. Install it and set up your IDE accordingly.
1010

1111
## Dependencies
1212

@@ -139,28 +139,22 @@ Publishing new versions to [PyPI](https://pypi.org/project/apify_client) is auto
139139

140140
3. Update the version number:
141141

142-
- Modify the `version` field under `tool.poetry` in `pyproject.toml`.
142+
- Modify the `version` field under `project` in `pyproject.toml`.
143143

144144
```toml
145-
[tool.poetry]
145+
[project]
146146
name = "apify_client"
147147
version = "x.z.y"
148148
```
149149

150150
4. Generate the distribution archives for the package:
151151

152152
```shell
153-
poetry build
153+
uv build
154154
```
155155

156-
5. Set up the PyPI API token for authentication:
156+
5. Set up the PyPI API token for authentication and upload the package to PyPI:
157157

158158
```shell
159-
poetry config pypi-token.pypi YOUR_API_TOKEN
160-
```
161-
162-
6. Upload the package to PyPI:
163-
164-
```shell
165-
poetry publish
159+
uv publish --token YOUR_API_TOKEN
166160
```

Makefile

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,51 @@ clean:
99
rm -rf .mypy_cache .pytest_cache .ruff_cache build dist htmlcov .coverage
1010

1111
install-dev:
12-
poetry install --all-extras
13-
poetry run pre-commit install
12+
uv sync --all-extras
13+
uv run pre-commit install
1414

1515
build:
16-
poetry build --no-interaction -vv
16+
uv build --verbose
1717

1818
# APIFY_PYPI_TOKEN_CRAWLEE is expected to be set in the environment
1919
publish-to-pypi:
20-
poetry config pypi-token.pypi "${APIFY_PYPI_TOKEN_CRAWLEE}"
21-
poetry publish --no-interaction -vv
20+
uv publish --verbose --token "${APIFY_PYPI_TOKEN_CRAWLEE}"
2221

2322
lint:
24-
poetry run ruff format --check
25-
poetry run ruff check
23+
uv run ruff format --check
24+
uv run ruff check
2625

2726
type-check:
28-
poetry run mypy
27+
uv run mypy
2928

3029
unit-tests:
31-
poetry run pytest --numprocesses=auto --verbose --cov=src/apify_client tests/unit
30+
uv run pytest --numprocesses=auto --verbose --cov=src/apify_client tests/unit
3231

3332
unit-tests-cov:
34-
poetry run pytest --numprocesses=auto --verbose --cov=src/apify_client --cov-report=html tests/unit
33+
uv run pytest --numprocesses=auto --verbose --cov=src/apify_client --cov-report=html tests/unit
3534

3635
integration-tests:
37-
poetry run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) tests/integration
36+
uv run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) --verbose tests/integration
3837

3938
format:
40-
poetry run ruff check --fix
41-
poetry run ruff format
39+
uv run ruff check --fix
40+
uv run ruff format
4241

4342
check-async-docstrings:
44-
poetry run python scripts/check_async_docstrings.py
43+
uv run python scripts/check_async_docstrings.py
4544

4645
# The check-code target runs a series of checks equivalent to those performed by pre-commit hooks
4746
# and the run_checks.yaml GitHub Actions workflow.
4847
check-code: lint type-check unit-tests check-async-docstrings
4948

5049
fix-async-docstrings:
51-
poetry run python scripts/fix_async_docstrings.py
50+
uv run python scripts/fix_async_docstrings.py
5251

5352
build-api-reference:
54-
cd website && poetry run ./build_api_reference.sh
53+
cd website && uv run ./build_api_reference.sh
5554

5655
build-docs:
57-
cd website && npm clean-install && npm run build
56+
cd website && uv run npm clean-install && uv run npm run build
5857

5958
run-docs: build-api-reference
60-
cd website && npm clean-install && npm run start
59+
cd website && uv run npm clean-install && uv run npm run start

docs/01_overview/02_setting_up.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ If these commands return the respective versions, you're ready to continue.
3535

3636
## Installation
3737

38-
Apify client for Python is available as the [`apify-client`](https://pypi.org/project/crawlee/) package on PyPI. To install it, run:
38+
Apify client for Python is available as the [`apify-client`](https://pypi.org/project/apify-client/) package on PyPI. To install it, run:
3939

4040
```sh
4141
pip install apify-client

0 commit comments

Comments
 (0)