Skip to content

Commit 8e26299

Browse files
authored
chore: migrate to uv package manager (#406)
- Migrate from `poetry` to `uv`. - Relates: apify/crawlee-python#628
1 parent 3bff7ab commit 8e26299

File tree

10 files changed

+3049
-3943
lines changed

10 files changed

+3049
-3943
lines changed

.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: 22
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
@@ -22,33 +22,33 @@ jobs:
2222
changelog: ${{ steps.release_metadata.outputs.changelog }}
2323
existing_changelog_path: CHANGELOG.md
2424
steps:
25-
- uses: apify/workflows/git-cliff-release@main
25+
- uses: apify/workflows/git-cliff-release@switch-to-uv
2626
id: release_metadata
2727
name: Prepare release metadata
2828
with:
2929
release_type: prerelease
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
integration_tests:
4444
name: Integration tests
45-
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
45+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@switch-to-uv
4646
secrets: inherit
4747

4848
update_changelog:
4949
name: Update changelog
5050
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
51-
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
51+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@switch-to-uv
5252
with:
5353
version_number: ${{ needs.release_metadata.outputs.version_number }}
5454
changelog: ${{ needs.release_metadata.outputs.changelog }}
@@ -67,7 +67,7 @@ jobs:
6767
url: https://pypi.org/project/apify
6868
steps:
6969
- name: Prepare distribution
70-
uses: apify/workflows/prepare-pypi-distribution@main
70+
uses: apify/workflows/prepare-pypi-distribution@switch-to-uv
7171
with:
7272
package_name: apify
7373
is_prerelease: "yes"

.github/workflows/release.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
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,25 +41,25 @@ 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
integration_tests:
5555
name: Integration tests
56-
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
56+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@switch-to-uv
5757
secrets: inherit
5858

5959
update_changelog:
6060
name: Update changelog
6161
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
62-
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
62+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@switch-to-uv
6363
with:
6464
version_number: ${{ needs.release_metadata.outputs.version_number }}
6565
changelog: ${{ needs.release_metadata.outputs.changelog }}
@@ -93,7 +93,7 @@ jobs:
9393
url: https://pypi.org/project/apify
9494
steps:
9595
- name: Prepare distribution
96-
uses: apify/workflows/prepare-pypi-distribution@main
96+
uses: apify/workflows/prepare-pypi-distribution@switch-to-uv
9797
with:
9898
package_name: apify
9999
is_prerelease: ""

.github/workflows/run_code_checks.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ 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
docs_check:
2323
name: Docs check
24-
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main
24+
uses: apify/workflows/.github/workflows/python_docs_check.yaml@switch-to-uv
2525

2626
integration_tests:
2727
name: Integration tests
2828
needs: [lint_check, type_check, unit_tests]
29-
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
29+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@switch-to-uv
3030
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) is automated t
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"
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: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.PHONY: clean install-dev build publish-to-pypi lint type-check unit-tests unit-tests-cov \
2-
integration-tests format check-code build-api-reference build-docs run-docs
2+
integration-tests format check-code build-api-reference build-docs run-docs
33

44
# This is default for local testing, but GitHub workflows override it to a higher value in CI
55
INTEGRATION_TESTS_CONCURRENCY = 1
@@ -8,46 +8,45 @@ clean:
88
rm -rf .mypy_cache .pytest_cache .ruff_cache build dist htmlcov .coverage
99

1010
install-dev:
11-
poetry install --all-extras
12-
poetry run pre-commit install
11+
uv sync --all-extras
12+
uv run pre-commit install
1313

1414
build:
15-
poetry build --no-interaction -vv
15+
uv build --verbose
1616

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

2221
lint:
23-
poetry run ruff format --check
24-
poetry run ruff check
22+
uv run ruff format --check
23+
uv run ruff check
2524

2625
type-check:
27-
poetry run mypy
26+
uv run mypy
2827

2928
unit-tests:
30-
poetry run pytest --numprocesses=auto --verbose --cov=src/apify tests/unit
29+
uv run pytest --numprocesses=auto --verbose --cov=src/apify tests/unit
3130

3231
unit-tests-cov:
33-
poetry run pytest --numprocesses=auto --verbose --cov=src/apify --cov-report=html tests/unit
32+
uv run pytest --numprocesses=auto --verbose --cov=src/apify --cov-report=html tests/unit
3433

3534
integration-tests:
36-
poetry run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) --verbose tests/integration
35+
uv run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) --verbose tests/integration
3736

3837
format:
39-
poetry run ruff check --fix
40-
poetry run ruff format
38+
uv run ruff check --fix
39+
uv run ruff format
4140

4241
# The check-code target runs a series of checks equivalent to those performed by pre-commit hooks
4342
# and the run_checks.yaml GitHub Actions workflow.
4443
check-code: lint type-check unit-tests
4544

4645
build-api-reference:
47-
cd website && poetry run ./build_api_reference.sh
46+
cd website && uv run ./build_api_reference.sh
4847

4948
build-docs:
50-
cd website && poetry run npm clean-install && poetry run npm run build
49+
cd website && uv run npm clean-install && uv run npm run build
5150

5251
run-docs: build-api-reference
53-
cd website && poetry run npm clean-install && poetry run npm run start
52+
cd website && uv run npm clean-install && uv run npm run start

0 commit comments

Comments
 (0)