Skip to content

Commit

Permalink
Migrate from poetry to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI committed Sep 12, 2024
1 parent 45d9e7d commit c30dbec
Show file tree
Hide file tree
Showing 9 changed files with 1,121 additions and 1,628 deletions.
34 changes: 14 additions & 20 deletions .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,40 @@ runs:
echo "$PYTHON_USER_BASE/bin" >> $GITHUB_PATH
echo "pip-user-base=$PYTHON_USER_BASE" >> $GITHUB_OUTPUT
- name: Get poetry latest version
- name: Get uv latest version
id: latest-versions
shell: bash
run: |
poetry_version=$(curl -s https://pypi.org/pypi/poetry/json | jq -r .info.version)
echo "poetry=$poetry_version" >> $GITHUB_OUTPUT
echo "Python user base: $(python -m site --user-base)"
uv_version=$(curl -s https://pypi.org/pypi/uv/json | jq -r .info.version)
echo "uv=$uv_version" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Cache Poetry
name: Cache uv binary
with:
path: ${{ steps.environment.outputs.pip-user-base }}
key: >
${{ format('pip-user-{0}-{1}-{2}',
${{ format('pip-user-{0}-{1}-uv-{2}',
runner.os,
inputs.python-version,
steps.latest-versions.outputs.poetry
steps.latest-versions.outputs.uv
) }}
- name: Install or update Poetry
- name: Install or update uv
id: uv
shell: bash
run: |
pip install --user poetry==${{ steps.latest-versions.outputs.poetry }}
- name: Use local virtual environment
shell: bash
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
pip install --user uv==${{ steps.latest-versions.outputs.uv }}
echo "cache-dir=$(uv cache dir)"
- uses: actions/cache@v4
name: Cache Poetry dependencies
name: Cache uv dependencies
with:
path: ./.venv
key: deps-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }}
key: deps-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('uv.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ inputs.python-version }}-
- name: Install dependencies with Poetry
- name: Install dependencies with uv
shell: bash
run: |
poetry env use python3
poetry install
uv sync
56 changes: 53 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,59 @@ jobs:
- name: Check out the repository
uses: actions/checkout@v4

- name: Prepare and install deps
uses: ./.github/actions/install-deps
- name: Set up Python ${{ '3.9' }}
uses: actions/setup-python@v5
with:
python-version: ${{ '3.9' }}

- name: Setup environment
id: environment
shell: bash
run: |
PYTHON_USER_BASE="$(python -m site --user-base)"
echo "$PYTHON_USER_BASE/bin" >> $GITHUB_PATH
echo "pip-user-base=$PYTHON_USER_BASE" >> $GITHUB_OUTPUT
- name: Get uv latest version
id: latest-versions
shell: bash
run: |
poetry_version=$(curl -s https://pypi.org/pypi/poetry/json | jq -r .info.version)
echo "poetry=$poetry_version" >> $GITHUB_OUTPUT
uv_version=$(curl -s https://pypi.org/pypi/uv/json | jq -r .info.version)
echo "uv=$uv_version" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Cache uv binary
with:
path: ${{ steps.environment.outputs.pip-user-base }}
key: >
${{ format('pip-user-{0}-{1}-uv-{2}',
runner.os,
'3.9',
steps.latest-versions.outputs.uv
) }}
- name: Install or update uv
id: uv
shell: bash
run: |
pip install --user uv==${{ steps.latest-versions.outputs.uv }}
echo "cache-dir=$(uv cache dir)"
- uses: actions/cache@v4
name: Cache uv dependencies
with:
path: ./.venv
key: deps-${{ runner.os }}-${{ '3.9' }}-${{ hashFiles('uv.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ '3.9' }}-
- name: Install dependencies with uv
shell: bash
run: |
uv sync
- name: Check if package builds
run: |
poetry build
uv build
4 changes: 2 additions & 2 deletions .github/workflows/linting-and-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
- name: Run pre-commit on all files
run: |
poetry run pre-commit run --all-files --show-diff-on-failure --color=always
uv run pre-commit run --all-files --show-diff-on-failure --color=always
- name: Run python-typing-update
run: |
poetry run pre-commit run --hook-stage manual python-typing-update --all-files --show-diff-on-failure --color=always
uv run pre-commit run --hook-stage manual python-typing-update --all-files --show-diff-on-failure --color=always
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: poetry version $(git describe --tags --abbrev=0 | sed -e "s/^v//")

- name: Build package
run: poetry build
run: uv build

- name: Publish to PyPI
run: |
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ __pycache__/
*.egg-info
/build/
/dist/

venv/
/.venv/
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,42 @@ repos:
hooks:
- id: black
name: black
entry: poetry run black
entry: uv run black
language: system
types: [python]
require_serial: true
- id: isort
name: isort
entry: poetry run isort
entry: uv run isort
language: system
types: [python]
require_serial: true
- id: mypy
name: mypy
entry: poetry run mypy
entry: uv run mypy
language: system
types: [python]
require_serial: true
- id: flake8
name: flake8
entry: poetry run flake8
entry: uv run flake8
language: system
types: [python]
- id: pylint
name: pylint
entry: poetry run pylint
entry: uv run pylint
language: system
types: [python]
require_serial: true
- id: pytest
name: pytest
language: system
entry: poetry run pytest
entry: uv run pytest
pass_filenames: false
always_run: true
- id: codespell
name: codespell
entry: poetry run codespell
entry: uv run codespell
language: system
pass_filenames: false
always_run: true
Expand Down
Loading

0 comments on commit c30dbec

Please sign in to comment.