diff --git a/pipenv/vendor/pythonfinder/__init__.py b/pipenv/vendor/pythonfinder/__init__.py index 9338d917bb..e9edecd9bf 100644 --- a/pipenv/vendor/pythonfinder/__init__.py +++ b/pipenv/vendor/pythonfinder/__init__.py @@ -4,7 +4,7 @@ from .models import SystemPath from .pythonfinder import Finder -__version__ = "2.0.4" +__version__ = "2.0.5" __all__ = ["Finder", "SystemPath", "InvalidPythonVersion"] diff --git a/pipenv/vendor/pythonfinder/environment.py b/pipenv/vendor/pythonfinder/environment.py index eec23fe77a..ad614a79cc 100644 --- a/pipenv/vendor/pythonfinder/environment.py +++ b/pipenv/vendor/pythonfinder/environment.py @@ -3,8 +3,6 @@ import os import platform import sys -import posixpath -import ntpath import re import shutil @@ -21,16 +19,18 @@ def possibly_convert_to_windows_style_path(path): if not isinstance(path, str): path = str(path) # Check if the path is in Unix-style (Git Bash) - if os.name == 'nt': - if path.startswith('/'): - drive, tail = re.match(r"^/([a-zA-Z])/(.*)", path).groups() - revised_path = drive.upper() + ":\\" + tail.replace('/', '\\') - return revised_path - elif path.startswith('\\'): - drive, tail = re.match(r"^\\([a-zA-Z])\\(.*)", path).groups() - revised_path = drive.upper() + ":\\" + tail.replace('\\', '\\') - return revised_path - + if os.name != 'nt': + return path + if os.path.exists(path): + return path + match = re.match(r"[/\\]([a-zA-Z])[/\\](.*)", path) + if match is None: + return path + drive, rest_of_path = match.groups() + rest_of_path = rest_of_path.replace("/", "\\") + revised_path = f"{drive.upper()}:\\{rest_of_path}" + if os.path.exists(revised_path): + return revised_path return path @@ -38,11 +38,11 @@ def possibly_convert_to_windows_style_path(path): os.path.expandvars(os.environ.get("PYENV_ROOT", "~/.pyenv")) ) PYENV_ROOT = possibly_convert_to_windows_style_path(PYENV_ROOT) -PYENV_INSTALLED = shutil.which("pyenv") != None +PYENV_INSTALLED = shutil.which("pyenv") is not None ASDF_DATA_DIR = os.path.expanduser( os.path.expandvars(os.environ.get("ASDF_DATA_DIR", "~/.asdf")) ) -ASDF_INSTALLED = shutil.which("asdf") != None +ASDF_INSTALLED = shutil.which("asdf") is not None IS_64BIT_OS = None SYSTEM_ARCH = platform.architecture()[0] @@ -61,20 +61,9 @@ def possibly_convert_to_windows_style_path(path): """ -def join_path_for_platform(path, path_parts): - # If we're on Unix or Unix-like system - if os.name == 'posix' or sys.platform == 'linux': - return posixpath.join(path, *path_parts) - # If we're on Windows - elif os.name == 'nt' or sys.platform == 'win32': - return ntpath.join(path, *path_parts) - else: - raise Exception("Unknown environment") - - def set_asdf_paths(): if ASDF_INSTALLED: - python_versions = join_path_for_platform(ASDF_DATA_DIR, ["installs", "python"]) + python_versions = os.path.join(ASDF_DATA_DIR, "installs", "python") try: # Get a list of all files and directories in the given path all_files_and_dirs = os.listdir(python_versions) @@ -92,10 +81,10 @@ def set_pyenv_paths(): if PYENV_INSTALLED: is_windows = False if os.name == "nt": - python_versions = join_path_for_platform(PYENV_ROOT, ["pyenv-win", "versions"]) + python_versions = os.path.join(PYENV_ROOT, "pyenv-win", "versions") is_windows = True else: - python_versions = join_path_for_platform(PYENV_ROOT, ["versions"]) + python_versions = os.path.join(PYENV_ROOT, "versions") try: # Get a list of all files and directories in the given path all_files_and_dirs = os.listdir(python_versions) diff --git a/pipenv/vendor/vendor.txt b/pipenv/vendor/vendor.txt index 5e12e8bb1d..c9a14ae0bc 100644 --- a/pipenv/vendor/vendor.txt +++ b/pipenv/vendor/vendor.txt @@ -10,7 +10,7 @@ plette==0.4.4 ptyprocess==0.7.0 pydantic==1.10.10 python-dotenv==1.0.0 -pythonfinder==2.0.4 +pythonfinder==2.0.5 requirementslib==3.0.0 ruamel.yaml==0.17.21 shellingham==1.5.0.post1