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

Migrate to Poetry v2 and project-managed Poetry plugins #62

Merged
merged 24 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6fa2da3
Migrate to Poetry v2 and project-managed Poetry plugins
pronovic Jan 6, 2025
263204a
Fix typo
pronovic Jan 6, 2025
928206e
Remove instructions for poetry-dynamic-versioning
pronovic Jan 6, 2025
cf861e8
Switch specifier format to match pydantic
pronovic Jan 6, 2025
741457b
Move pytest configuration into pyproject.toml
pronovic Jan 7, 2025
4b82903
Move coverage configuration into pyproject.toml
pronovic Jan 7, 2025
ef937f2
Move mypy configuration into pyproject.toml
pronovic Jan 7, 2025
eef0bc8
Reorder pyproject.toml to better group related entries
pronovic Jan 7, 2025
f8857f8
Fix comment
pronovic Jan 7, 2025
f60150e
Remove the unused poetryplugin command
pronovic Jan 7, 2025
ef85299
Update comments about plugin
pronovic Jan 7, 2025
3696be8
Reinstall virtualenv at top of docs task
pronovic Jan 7, 2025
1c258c2
Update poetry calls in outdated command to be more explicit
pronovic Jan 7, 2025
e649781
Adjust black configuration
pronovic Jan 8, 2025
720c4cf
Put project-specific mypy overrides at bottom
pronovic Jan 8, 2025
f4ad2f7
Update changelog
pronovic Jan 8, 2025
ebda75b
Standardize TOML formatting
pronovic Jan 8, 2025
16f1458
Standardize TOML formatting
pronovic Jan 8, 2025
5cf3550
Update all dependencies and outdated constraints
pronovic Jan 8, 2025
4f7adf8
Update references to Poetry version
pronovic Jan 8, 2025
0276e99
Update date reference
pronovic Jan 8, 2025
7e7ab7d
Update sphinx-autoapi
pronovic Jan 8, 2025
c58bf67
Fix Exclude Files list for PyCharm
pronovic Jan 8, 2025
90a85ac
Fix Changelog entry for workflow version
pronovic Jan 8, 2025
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
10 changes: 0 additions & 10 deletions .coveragerc

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
jobs:
linux-build-and-test:
name: "Linux"
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-build-and-test.yml@v7
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-build-and-test.yml@v8
secrets: inherit
with:
matrix-os-version: "[ 'ubuntu-latest' ]"
Expand All @@ -25,22 +25,22 @@ jobs:
persist-python-version: "3.10" # persist artifacts for the oldest supported Python version
macos-build-and-test:
name: "MacOS"
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-build-and-test.yml@v7
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-build-and-test.yml@v8
secrets: inherit
with:
matrix-os-version: "[ 'macos-latest' ]"
matrix-python-version: "[ '3.13' ]" # only run MacOS tests on latest Python
windows-build-and-test:
name: "Windows"
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-build-and-test.yml@v7
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-build-and-test.yml@v8
secrets: inherit
with:
matrix-os-version: "[ 'windows-latest' ]"
matrix-python-version: "[ '3.13' ]" # only run Windows tests on latest Python
release:
name: "Release"
if: github.ref_type == 'tag'
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-release.yml@v7
uses: pronovic/gha-shared-workflows/.github/workflows/poetry-release.yml@v8
needs: [ linux-build-and-test, macos-build-and-test, windows-build-and-test ]
secrets: inherit
with:
Expand Down
39 changes: 0 additions & 39 deletions .mypy.ini

This file was deleted.

3 changes: 0 additions & 3 deletions .pytest.ini

This file was deleted.

8 changes: 4 additions & 4 deletions .run/commands/bumpchangelog.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# vim: set ft=bash ts=3 sw=3 expandtab:
# Bump the version in the changelog, preparing for a new development cycle

# If pyproject.toml is configured to use the poetry-dynamic-versioning plugin,
# then you need to have it installed locally, or you will get unexpected results
# from this command. The new version in the Changelog will always be "0.0.1",
# because all Poetry is aware of is the hardcoded version "0.0.0".
# This relies on the poetry-dynamic-versioning plugin, which is assumed to be
# installed as a project plugin. If it's not installed, the new version in the
# Changelog will always be "0.0.1", because all Poetry is aware of is the
# hardcoded version "0.0.0".

