Skip to content

Commit

Permalink
Prepare for Python 3.9 (not compatible yet) (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
pronovic authored Oct 17, 2020
1 parent 64020c6 commit a7c08f9
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 44 additions & 3 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ $ brew install python3
$ brew install poetry
```

When you're done, make sure that the `python` on your `$PATH` is Python 3 from
Homebrew (in `/usr/local`). By default, you'll get the standard Python 2 that
comes with MacOS.
When you're done, you probably want to set up your profile so the `python` on
your `$PATH` is Python 3 from Homebrew (in `/usr/local`). By default, you'll
get the standard Python 2 that comes with MacOS.

### Debian

Expand All @@ -88,6 +88,46 @@ Then, install Poetry in your home directory:
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
```

## Configure Poetry's Python Interpreter

At this point, you can either let Poetry use its defaults, or tell it explicity
which Python interpreter you want it to use. On MacOS anyway, Poetry >= v1.1.3
seems to be quite aggressive about using the most recent version of Python
available on my system (even if it's not on my `$PATH`), which is not always
what I want.

To force Poetry to use a particular version of Python on the `$PATH`, do this:

```
$ poetry env use 3.8
```

To force Poetry to use a version that isn't on the `$PATH`, you can't just use
the version number as shown above. You have to provide the whole path:

```
$ poetry env use /usr/local/Cellar/[email protected]/3.9.0/bin/python3.9
```

You can check the version that is in use with:

```
$ poetry env info
```

If you switch between versions, it is a good idea to sanity check what is
actually being used. I've noticed that if I start on 3.8 and then switch to
3.9 (in the order shown above), then `python env info` still reports Python
3.8.6 when I'm done. The fix seems to be to remove the virutalenvs and start
over:

```
$ poetry env list
$ poetry env remove <item>
```

For more background, see [this discussion](https://github.com/python-poetry/poetry/issues/522) and also [Poetry PR #731](https://github.com/python-poetry/poetry/pull/731).

## Activating the Virtual Environment

Poetry manages the virtual environment used for testing. Theoretically, the
Expand All @@ -113,6 +153,7 @@ 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 checks: Run the PyLint and MyPy code checkers
- run format: Run the Black code formatter
- run test: Run the unit tests
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers=[
]

[tool.poetry.dependencies]
python = "^3.7"
python = ">=3.7,<=3.9"
attrs = "^19.3.0"
cattrs = "^1.0.0"
pendulum = "^2.1.0"
Expand Down

0 comments on commit a7c08f9

Please sign in to comment.