Skip to content

Commit

Permalink
Upgrade to Poetry v1.2.0 and other related cleanup (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
pronovic authored Sep 5, 2022
1 parent 4b8629c commit 6d294f4
Show file tree
Hide file tree
Showing 14 changed files with 585 additions and 427 deletions.
55 changes: 46 additions & 9 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.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
9 changes: 1 addition & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ repos:
hooks:
- id: system
name: Requirements
entry: poetry export --format=requirements.txt --without-hashes --dev --output=docs/requirements.txt
pass_filenames: false
language: system
- repo: local
hooks:
- id: system
name: Line Endings
entry: poetry run python utils/dos2unix.py docs/requirements.txt
entry: sh utils/requirements.sh
pass_filenames: false
language: system
- repo: local
Expand Down
12 changes: 1 addition & 11 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,
not-an-iterable, # gets confused with lists on attrs classes; MyPy covers this
Expand Down Expand Up @@ -273,13 +271,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 Expand Up @@ -356,8 +347,7 @@ function-naming-style=snake_case
#function-rgx=

# Good variable names which should always be accepted, separated by a comma.
good-names=d,
e,
good-names=e,
f,
i,
j,
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
9 changes: 9 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 0.5.1 unreleased

* Upgrade to Poetry v1.2.0 and make related build process changes.
* Upgrade to Pylint v2.15.0 and address warnings.
* Fix Pylint's configured class-attribute-naming-style to be snake_case.
* 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.5.0 24 Jun 2022

* Refactor out a SmartAppConfigManager that can be overridden.
Expand Down
57 changes: 41 additions & 16 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,47 @@ in this repository. Instead of relying on automatic behavior, the
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 @@ -65,34 +87,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://install.python-poetry.org | python3 -
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 @@ -109,8 +136,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
- run test: Run the unit tests
Expand Down Expand Up @@ -144,7 +169,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 @@ -358,7 +383,7 @@ Version 0.1.0 unreleased
Run the release step:

```
$ run release 0.1.0
run release 0.1.0
```

This updates `pyproject.toml` and the `Changelog` to reflect the released
Expand All @@ -369,7 +394,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

0 comments on commit 6d294f4

Please sign in to comment.