command_bumpchangelog() {
mv Changelog Changelog.$$
Expand Down
6 changes: 3 additions & 3 deletions .run/commands/outdated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
command_outdated() {
echo "Updating dependencies with current constraints..."
echo ""
poetry update
poetry update --sync --with=dev
if [ $? != 0 ]; then
echo "*** Failed to update dependencies"
exit 1
Expand All @@ -16,13 +16,13 @@ command_outdated() {
echo "Checking for outdated constraints..."
echo ""

PATTERNS=$(poetry show --tree | grep '^\w' | cut -d' ' -f1 | sed 's/.*/^&\\s/')
PATTERNS=$(poetry show --with=dev --tree | grep '^\w' | cut -d' ' -f1 | sed 's/.*/^&\\s/')
if [ $? != 0 ]; then
echo "*** Failed to run 'poetry show --tree'"
exit 1
fi

OUTDATED=$(poetry show --outdated)
OUTDATED=$(poetry show --with=dev --outdated)
if [ $? != 0 ]; then
echo "*** Failed to run 'poetry show --outdated'"
exit 1
Expand Down
12 changes: 0 additions & 12 deletions .run/commands/poetryplugin.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .run/commands/virtualenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Create and update the virtualenv, synchronizing it to versions in poetry.lock

command_virtualenv() {
poetry install --sync --all-extras
poetry sync --all-extras --all-groups
if [ $? != 0 ]; then
echo "*** Failed to install the virtualenv"
exit 1
Expand Down
1 change: 1 addition & 0 deletions .run/tasks/docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ help_docs() {
}

task_docs() {
run_command virtualenv # work around the fact that Poetry sometimes uninstalls extras
run_command sphinx "$@"
}

7 changes: 7 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.1.57 unreleased

* Migrate to Poetry v2 and project-managed Poetry plugins.
* Move configuration into pyproject.toml for pytest, mypy & coverage.
* Upgrade to gha-shared-workflows@v8 for Poetry v2 support.
* Update all dependencies and outdated constraints.

Version 0.1.56 02 Jan 2025

* Pull in latest version of run-script-framework.
Expand Down
23 changes: 7 additions & 16 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ library for screen drawing.

## Packaging and Dependencies

This project uses [Poetry](https://python-poetry.org/) to manage Python packaging and dependencies. Most day-to-day tasks (such as running unit tests from the command line) are orchestrated through Poetry.
This project uses [Poetry v2](https://python-poetry.org/) to manage Python packaging and dependencies. Most day-to-day tasks (such as running unit tests from the command line) are orchestrated through Poetry.

A coding standard is enforced using [Black](https://pypi.org/project/black/), [isort](https://pypi.org/project/isort/) and [Pylint](https://pypi.org/project/pylint/). Python 3 type hinting is validated using [MyPy](https://pypi.org/project/mypy/). To reduce boilerplate, classes are defined using [Attrs](https://www.attrs.org/) (see this [rationale](https://glyph.twistedmatrix.com/2016/08/attrs.html)).

To add dependencies use `poetry add package` (for runtime dependencies) or `poetry add --group dev package` (for development environment dependencies).

To update dependencies, use `poetry update`. This will update all of the dependencies without taking you past any major version changes that are likely to be incompatible. If you want to update a single package, use `poetry update package`. If you want to update past a major version change, either specify the version like `poetry add package=^2.0.3` or get the latest with `poetry add package@latest`. [PEP 508](https://peps.python.org/pep-0508/) specifications are also supported.

## Vulnerability Scanning

Previously, I used the Safety scanner as part of my pre-commit hooks and GitHub Actions, to identify vulnerabilities in Python dependencies. This functionality was removed in [PR #33](https://github.com/pronovic/apologies/pull/33). Even though Safety is distributed under the liberal [MIT license](notes/safety/license.png), and the PyPI package page [documents that Safety can be used in this manner](notes/safety/usage.png), the PyUp organization behind Safety now claims that this usage is not allowed. (See this [bizarre email thread](notes/safety/email.md) — it has some hallmarks of a phishing email, but appears to be legitimate.) Despite my repeated attempts to clarify what I was doing wrong, PyUp's representative never offered any specifics. Given PyUp's unfriendly behavior, I recommend that you avoid using Safety and rely instead on other tools, such as GitHub's own Dependabot service.
Expand Down Expand Up @@ -97,7 +93,7 @@ sure that you have a working Python 3 enviroment and install Poetry itself.

### Poetry Version

The project is designed to work with Poetry >= 1.8.0. If you already have an older
The project is designed to work with Poetry >= 2.0.0. If you already have an older
version of Poetry installed on your system, upgrade it first.

### MacOS
Expand All @@ -116,14 +112,12 @@ Finally, install Poetry itself and then verify your installation:

```
pipx install poetry
pipx inject poetry poetry-dynamic-versioning
pipx list --include-injected
```

To upgrade this installation later, use:

```
pipx upgrade --include-injected poetry
pipx upgrade poetry
```

### Debian
Expand All @@ -141,14 +135,13 @@ Finally, install Poetry itself and then verify your installation:

```
pipx install poetry
pipx inject poetry poetry-dynamic-versioning
pipx list --include-injected
pipx list
```

To upgrade this installation later, use:

```
pipx upgrade --include-injected poetry
pipx upgrade poetry
```

### Windows
Expand All @@ -167,14 +160,12 @@ Finally, install Poetry itself and then verify your installation:

```
pipx install poetry
pipx inject poetry poetry-dynamic-versioning
pipx list --include-injected
```

To upgrade this installation later, use:

```
pipx upgrade --include-injected poetry
pipx upgrade poetry
```

> _Note:_ The development environment (the `run` script, etc.) expects a bash
Expand Down Expand Up @@ -307,7 +298,7 @@ Go to the PyCharm settings and find the `apologies` project. Under
the **Exclude Files** box, enter the following:

```
LICENSE;NOTICE;PyPI.md;.coverage;.coveragerc;.github;.gitignore;.gitattributes;.htmlcov;.idea;.isort.cfg;.mypy.ini;.mypy_cache;.pre-commit-config.yaml;.pylintrc;.pytest_cache;.pytest.ini;.readthedocs.yml;.tabignore;build;dist;docs/_build;out;poetry.lock;poetry.toml;run;.run;.venv
LICENSE;NOTICE;PyPI.md;build;dist;docs/_build;out;poetry.lock;poetry.toml;run;.coverage;.coverage.lcov;.coveragerc;.gitattributes;.github;.gitignore;.htmlcov;.idea;.mypy_cache;.poetry;.pre-commit-config.yaml;.pylintrc;.pytest_cache;.readthedocs.yml;.run;.tabignore;.venv
```

When you're done, click **Ok**. Then, go to the gear icon in the project panel
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

This is a Python library that implements a game similar to the [Sorry](https://en.wikipedia.org/wiki/Sorry!_(game)) board game. On UNIX-like platforms, it includes a console demo that plays the game with automated players, intended for use by developers and not by end users.

It was written as a learning exercise and technology demonstration effort, and serves as a complete example of how to manage a modern (circa 2020) Python project, including style checks, code formatting, integration with IntelliJ, [CI builds at GitHub](https://github.com/pronovic/apologies/actions), and integration with [PyPI](https://pypi.org/project/apologies/) and [Read the Docs](https://apologies.readthedocs.io/en/stable/).
It was written as a learning exercise and technology demonstration effort, and serves as a complete example of how to manage a modern (circa 2025) Python project, including style checks, code formatting, integration with IntelliJ, [CI builds at GitHub](https://github.com/pronovic/apologies/actions), and integration with [PyPI](https://pypi.org/project/apologies/) and [Read the Docs](https://apologies.readthedocs.io/en/stable/).

Developer documentation is found in [DEVELOPER.md](DEVELOPER.md). See that file for notes about how the code is structured, how to set up a development environment, etc.

Expand Down
Loading
Loading