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

Upgrade to Poetry v1.2.0 and other related cleanup #19

Merged
merged 7 commits into from
Sep 5, 2022
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
57 changes: 47 additions & 10 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# vim: set ft=yaml ts=2 sw=2:
name: Test Suite
on:
push:
Expand All @@ -10,44 +11,80 @@ on:
- cron: '05 17 15 * *' # 15th of the month at 5:05pm UTC
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [ "3.7", "3.8", "3.9", "3.10" ]
python: ["3.7", "3.8", "3.9", "3.10" ]
runs-on: ${{ matrix.os }}
env:
# Run builds using a specific version of Poetry, to avoid surprises
POETRY_VERSION: "1.2.0"
# Prevent Poetry v1.2.0 from using the Python keyring, which sometimes fails or hangs on Linux
# See: https://github.com/python-poetry/poetry/issues/2692#issuecomment-1235683370
PYTHON_KEYRING_BACKEND: "keyring.backends.null.Keyring"
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install and configure Poetry
- name: Platform information
shell: bash
run: |
# Show platform information
python -c "import sys;print('Python %s' % sys.version)"
- name: Install Poetry
uses: snok/install-poetry@v1.2.1 # see https://github.com/snok/install-poetry
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install Poetry plugins
shell: bash
run: |
# Install Poetry plugins
poetry self add poetry-plugin-export
- name: Cache Poetry dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install -v
shell: bash
run: |
# Install dependencies
poetry install --sync
- name: Upgrade embedded tools within virtualenv
run: poetry run pip install --upgrade pip setuptools wheel
shell: bash
run: |
# Upgrade embedded tools
poetry run pip install --upgrade pip setuptools wheel
- name: Run Tox test suite
run: poetry run tox -c .toxrc -e "checks,coverage"
shell: bash
run: |
# Run Tox test suite
poetry run tox -c .toxrc -e "checks,coverage"
- name: Upload coverage data to coveralls.io
run: poetry run coveralls --service=github
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ runner.os }}-python${{ matrix.python }}
COVERALLS_PARALLEL: true
run: |
# Upload coverage data to coveralls.io
poetry run coveralls --service=github
coveralls:
name: Indicate completion to coveralls.io
needs: build
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --service=github --finish
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Indicate completion to coveralls.io
pip3 install --upgrade coveralls
coveralls --service=github --finish
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: system
name: Requirements
entry: poetry export --format=requirements.txt --without-hashes --dev --output=docs/requirements.txt
entry: poetry export --format=requirements.txt --without-hashes --with dev --output=docs/requirements.txt
pass_filenames: false
language: system
- repo: local
Expand Down
9 changes: 0 additions & 9 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ disable=fixme,
missing-function-docstring,
unused-wildcard-import,
trailing-whitespace,
bad-continuation,
too-few-public-methods,
no-else-return,
no-else-raise,
no-self-use,
duplicate-code,
consider-using-f-string

Expand Down Expand Up @@ -268,13 +266,6 @@ max-line-length=132
# Maximum number of lines in a module.
max-module-lines=1000

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
Expand Down
6 changes: 3 additions & 3 deletions .toxrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ envlist =
ignore_basepython_conflict = true

[testenv:checks]
whitelist_externals = poetry
allowlist_externals = poetry
commands =
poetry --version
poetry version
poetry run pre-commit run --all-files --show-diff-on-failure

[testenv:coverage]
whitelist_externals = poetry
allowlist_externals = poetry
commands =
poetry --version
poetry version
Expand All @@ -23,7 +23,7 @@ commands =
poetry run coverage report

[testenv:docs]
whitelist_externals = poetry
allowlist_externals = poetry
changedir = docs
commands =
poetry --version
Expand Down
10 changes: 10 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 0.1.15 unreleased

* Upgrade to Poetry v1.2.0 and make related build process changes.
* Upgrade to Pylint 2.15.0 and address warnings.
* Fix Pylint's configured class-attribute-naming-style to be snake_case.
* Adjust Black configuration to target Python 3.7, 3.8, 3.9, and 3.10.
* Add dependency caching to GitHub Actions workflow.
* Fix the GitHub Actions matrix build to properly target Windows and MacOS.
* Update various dependencies for the developer environment.

Version 0.1.14 30 Apr 2022

* Adjust the pyproject.toml include directive to limit what goes into wheel.
Expand Down
58 changes: 42 additions & 16 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This code should work equivalently on MacOS, Linux, and Windows.

## 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](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://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/).

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

### Poetry Version

The project is designed to work with Poetry >= 1.2.0. If you already have an older
version of Poetry installed on your system, uninstall it before following the setup
process below:

```
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 - --uninstall
```

See the [Announcing Poetry 1.2.0](https://python-poetry.org/blog/announcing-poetry-1.2.0/)
blog post for more information.

### MacOS

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

```
$ brew install python3
$ brew install poetry
brew install python3
```

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

Although Poetry can also be installed from Homebrew, it works better to use
to [official installer](https://python-poetry.org/docs/#installing-with-the-official-installer):

```
curl -sSL https://install.python-poetry.org | python3 -
```

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

First, install Python 3 and related tools:

```
$ sudo apt-get install python3 python3-venv python3-pip
sudo apt-get install python3 python3-venv python3-pip
```

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

```
$ sudo apt-get install python-is-python3
sudo apt-get install python-is-python3
```

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

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

```
$ curl -sSL https://install.python-poetry.org | python3 -
curl -sSL https://install.python-poetry.org | python3 -
```

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

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

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

```
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
curl -sSL https://install.python-poetry.org | python -
```

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

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

```
$ run install && run checks && run test
run install && run checks && run test
```

### Open the Project
Expand Down Expand Up @@ -370,7 +396,7 @@ Version 0.1.29 unreleased
Run the release step:

```
$ run release 0.1.29
run release 0.1.29
```

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

```
$ run publish
run publish
```

This builds the deployment artifacts, publishes the artifacts to PyPI, and
Expand Down
Loading