Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UV replacement of Poetry #2349

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/constraints.txt

This file was deleted.

15 changes: 5 additions & 10 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/poetry-constraints.txt poetry
poetry --version
- name: Install UV
uses: astral-sh/setup-uv@v5
staticdev marked this conversation as resolved.
Show resolved Hide resolved
with:
version: ">=0.5.24"

- name: Install dependencies
run: poetry install
run: uv sync --all-extras --frozen

- name: Test integration
run: ./scripts/test_integration.sh
15 changes: 5 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: "pip"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I think these caches are now outdated.

Maybe something for a follow up though!


- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/poetry-constraints.txt poetry
poetry --version
- name: Install UV
uses: astral-sh/setup-uv@v5
staticdev marked this conversation as resolved.
Show resolved Hide resolved
with:
version: ">=0.5.24"

- name: Install dependencies
run: poetry install
run: uv sync --all-extras --frozen

- name: Lint
run: ./scripts/lint.sh
1 change: 0 additions & 1 deletion .github/workflows/poetry-constraints.txt

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Release Dev
staticdev marked this conversation as resolved.
Show resolved Hide resolved

"on":
push:
branches:
- main

jobs:
release:
if: github.repository_owner == 'PyCQA'
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install UV
uses: astral-sh/setup-uv@v5
with:
version: ">=0.5.24"

- name: Build package
run: |
uv build
40 changes: 13 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Release

"on":
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
release:
Expand All @@ -17,45 +17,31 @@ jobs:
with:
fetch-depth: 2

- name: Set Tag env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"

- name: Upgrade pip
- name: Install dependencies
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
uv sync --all-extras --frozen

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/poetry-constraints.txt poetry
poetry --version
- name: Install UV
uses: astral-sh/setup-uv@v5
with:
version: ">=0.5.24"

- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"

- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@v2
with:
tag-template: "{VERSION}"
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"

- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)

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

- name: Publish package on PyPI
if: steps.check-version.outputs.tag
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,13 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/poetry-constraints.txt poetry
poetry --version
- name: Install UV
staticdev marked this conversation as resolved.
Show resolved Hide resolved
uses: astral-sh/setup-uv@v5
with:
version: ">=0.5.24"

- name: Install dependencies
run: poetry install
run: uv sync --all-extras --frozen

- name: Test
shell: bash
Expand Down
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ARG VERSION=3
FROM python:$VERSION
FROM python:3.13

# Install pip and poetry
RUN python -m pip install --upgrade pip && python -m pip install poetry
WORKDIR /isort
COPY pyproject.toml uv.lock /isort/

# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.5.24 /uv /uvx /bin/

# Setup as minimal a stub project as possible, simply to allow caching base dependencies
# between builds.
Expand All @@ -13,14 +15,11 @@ RUN mkdir -p /isort/tests
RUN touch /isort/isort/__init__.py
RUN touch /isort/tests/__init__.py
RUN touch /isort/README.md
WORKDIR /isort
COPY pyproject.toml poetry.lock /isort/
RUN poetry install
COPY . /isort
RUN SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 uv sync --all-extras --frozen

# Install latest code for actual project
RUN rm -rf /isort
COPY . /isort
RUN poetry install

# Run full test suite
CMD /isort/scripts/test.sh
6 changes: 3 additions & 3 deletions docs/contributing/1.-contributing-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Account Requirements:
Base System Requirements:

- Python3.9+
- poetry
- uv
- bash or a bash compatible shell (should be auto-installed on Linux / Mac)
- WSL users running Ubuntu may need to install Python's venv module even after installing Python.

Expand All @@ -25,8 +25,8 @@ Once you have verified that your system matches the base requirements you can st
2. Clone your fork to your local file system:
`git clone https://github.com/$GITHUB_ACCOUNT/isort.git`
3. `cd isort`
4. `poetry install`
* Optionally, isolate poetry's installation from the rest of your system using the instructions on the poetry site here: https://python-poetry.org/docs/#installation
4. `uv sync --all-extras --frozen`
* Optionally, isolate uv's installation from the rest of your system using the instructions on the uv site here: https://docs.astral.sh/uv/
5. `./scripts/test.sh` should yield Success: no issues found
6. `./scripts/clean.sh` should yield a Safety report checking packages

Expand Down
4 changes: 4 additions & 0 deletions docs/quick_start/1.-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Install `isort` using your preferred Python package manager:

OR

`uv add isort`

OR

`poetry add isort`

OR
Expand Down
Loading
Loading