Skip to content

Commit f25a89c

Browse files
authored
Upgrade to Poetry v1.2.0 and other related cleanup (#19)
1 parent 54de983 commit f25a89c

10 files changed

+575
-427
lines changed

.github/workflows/tox.yml

+47-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# vim: set ft=yaml ts=2 sw=2:
12
name: Test Suite
23
on:
34
push:
@@ -10,44 +11,80 @@ on:
1011
- cron: '05 17 15 * *' # 15th of the month at 5:05pm UTC
1112
jobs:
1213
build:
13-
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, macos-latest, windows-latest]
17-
python: [ "3.7", "3.8", "3.9", "3.10" ]
17+
python: ["3.7", "3.8", "3.9", "3.10" ]
18+
runs-on: ${{ matrix.os }}
19+
env:
20+
# Run builds using a specific version of Poetry, to avoid surprises
21+
POETRY_VERSION: "1.2.0"
22+
# Prevent Poetry v1.2.0 from using the Python keyring, which sometimes fails or hangs on Linux
23+
# See: https://github.com/python-poetry/poetry/issues/2692#issuecomment-1235683370
24+
PYTHON_KEYRING_BACKEND: "keyring.backends.null.Keyring"
1825
steps:
1926
- name: Check out code
2027
uses: actions/checkout@v2
2128
- name: Setup Python
2229
uses: actions/setup-python@v2
2330
with:
2431
python-version: ${{ matrix.python }}
25-
- name: Install and configure Poetry
32+
- name: Platform information
33+
shell: bash
34+
run: |
35+
# Show platform information
36+
python -c "import sys;print('Python %s' % sys.version)"
37+
- name: Install Poetry
2638
uses: snok/install-poetry@v1.2.1 # see https://github.com/snok/install-poetry
2739
with:
40+
version: ${{ env.POETRY_VERSION }}
2841
virtualenvs-create: true
2942
virtualenvs-in-project: true
43+
- name: Install Poetry plugins
44+
shell: bash
45+
run: |
46+
# Install Poetry plugins
47+
poetry self add poetry-plugin-export
48+
- name: Cache Poetry dependencies
49+
uses: actions/cache@v2
50+
with:
51+
path: .venv
52+
key: venv-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
3053
- name: Install dependencies
31-
run: poetry install -v
54+
shell: bash
55+
run: |
56+
# Install dependencies
57+
poetry install --sync
3258
- name: Upgrade embedded tools within virtualenv
33-
run: poetry run pip install --upgrade pip setuptools wheel
59+
shell: bash
60+
run: |
61+
# Upgrade embedded tools
62+
poetry run pip install --upgrade pip setuptools wheel
3463
- name: Run Tox test suite
35-
run: poetry run tox -c .toxrc -e "checks,coverage"
64+
shell: bash
65+
run: |
66+
# Run Tox test suite
67+
poetry run tox -c .toxrc -e "checks,coverage"
3668
- name: Upload coverage data to coveralls.io
37-
run: poetry run coveralls --service=github
69+
shell: bash
3870
env:
3971
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4072
COVERALLS_FLAG_NAME: ${{ runner.os }}-python${{ matrix.python }}
4173
COVERALLS_PARALLEL: true
74+
run: |
75+
# Upload coverage data to coveralls.io
76+
poetry run coveralls --service=github
4277
coveralls:
4378
name: Indicate completion to coveralls.io
4479
needs: build
4580
runs-on: ubuntu-latest
4681
container: python:3-slim
4782
steps:
4883
- name: Finished
49-
run: |
50-
pip3 install --upgrade coveralls
51-
coveralls --service=github --finish
84+
shell: bash
5285
env:
5386
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
run: |
88+
# Indicate completion to coveralls.io
89+
pip3 install --upgrade coveralls
90+
coveralls --service=github --finish

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: system
66
name: Requirements
7-
entry: poetry export --format=requirements.txt --without-hashes --dev --output=docs/requirements.txt
7+
entry: poetry export --format=requirements.txt --without-hashes --with dev --output=docs/requirements.txt
88
pass_filenames: false
99
language: system
1010
- repo: local

