Skip to content

Commit

Permalink
Update to Poetry 2.0 (#246)
Browse files Browse the repository at this point in the history
* Bump minimum poetry-core version

* Update to Poetry 2.0.1

* Remove redundant Ruff target-version setting

* Add --strict flag to poetry check in CI

* Migrate from poetry install to poetry sync
  • Loading branch information
johnthagen authored Jan 13, 2025
1 parent 35be74f commit b3446a4
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: [main]

env:
POETRY_VERSION: "1.8.4"
POETRY_VERSION: "2.0.1"
PYTHON_VERSION: "3.11"

jobs:
Expand All @@ -23,6 +23,6 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry
- name: Install Nox and doc dependencies
run: poetry install --only nox,docs
run: poetry sync --only nox,docs
- name: Publish Docs
run: poetry run nox -s docs_github_pages
8 changes: 4 additions & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: python
on: [push, pull_request]

env:
POETRY_VERSION: "1.8.4"
POETRY_VERSION: "2.0.1"
PYTHON_VERSION: "3.11"

jobs:
Expand All @@ -23,7 +23,7 @@ jobs:
# https://github.com/actions/setup-python#caching-packages-dependencies
cache: poetry
- name: Install Nox
run: poetry install --only nox
run: poetry sync --only nox
- name: Test with Nox
run: poetry run nox -s test-${{ matrix.python-version }}
quality:
Expand All @@ -45,7 +45,7 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry
- name: Install Nox and group dependencies
run: poetry install --only nox,${{ matrix.job.poetry-groups }}
run: poetry sync --only nox,${{ matrix.job.poetry-groups }}
- name: Test with Nox
run: poetry run nox -s ${{ matrix.job.nox-session }}
poetry-check:
Expand All @@ -59,4 +59,4 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Validate Poetry Configuration and Lockfile Freshness
run: poetry check --lock
run: poetry check --lock --strict
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
FROM python:3.11-slim-bookworm AS python_builder

# Pin Poetry to a specific version to make Docker builds reproducible.
ENV POETRY_VERSION=1.8.4
ENV POETRY_VERSION=2.0.1

# Set ENV variables that make Python more friendly to running inside a container.
ENV PYTHONDONTWRITEBYTECODE=1
Expand Down Expand Up @@ -46,9 +46,7 @@ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
COPY pyproject.toml poetry.lock ./

# Don't install the package itself with Poetry because it will install it as an editable install.
# TODO: Improve this when non-editable `poetry install` is supported in Poetry.
# https://github.com/python-poetry/poetry/issues/1382
RUN poetry install --only main --no-root
RUN poetry sync --only main --no-root

# Copy in source files.
COPY README.md ./
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ all machines that use the project, both during development and in production.

To install all dependencies into an isolated virtual environment:

> [!TIP]
> Append `--sync` to uninstall dependencies that are no longer in use from the virtual environment.
```bash
$ poetry install
$ poetry sync
```

To [activate](https://python-poetry.org/docs/basic-usage#activating-the-virtual-environment) the
Expand Down Expand Up @@ -107,7 +104,7 @@ environments and run commands based on [`noxfile.py`](./noxfile.py) for unit tes
guide checking, type checking and documentation generation.

> [!NOTE]
> `nox` is installed into the virtual environment automatically by the `poetry install` command
> `nox` is installed into the virtual environment automatically by the `poetry sync` command
> above. Run `poetry shell` to activate the virtual environment.
To run all default sessions:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pipx install poetry
Then install the `fact` package and its dependencies:

```bash
poetry install
poetry sync
```

Activate the virtual environment created automatically by Poetry:
Expand Down
Loading

0 comments on commit b3446a4

Please sign in to comment.