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 1.2.0 #39

Merged
merged 16 commits into from
Sep 2, 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
26 changes: 18 additions & 8 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,49 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.7", "3.8", "3.9", "3.10" ]
env:
# 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: Install Poetry
uses: snok/install-poetry@v1.2.1 # see https://github.com/snok/install-poetry
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install Poetry plugins
run: |
poetry self add poetry-plugin-export
- name: Install dependencies
run: poetry install -v
run: |
poetry install --sync
- name: Upgrade embedded tools within virtualenv
run: poetry run pip install --upgrade pip setuptools wheel
run: |
poetry run pip install --upgrade pip setuptools wheel
- name: Run Tox test suite
run: poetry run tox -c .toxrc -e "checks,coverage"
run: |
poetry run tox -c .toxrc -e "checks,coverage"
- name: Upload coverage data to coveralls.io
run: poetry run coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ runner.os }}-python${{ matrix.python }}
COVERALLS_PARALLEL: true
run: |
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
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
79 changes: 58 additions & 21 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ 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](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/). 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 --dev package` (for development environment dependencies).
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`.
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

Expand Down Expand Up @@ -124,25 +124,47 @@ things for users as much as I had hoped.
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 @@ -153,34 +175,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 @@ -197,7 +224,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 All @@ -213,6 +239,17 @@ Usage: run <command>
- run sim: Run a simulation to see how well different character input sources behave
```

## Running the Simulation

This runs a simulation on the standard `RewardV1InputSource`:

```
run sim apologies.source.RewardV1InputSource
```

Output is written to `simulation.csv`. You can specify any source in
the [`apologies.source`](src/apologies/source.py) module.

## Running the Demo

While this is primarily a library, it includes a quick'n'dirty console demo
Expand Down Expand Up @@ -242,13 +279,13 @@ that chooses a player's move.
It's simplest to run a demo with the default arguments:

```
$ run demo
run demo
```

This runs a really fast game in adult mode with 3 players:

```
$ run demo --players=3 --mode=ADULT --delay=0.1
run demo --players=3 --mode=ADULT --delay=0.1
```

> _Note:_ The demo only works inside a UNIX-style terminal window (like an
Expand Down Expand Up @@ -277,7 +314,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 @@ -491,7 +528,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 @@ -502,7 +539,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 Expand Up @@ -564,4 +601,4 @@ Deleting password for 'user' in 'testvalue':
At this point, the keyring should be fully functional and it should be ready
for use with Poetry. Whenever Poetry needs to read a secret from the keyring,
you'll get a popup window where you need to enter the keyring password.

Loading