.pylintrc

-9
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ disable=fixme,
7070
missing-function-docstring,
7171
unused-wildcard-import,
7272
trailing-whitespace,
73-
bad-continuation,
7473
too-few-public-methods,
7574
no-else-return,
7675
no-else-raise,
77-
no-self-use,
7876
duplicate-code,
7977
consider-using-f-string
8078

@@ -268,13 +266,6 @@ max-line-length=132
268266
# Maximum number of lines in a module.
269267
max-module-lines=1000
270268

271-
# List of optional constructs for which whitespace checking is disabled. `dict-
272-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
273-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
274-
# `empty-line` allows space-only lines.
275-
no-space-check=trailing-comma,
276-
dict-separator
277-
278269
# Allow the body of a class to be on the same line as the declaration if body
279270
# contains single statement.
280271
single-line-class-stmt=no

.toxrc

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ envlist =
77
ignore_basepython_conflict = true
88

99
[testenv:checks]
10-
whitelist_externals = poetry
10+
allowlist_externals = poetry
1111
commands =
1212
poetry --version
1313
poetry version
1414
poetry run pre-commit run --all-files --show-diff-on-failure
1515

1616
[testenv:coverage]
17-
whitelist_externals = poetry
17+
allowlist_externals = poetry
1818
commands =
1919
poetry --version
2020
poetry version
@@ -23,7 +23,7 @@ commands =
2323
poetry run coverage report
2424

2525
[testenv:docs]
26-
whitelist_externals = poetry
26+
allowlist_externals = poetry
2727
changedir = docs
2828
commands =
2929
poetry --version

Changelog

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 0.1.15 unreleased
2+
3+
* Upgrade to Poetry v1.2.0 and make related build process changes.
4+
* Upgrade to Pylint 2.15.0 and address warnings.
5+
* Fix Pylint's configured class-attribute-naming-style to be snake_case.
6+
* Adjust Black configuration to target Python 3.7, 3.8, 3.9, and 3.10.
7+
* Add dependency caching to GitHub Actions workflow.
8+
* Fix the GitHub Actions matrix build to properly target Windows and MacOS.
9+
* Update various dependencies for the developer environment.
10+
111
Version 0.1.14 30 Apr 2022
212

313
* Adjust the pyproject.toml include directive to limit what goes into wheel.

DEVELOPER.md

+42-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This code should work equivalently on MacOS, Linux, and Windows.
66

77
## Packaging and Dependencies
88

9-
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.
9+
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.
1010

