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

Use tox so we can test multiple python versions locally #128

Open
msto opened this issue Jun 6, 2024 · 3 comments
Open

Use tox so we can test multiple python versions locally #128

msto opened this issue Jun 6, 2024 · 3 comments

Comments

@msto
Copy link
Contributor

msto commented Jun 6, 2024

GHA does this, but it'd be more convenient if tests and checks could be run without pushing and the overhead of GHA

@nh13
Copy link
Member

nh13 commented Jun 6, 2024

The advantage of using GHA to do this is we get multiple concurrent jobs. I don't think that would be the case with tox.

@clintval
Copy link
Member

clintval commented Jun 6, 2024

@nh13 tox works well for this and will run multiple GHA jobs as expected:

Here's an example from a personal OSS project:

Screenshot 2024-06-06 at 9 30 27 AM

And the associated pyproject.toml config:

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py312,py311,py310,py39,py38

[gh-actions]
python =
    3.12: py312
    3.11: py311
    3.10: py310
    3.9: py39
    3.8: py38

[testenv]
allowlist_externals = poetry
commands =
  poetry install -v
  poetry run pytest toolkit/ tests/
"""

Tox has a feature request to update their config syntax to proper TOML (instead of ini-style) but at least it's all in the pyproject.toml and not in another dotfile.

@clintval
Copy link
Member

clintval commented Jun 6, 2024

What I do locally is use pyenv, a very simple Python version management tool, to install all versions of Python on my local. I think of this as the environment layer between the system Python (which you should not touch) and deeper environments like venvs and conda environments. Of course, depending on your personal preferences, you can get multiple Python versions installed in other ways.

Once I have those Pythons, then I have the option of running poetry run pytest to run the whole test suite with whatever Python version poetry finds as default, or if I have tox installed, simply running tox and then I get parallel testing over all versions of Python. This emulates GHA quite well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants