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

Restore limited <major>.<minor> environment name support #3319

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ v4.17.0 (2024-08-05)

Features - 4.17.0
~~~~~~~~~~~~~~~~~
- Add "graalpy" prefix as a supported base python (:issue:`3312`)
- Add ``graalpy`` prefix as a supported base python (:issue:`3312`)
- Add :ref:`on_platform` core configuration holding the tox platform and do not install package when exec an environment
- by :user:`gaborbernat`. (:issue:`3315`)

Expand Down Expand Up @@ -69,7 +69,7 @@ Bugfixes - 4.14.2

Improved Documentation - 4.14.2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Removed unused line from the 'fresh_subprocess' documentation. (:issue:`3241`)
- Removed unused line from the ``fresh_subprocess`` documentation. (:issue:`3241`)

v4.14.1 (2024-03-06)
--------------------
Expand Down Expand Up @@ -216,9 +216,9 @@ v4.7.0 (2023-08-08)

Features - 4.7.0
~~~~~~~~~~~~~~~~
- Make --hashseed default to PYTHONHASHSEED, if defined - by :user:`paravoid`.
- Make ``--hashseed`` default to ``PYTHONHASHSEED``, if defined - by :user:`paravoid`.
The main motivation for this is to able to set the hash seed when building the
documentation with "tox -e docs", and thus avoid embedding a random value in
documentation with ``tox -e docs``, and thus avoid embedding a random value in
the tox documentation for --help. This caused documentation builds to fail to
build reproducibly. (:issue:`2942`)

Expand Down
1 change: 1 addition & 0 deletions docs/changelog/2849.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support for running ``-e <major>.<minor>`` has been lost, fixing it - by :user:`gaborbernat`.
13 changes: 9 additions & 4 deletions src/tox/tox_env/python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def version_dot(self) -> str:
""",
re.VERBOSE,
)
PY_FACTORS_RE_EXPLICIT_VERSION = re.compile(r"^(?P<version>[2-9]\.[0-9]+)$")


class Python(ToxEnv, ABC):
Expand Down Expand Up @@ -142,10 +143,14 @@ def default_base_python(self, conf: Config, env_name: str | None) -> list[str]:
@classmethod
def extract_base_python(cls, env_name: str) -> str | None:
candidates: list[str] = []
for factor in env_name.split("-"):
match = PY_FACTORS_RE.match(factor)
if match:
candidates.append(factor)
match = PY_FACTORS_RE_EXPLICIT_VERSION.match(env_name)
if match:
candidates.append(env_name)
else:
for factor in env_name.split("-"):
match = PY_FACTORS_RE.match(factor)
if match:
candidates.append(factor)
if candidates:
if len(candidates) > 1:
msg = f"conflicting factors {', '.join(candidates)} in {env_name}"
Expand Down
3 changes: 3 additions & 0 deletions tests/tox_env/python/test_python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def test_diff_msg_no_diff() -> None:
("5", None),
("2000", None),
("4000", None),
("3.10", "3.10"),
("3.9", "3.9"),
("2.7", "2.7"),
],
ids=lambda a: "|".join(a) if isinstance(a, list) else str(a),
)
Expand Down
Loading