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

Hatch doesn't pick up python version when changed in the config #1319

Open
nikitajz opened this issue Mar 15, 2024 · 2 comments
Open

Hatch doesn't pick up python version when changed in the config #1319

nikitajz opened this issue Mar 15, 2024 · 2 comments

Comments

@nikitajz
Copy link

nikitajz commented Mar 15, 2024

Issue

When tool.hatch.envs.default.python is specified after the first run (was not before) or amended, hatch keeps using the old version of python. In order to actually apply the change, the old environment should be deleted.
It might not be interpreted as a bug per ce, but it's not what is expected intuitively.

How to reproduce

Stage 1: No python version is specified under tool.hatch.*

pyproject.toml:

[project]
requires-python = ">=3.9"
# ...

[tool.hatch.envs.default]
extra-dependencies = [
    "pytest~=7.4.4"
]

Run: hatch run pytest
Hatch installs the latest available python version, for example, python=3.12

❯ hatch run pytest
============================================ test session starts ============================================
platform darwin -- Python 3.12.2, pytest-7.4.4, pluggy-1.4.0
...

Stage 2: Specify python version explicitly

pyproject.toml:

# ...

[tool.hatch.envs.default]
python=3.9

#...

Run: hatch run test
Expected: Hatch rebuild environment using python=3.9
Actual: Hatch keeps using python=3.12

To use python=3.9 you have to remove existing env manually, for example, hatch env prune

@nikitajz nikitajz changed the title Hatch doesn't pick up python version when changed Hatch doesn't pick up python version when changed in the config Mar 15, 2024
@nikitajz
Copy link
Author

nikitajz commented Mar 15, 2024

Seems loosely related #1097 and #1126

@a-reich
Copy link

a-reich commented Jul 27, 2024

+1 to this - it tripped me up because the docs say “dependencies are automatically synced” each time the environment is used, but it didn’t occur to me that this would mean only package dependencies and not python version.

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

2 participants