diff options
| author | Bernát Gábor <bgabor8@bloomberg.net> | 2020-03-24 22:34:59 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-24 22:34:59 +0000 |
| commit | c0ff71bf8d08da24677839aeb4eba1149f784d49 (patch) | |
| tree | c6eb215ef94e867fca1ec397b06ada8c0245df39 /src | |
| parent | 02c58c134631a2753ef2c7b2128a5ad6059ff882 (diff) | |
| download | virtualenv-c0ff71bf8d08da24677839aeb4eba1149f784d49.tar.gz | |
Fix discovery when name is non-spec format on PATH (#1748)
* Fix discovery when name is non-spec format on PATH
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
* fix windows
Diffstat (limited to 'src')
| -rw-r--r-- | src/virtualenv/discovery/py_info.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/virtualenv/discovery/py_info.py b/src/virtualenv/discovery/py_info.py index 903ad7d..d41c99c 100644 --- a/src/virtualenv/discovery/py_info.py +++ b/src/virtualenv/discovery/py_info.py @@ -235,13 +235,19 @@ class PythonInfo(object): def satisfies(self, spec, impl_must_match): """check if a given specification can be satisfied by the this python interpreter instance""" - if spec.path and self.executable == os.path.abspath(spec.path): - return True # if the path is a our own executable path we're done - - if spec.path is not None: # if path set, and is not our original executable name, this does not match - root, _ = os.path.splitext(os.path.basename(self.original_executable)) - if root != spec.path: - return False + if spec.path: + if self.executable == os.path.abspath(spec.path): + return True # if the path is a our own executable path we're done + if not spec.is_abs: + # if path set, and is not our original executable name, this does not match + basename = os.path.basename(self.original_executable) + spec_path = spec.path + if sys.platform == "win32": + basename, suffix = os.path.splitext(basename) + if spec_path.endswith(suffix): + spec_path = spec_path[: -len(suffix)] + if basename != spec_path: + return False if impl_must_match: if spec.implementation is not None and spec.implementation.lower() != self.implementation.lower(): |
