Skip to content

Commit fdc9eb0

Browse files
authored
Restore limited <major>.<minor> environment name support (#3319)
1 parent 2f7c60e commit fdc9eb0

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

docs/changelog.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ v4.17.0 (2024-08-05)
99

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

@@ -69,7 +69,7 @@ Bugfixes - 4.14.2
6969

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

7474
v4.14.1 (2024-03-06)
7575
--------------------
@@ -216,9 +216,9 @@ v4.7.0 (2023-08-08)
216216

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

docs/changelog/2849.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support for running ``-e <major>.<minor>`` has been lost, fixing it - by :user:`gaborbernat`.

src/tox/tox_env/python/api.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def version_dot(self) -> str:
5656
""",
5757
re.VERBOSE,
5858
)
59+
PY_FACTORS_RE_EXPLICIT_VERSION = re.compile(r"^(?P<version>[2-9]\.[0-9]+)$")
5960

6061

6162
class Python(ToxEnv, ABC):
@@ -142,10 +143,14 @@ def default_base_python(self, conf: Config, env_name: str | None) -> list[str]:
142143
@classmethod
143144
def extract_base_python(cls, env_name: str) -> str | None:
144145
candidates: list[str] = []
145-
for factor in env_name.split("-"):
146-
match = PY_FACTORS_RE.match(factor)
147-
if match:
148-
candidates.append(factor)
146+
match = PY_FACTORS_RE_EXPLICIT_VERSION.match(env_name)
147+
if match:
148+
candidates.append(env_name)
149+
else:
150+
for factor in env_name.split("-"):
151+
match = PY_FACTORS_RE.match(factor)
152+
if match:
153+
candidates.append(factor)
149154
if candidates:
150155
if len(candidates) > 1:
151156
msg = f"conflicting factors {', '.join(candidates)} in {env_name}"

tests/tox_env/python/test_python_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def test_diff_msg_no_diff() -> None:
100100
("5", None),
101101
("2000", None),
102102
("4000", None),
103+
("3.10", "3.10"),
104+
("3.9", "3.9"),
105+
("2.7", "2.7"),
103106
],
104107
ids=lambda a: "|".join(a) if isinstance(a, list) else str(a),
105108
)

0 commit comments

Comments
 (0)