Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tox configuration to pyproject.toml
Tooling around pyproject.toml (and Poetry) is brand new to me, so I'm trying to fit this into my existing workflows and mental models around how Python package development works. The change I'm making here is to incorporate tox for testing without either creating a conflict with Poetry (for dependency/package management) or creating any sort of global Poetry dependency. The challenge is that the primary use case for tox and the primary use case for Poetry are different, and each tool is *very* good at its own primary use case. But they both serve a secondary overlapping use case of automating virtualenv management -- which I don't even want or need. I much prefer to stick with pyenv + pyenv-virtualenv and manage environments on my own explicitly. Both Poetry and tox also want you to install them globally, but I much prefer to keep them limited to their own virtualenvs that I can manage myself without needing to pollute my system Python. So far this setup seems to let me do this. Three things to note about how this works. 1. Instead of using `tool.poetry.dev-dependencies` for pytest, I set pytest as an optional (main) dependency and then set that to the extra group `test`. In the tox config, `extras` references that `test` group, which tells it to include that dependency during the installation. I've done it this way because `extras` is standard while `dev-dependencies` is not. (See: python-poetry/poetry#1941 (comment) 581602064). 2. I've used the legacy tox ini pattern to include the tox ini in `pyproject.toml`. Eventually they will incorporate tox configuration into the .toml format natively, but for now this is the only way to do it, without having a separate `tox.ini` file. See: https://tox.wiki/en/latest/example/basic.html#pyproject-toml-tox- legacy-ini 3. Since this is a package and not a project, the dependencies reflect a range of versions for py 3.7 to 3.10. When tox runs, it sets up two environments per supported Python version -- one with the oldest supported dependency versions, and one with the latest supported dependency versions. The `oldest` groups are the only ones we need to define explicitly, since the default install behavior is to install the latest supported version.
- Loading branch information