Skip to content

Commit

Permalink
Discover python interpreter in a case insensitive manner (#1629)
Browse files Browse the repository at this point in the history
Closes #1624
  • Loading branch information
PrajwalM2212 authored Feb 15, 2020
1 parent c14c5b6 commit 39b2ed7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1624.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Discover python interpreter in a case insensitive manner - by :user:`PrajwalM2212`
2 changes: 1 addition & 1 deletion src/virtualenv/discovery/py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def satisfies(self, spec, impl_must_match):
return False

if impl_must_match:
if spec.implementation is not None and spec.implementation != self.implementation:
if spec.implementation is not None and spec.implementation.lower() != self.implementation.lower():
return False

if spec.architecture is not None and spec.architecture != self.architecture:
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/discovery/py_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def satisfies(self, spec):
"""called when there's a candidate metadata spec to see if compatible - e.g. PEP-514 on Windows"""
if spec.is_abs and self.is_abs and self.path != spec.path:
return False
if spec.implementation is not None and spec.implementation != self.implementation:
if spec.implementation is not None and spec.implementation.lower() != self.implementation.lower():
return False
if spec.architecture is not None and spec.architecture != self.architecture:
return False
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/discovery/py_info/test_py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ def test_bad_exe_py_info_no_raise(tmp_path, caplog, capsys):
list(
"{}{}{}".format(impl, ".".join(str(i) for i in ver), arch)
for impl, ver, arch in itertools.product(
([CURRENT.implementation] + (["python"] if CURRENT.implementation == "CPython" else [])),
(
[CURRENT.implementation]
+ (["python"] if CURRENT.implementation == "CPython" else [])
+ (
[CURRENT.implementation.lower()]
if CURRENT.implementation != CURRENT.implementation.lower()
else []
)
),
[sys.version_info[0 : i + 1] for i in range(3)],
["", "-{}".format(CURRENT.architecture)],
)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/discovery/test_py_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def test_spec_satisfies_arch():


@pytest.mark.parametrize(
"req, spec", list(itertools.combinations(["py", "CPython", "python"], 2)) + [("jython", "jython")]
"req, spec",
list(itertools.combinations(["py", "CPython", "python"], 2)) + [("jython", "jython")] + [("CPython", "cpython")],
)
def test_spec_satisfies_implementation_ok(req, spec):
spec_1 = PythonSpec.from_string_spec(req)
Expand Down

0 comments on commit 39b2ed7

Please sign in to comment.