1111
A coding standard is enforced using [Black](https://github.com/psf/black), [isort](https://pypi.org/project/isort/) and [Pylint](https://www.pylint.org/). Python 3 type hinting is validated using [MyPy](https://pypi.org/project/mypy/).
1212

@@ -48,25 +48,47 @@ of this writing.
4848
Nearly all prerequisites are managed by Poetry. All you need to do is make
4949
sure that you have a working Python 3 enviroment and install Poetry itself.
5050

51+
### Poetry Version
52+
53+
The project is designed to work with Poetry >= 1.2.0. If you already have an older
54+
version of Poetry installed on your system, uninstall it before following the setup
55+
process below:
56+
57+
```
58+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 - --uninstall
59+
```
60+
61+
See the [Announcing Poetry 1.2.0](https://python-poetry.org/blog/announcing-poetry-1.2.0/)
62+
blog post for more information.
63+
5164
### MacOS
5265

53-
On MacOS, it's easiest to use [Homebrew](https://brew.sh/):
66+
On MacOS, it's easiest to use [Homebrew](https://brew.sh/) to install Python:
5467

5568
```
56-
$ brew install python3
57-
$ brew install poetry
69+
brew install python3
5870
```
5971

6072
Once that's done, make sure the `python` on your `$PATH` is Python 3 from
6173
Homebrew (in `/usr/local`), rather than the standard Python 2 that comes with
6274
MacOS.
6375

76+
Although Poetry can also be installed from Homebrew, it works better to use
77+
to [official installer](https://python-poetry.org/docs/#installing-with-the-official-installer):
78+
79+
```
80+
curl -sSL https://install.python-poetry.org | python3 -
81+
```
82+
83+
> _Note:_ The installer prints the location of the installed `poetry` script.
84+
> Make sure to add this to your `$PATH`, otherwise you won't be able to run it.
85+
6486
### Debian
6587

6688
First, install Python 3 and related tools:
6789

6890
```
69-
$ sudo apt-get install python3 python3-venv python3-pip
91+
sudo apt-get install python3 python3-venv python3-pip
7092
```
7193

7294
Next, make sure that the `python` interpreter on your `$PATH` is Python 3.
@@ -77,34 +99,39 @@ However, by default there is only a `python3` interpreter on your `$PATH`, not
7799
a `python` interpreter. To add the `python` interpreter, use:
78100

79101
```
80-
$ sudo apt-get install python-is-python3
102+
sudo apt-get install python-is-python3
81103
```
82104

83105
For earlier releases of Debian where both Python 2 and Python 3 are available,
84106
the process is a little more complicated. The approach I used before upgrading
85107
to _bullseye_ was based on `update-alternatives`, as discussed on
86108
[StackExchange](https://unix.stackexchange.com/a/410851).
87109

88-
Once Python 3 is on your `$PATH` as `python`, install Poetry in your home
89-
directory:
110+
Next, install Poetry using the [official installer](https://python-poetry.org/docs/#installing-with-the-official-installer):
90111

91112
```
92-
$ curl -sSL https://install.python-poetry.org | python3 -
113+
curl -sSL https://install.python-poetry.org | python3 -
93114
```
94115

116+
> _Note:_ The installer prints the location of the installed `poetry` script.
117+
> Make sure to add this to your `$PATH`, otherwise you won't be able to run it.
118+
95119
### Windows
96120

97121
First, install Python 3 from your preferred source, either a standard
98122
installer or a meta-installer like Chocolatey. Make sure the `python`
99123
on your `$PATH` is Python 3.
100124

101-
Then, install Poetry in your home directory:
125+
Next, install Poetry using the [official installer](https://python-poetry.org/docs/#installing-with-the-official-installer):
102126

103127
```
104-
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
128+
curl -sSL https://install.python-poetry.org | python -
105129
```
106130

107-
The development environment (with the `run` script, etc.) expects a bash shell
131+
> _Note:_ The installer prints the location of the installed `poetry` script.
132+
> Make sure to add this to your `$PATH`, otherwise you won't be able to run it.
133+
134+
The development environment (the `run` script, etc.) expects a bash shell
108135
to be available. On Windows, it works fine with the standard Git Bash.
109136

110137
## Developer Tasks
@@ -121,7 +148,6 @@ Shortcuts for common developer tasks
121148
Usage: run <command>
122149
123150
- run install: Setup the virtualenv via Poetry and install pre-commit hooks
124-
- run activate: Print command needed to activate the Poetry virtualenv
125151
- run requirements: Regenerate the docs/requirements.txt file
126152
- run format: Run the code formatters
127153
- run checks: Run the code checkers
@@ -156,7 +182,7 @@ order. In particular, if you do not run the install step, there will be no
156182
virtualenv for PyCharm to use:
157183

158184
```
159-
$ run install && run checks && run test
185+
run install && run checks && run test
160186
```
161187

162188
### Open the Project
@@ -370,7 +396,7 @@ Version 0.1.29 unreleased
370396
Run the release step:
371397

372398
```
373-
$ run release 0.1.29
399+
run release 0.1.29
374400
```
375401

376402
This updates `pyproject.toml` and the `Changelog` to reflect the released
@@ -381,7 +407,7 @@ and revert your commit (`git reset HEAD~1`) if you made a mistake.
381407
Finally, publish the release:
382408

383409
```
384-
$ run publish
410+
run publish
385411
```
386412

387413
This builds the deployment artifacts, publishes the artifacts to PyPI, and

0 commit comments

Comments
 (0)