Skip to content

Commit

Permalink
chore: migrate from poetry to uv (#174)
Browse files Browse the repository at this point in the history
* chore: migrate from poetry to uv

Relates: apify/crawlee-python#628

* fix update package version

* update package version using sed
  • Loading branch information
vdusek authored Feb 19, 2025
1 parent 22b5eb4 commit e523dd4
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 45 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/python_bump_and_update_changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ jobs:
with:
python-version: ${{ inputs.python_version }}

- name: Install poetry
run: pipx install --python ${{ inputs.python_version }} poetry
- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ inputs.python_version }}

- name: Update package version in pyproject.toml
run: poetry version ${{ inputs.version_number }}
shell: bash
run: |
new_version="${{ inputs.version_number }}"
echo "Updating version in pyproject.toml to ${new_version}"
# Update the "version" key in the [project] section of pyproject.toml.
sed -i '/^\[project\]/,/^\[/ s/^\(version\s*=\s*\)".*"/\1"'${new_version}'"/' pyproject.toml
- name: Update CHANGELOG.md
uses: DamianReeves/write-file-action@master
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/python_docs_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ jobs:
with:
python-version: ${{ inputs.python_version }}

- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ inputs.python_version }}

- name: Install Python dependencies
run: |
pipx install --python ${{ inputs.python_version }} poetry
make install-dev
run: make install-dev

- name: Build API reference
run: make build-api-reference
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/python_integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
pipx install --python ${{ matrix.python-version }} poetry
make install-dev
run: make install-dev

- name: Run integration tests
run: make INTEGRATION_TESTS_CONCURRENCY=8 integration-tests
Expand Down Expand Up @@ -77,14 +80,15 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
pipx install --python ${{ matrix.python-version }} poetry
# This forces poetry to use specific Python version when installing a project.
# Raises error, if this Python version does not match project specific Python constraints.
poetry config virtualenvs.use-poetry-python true
poetry env use ${{ matrix.python-version }}
make install-dev
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Run integration tests
run: make INTEGRATION_TESTS_CONCURRENCY=8 integration-tests
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/python_lint_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
pipx install --python ${{ matrix.python-version }} poetry
# This forces poetry to use specific Python version when installing a project.
# Raises error, if this Python version does not match project specific Python constraints.
poetry config virtualenvs.use-poetry-python true
poetry env use ${{ matrix.python-version }}
make install-dev
run: make install-dev

- name: Run lint check
run: make lint
13 changes: 6 additions & 7 deletions .github/workflows/python_type_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
pipx install --python ${{ matrix.python-version }} poetry
# This forces poetry to use specific Python version when installing a project.
# Raises error, if this Python version does not match project specific Python constraints.
poetry config virtualenvs.use-poetry-python true
poetry env use ${{ matrix.python-version }}
make install-dev
run: make install-dev

- name: Run type check
run: make type-check
15 changes: 5 additions & 10 deletions .github/workflows/python_unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry for version checking
run: |
pip install poetry
- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
pipx install --python ${{ matrix.python-version }} poetry
# This forces poetry to use specific Python version when installing a project.
# Raises error, if this Python version does not match project specific Python constraints.
poetry config virtualenvs.use-poetry-python true
poetry env use ${{ matrix.python-version }}
make install-dev
run: make install-dev

- name: Run unit tests
run: make unit-tests
14 changes: 10 additions & 4 deletions prepare-pypi-distribution/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ runs:
with:
python-version: ${{ inputs.python_version }}

- name: Set up uv package manager
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ inputs.python_version }}

- name: Install dependencies
shell: bash
run: |
pipx install --python ${{ inputs.python_version }} poetry
make install-dev
run: make install-dev

# Updates the version number in the project's configuration.
- name: Set version in pyproject.toml
Expand All @@ -55,7 +58,10 @@ runs:
.[0] + 1
'
)
poetry version "${{ inputs.version_number }}b$next_beta"
new_version="${{ inputs.version_number }}b${next_beta}"
echo "Updating version in pyproject.toml to ${new_version}"
# Update the "version" key in the [project] section of pyproject.toml.
sed -i '/^\[project\]/,/^\[/ s/^\(version\s*=\s*\)".*"/\1"'${new_version}'"/' pyproject.toml
fi
# Builds the package.
Expand Down

0 comments on commit e523dd4

Please sign in to comment.