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

Python versions in matrix are ignored #738

Closed
Bobronium opened this issue Jan 29, 2023 · 4 comments
Closed

Python versions in matrix are ignored #738

Bobronium opened this issue Jan 29, 2023 · 4 comments

Comments

@Bobronium
Copy link
Contributor

Bobronium commented Jan 29, 2023

I'm not completely sure if it doesn't work, or I'm doing something wrong.
It looks like hatch creates only one venv for the matrix and using whatever python version was found first.

Configuring env like that:

[tool.hatch.envs.test]
features = ["testing"]

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.test.scripts]
version = "python --version"

Gives me this

$ hatch run test:version
──────────────────────────────────── test.py3.8 ────────────────────────────────────
Python 3.8.10
──────────────────────────────────── test.py3.9 ────────────────────────────────────
Python 3.8.10
─────────────────────────────────── test.py3.10 ────────────────────────────────────
Python 3.8.10
─────────────────────────────────── test.py3.11 ────────────────────────────────────
Python 3.8.10
$ hatch run +py=3.11 test:version
───────────────────────────────────────────────────────────────────────────────── test.py3.11 ──────────────────────────────────────────────────────────────────────────────────
Python 3.8.10

Expected behaviour:
Each env has its own python executable corresponding to the version specified in the matrix, if such version is not found, env is not created and error is emmited.

@ofek
Copy link
Sponsor Collaborator

ofek commented Jan 29, 2023

Are you using pyenv?

@Bobronium
Copy link
Contributor Author

Yes, I am. Sorry, forgot to include it in the issue:

$ pyenv versions
  system
* 3.8.10 (set by /Users/bobronium/.pyenv/version)
  3.8.13
* 3.9.12 (set by /Users/bobronium/.pyenv/version)
* 3.10.1 (set by /Users/bobronium/.pyenv/version)
* 3.11.0b3 (set by /Users/bobronium/.pyenv/version)
$ pyenv global
3.10.1
3.11.0b3
3.9.12
3.8.10

@icfly2
Copy link

icfly2 commented Feb 10, 2023

When using venv (in WSL) this works as expected:

[tool.hatch.envs.default.scripts]
version = "python --version"
cov = "pytest --cov-report=term --cov-config=pyproject.toml"
no-cov = "cov --no-cov {args}"

[[tool.hatch.envs.test.matrix]]
python = [ "38", "39", "310", "311"]
hatch run test:version
─────────────────────────────────────────────────────────────────────────────────────── test.py38 ────────────────────────────────────────────────────────────────────────────────────────
Python 3.8.10
─────────────────────────────────────────────────────────────────────────────────────── test.py39 ────────────────────────────────────────────────────────────────────────────────────────
Python 3.9.16
─────────────────────────────────────────────────────────────────────────────────────── test.py310 ───────────────────────────────────────────────────────────────────────────────────────
Python 3.10.8
─────────────────────────────────────────────────────────────────────────────────────── test.py311 ───────────────────────────────────────────────────────────────────────────────────────
Python 3.11.1

 hatch run default:version
Python 3.10.8

@ofek
Copy link
Sponsor Collaborator

ofek commented Oct 28, 2023

Fixed by #1002

@ofek ofek closed this as completed Oct 28, 2023
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