Skip to content

Commit

Permalink
Restore limited <major>.<minor> environment name support (#3319)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored Aug 7, 2024
1 parent 2f7c60e commit fdc9eb0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
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

0 comments on commit fdc9eb0

Please sign in to comment.