Skip to content

Commit 331a301

Browse files
authored
chore: migrate to uv package manager (#994)
- Migrate from `poetry` to `uv`. - Relates: #628 - The update of templates to use `uv` will be implemented separately.
1 parent a3a2b4f commit 331a301

File tree

10 files changed

+3415
-4260
lines changed

10 files changed

+3415
-4260
lines changed

.github/workflows/build_and_deploy_docs.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ jobs:
3939
with:
4040
python-version: ${{ env.PYTHON_VERSION }}
4141

42+
- name: Install uv package manager
43+
uses: astral-sh/setup-uv@v5
44+
with:
45+
python-version: ${{ env.PYTHON_VERSION }}
46+
4247
- name: Install Python dependencies
43-
run: |
44-
pipx install --python ${{ env.PYTHON_VERSION }} poetry
45-
make install-dev
48+
run: make install-dev
4649

4750
- name: Build generated API reference
4851
run: make build-api-reference

.github/workflows/pre_release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
2525
changelog: ${{ steps.release_metadata.outputs.changelog }}
2626
steps:
27-
- uses: apify/workflows/git-cliff-release@main
27+
- uses: apify/workflows/git-cliff-release@switch-to-uv
2828
id: release_metadata
2929
name: Prepare release metadata
3030
with:
@@ -47,7 +47,7 @@ jobs:
4747
update_changelog:
4848
name: Update changelog
4949
needs: [release_metadata, wait_for_checks]
50-
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
50+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@switch-to-uv
5151
with:
5252
version_number: ${{ needs.release_metadata.outputs.version_number }}
5353
changelog: ${{ needs.release_metadata.outputs.changelog }}
@@ -74,7 +74,7 @@ jobs:
7474
url: https://pypi.org/project/crawlee
7575
steps:
7676
- name: Prepare distribution
77-
uses: apify/workflows/prepare-pypi-distribution@main
77+
uses: apify/workflows/prepare-pypi-distribution@switch-to-uv
7878
with:
7979
package_name: crawlee
8080
is_prerelease: "yes"

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
changelog: ${{ steps.release_metadata.outputs.changelog }}
3636
release_notes: ${{ steps.release_metadata.outputs.release_notes }}
3737
steps:
38-
- uses: apify/workflows/git-cliff-release@main
38+
- uses: apify/workflows/git-cliff-release@switch-to-uv
3939
name: Prepare release metadata
4040
id: release_metadata
4141
with:
@@ -72,7 +72,7 @@ jobs:
7272
update_changelog:
7373
name: Update changelog
7474
needs: [release_metadata, wait_for_checks]
75-
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
75+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@switch-to-uv
7676
with:
7777
version_number: ${{ needs.release_metadata.outputs.version_number }}
7878
changelog: ${{ needs.release_metadata.outputs.changelog }}
@@ -113,7 +113,7 @@ jobs:
113113
url: https://pypi.org/project/crawlee
114114
steps:
115115
- name: Prepare distribution
116-
uses: apify/workflows/prepare-pypi-distribution@main
116+
uses: apify/workflows/prepare-pypi-distribution@switch-to-uv
117117
with:
118118
package_name: crawlee
119119
is_prerelease: ""

.github/workflows/run_code_checks.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ on:
1919
jobs:
2020
lint_check:
2121
name: Lint check
22-
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
22+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@switch-to-uv
2323

2424
type_check:
2525
name: Type check
26-
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
26+
uses: apify/workflows/.github/workflows/python_type_check.yaml@switch-to-uv
2727

2828
unit_tests:
2929
name: Unit tests
30-
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
30+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@switch-to-uv
3131
secrets:
3232
httpbin_url: ${{ secrets.APIFY_HTTPBIN_TOKEN && format('https://httpbin.apify.actor?token={0}', secrets.APIFY_HTTPBIN_TOKEN) || 'https://httpbin.org'}}
3333

3434
docs_check:
3535
name: Docs check
36-
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main
36+
uses: apify/workflows/.github/workflows/python_docs_check.yaml@switch-to-uv

.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
# Other Python tools
1714
.ropeproject
1815

CONTRIBUTING.md

Lines changed: 8 additions & 8 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

@@ -129,37 +129,37 @@ make run-docs
129129
Publishing new versions to [PyPI](https://pypi.org/project/crawlee) is automated through GitHub Actions.
130130

131131
- **Beta releases**: On each commit to the master branch, a new beta release is automatically published. The version number is determined based on the latest release and conventional commits. The beta version suffix is incremented by 1 from the last beta release on PyPI.
132-
- **Stable releases**: A stable version release may be created by triggering the `run_release` GitHub Actions workflow. The version number is determined based on the latest release and conventional commits (`auto` release type), or it may be overriden using the `custom` release type.
132+
- **Stable releases**: A stable version release may be created by triggering the `release` GitHub Actions workflow. The version number is determined based on the latest release and conventional commits (`auto` release type), or it may be overriden using the `custom` release type.
133133

134134
### Publishing to PyPI manually
135135

136-
1. **Do not do this unless absolutely necessary.** In all conceivable scenarios, you should use the `run_release` workflow instead.
136+
1. **Do not do this unless absolutely necessary.** In all conceivable scenarios, you should use the `release` workflow instead.
137137
2. **Make sure you know what you're doing.**
138138

139139
3. Update the version number:
140140

141-
- Modify the `version` field under `tool.poetry` in `pyproject.toml`.
141+
- Modify the `version` field under `project` in `pyproject.toml`.
142142

143143
```toml
144-
[tool.poetry]
144+
[project]
145145
name = "crawlee"
146146
version = "x.z.y"
147147
```
148148

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

151151
```shell
152-
poetry build
152+
uv build
153153
```
154154

155155
5. Set up the PyPI API token for authentication:
156156

157157
```shell
158-
poetry config pypi-token.pypi YOUR_API_TOKEN
158+
uv config pypi-token.pypi YOUR_API_TOKEN
159159
```
160160

161161
6. Upload the package to PyPI:
162162

163163
```shell
164-
poetry publish
164+
uv publish
165165
```

Makefile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
.PHONY: clean install-dev build publish-to-pypi lint type-check unit-tests unit-tests-cov integration-tests format check-code build-api-reference run-docs
1+
.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 run-docs
23

34
# This is default for local testing, but GitHub workflows override it to a higher value in CI
45
INTEGRATION_TESTS_CONCURRENCY = 1
@@ -7,48 +8,47 @@ clean:
78
rm -rf .mypy_cache .pytest_cache .ruff_cache build dist htmlcov .coverage
89

910
install-dev:
10-
poetry install --all-extras
11-
poetry run pre-commit install
12-
poetry run playwright install
13-
poetry run python -m browserforge update
11+
uv sync --all-extras
12+
uv run pre-commit install
13+
uv run playwright install
14+
uv run python -m browserforge update
1415

1516
build:
16-
poetry build --no-interaction -vv
17+
uv build --verbose
1718

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

2323
lint:
24-
poetry run ruff format --check
25-
poetry run ruff check
24+
uv run ruff format --check
25+
uv run ruff check
2626

2727
type-check:
28-
poetry run mypy
28+
uv run mypy
2929

3030
unit-tests:
31-
poetry run pytest --numprocesses=auto --verbose --cov=src/crawlee tests/unit
31+
uv run pytest --numprocesses=auto --verbose --cov=src/crawlee tests/unit
3232

3333
unit-tests-cov:
34-
poetry run pytest --numprocesses=auto --verbose --cov=src/crawlee --cov-report=html tests/unit
34+
uv run pytest --numprocesses=auto --verbose --cov=src/crawlee --cov-report=html tests/unit
3535

3636
integration-tests:
37-
poetry run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) tests/integration
37+
uv run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) --verbose tests/integration
3838

3939
format:
40-
poetry run ruff check --fix
41-
poetry run ruff format
40+
uv run ruff check --fix
41+
uv run ruff format
4242

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

4747
build-api-reference:
48-
cd website && poetry run ./build_api_reference.sh
48+
cd website && uv run ./build_api_reference.sh
4949

5050
build-docs:
51-
cd website && corepack enable && yarn && poetry run yarn build
51+
cd website && corepack enable && yarn && uv run yarn build
5252

5353
run-docs: build-api-reference
54-
cd website && corepack enable && yarn && poetry run yarn start
54+
cd website && corepack enable && yarn && uv run yarn start

0 commit comments

Comments
 (0)