Skip to content

Commit 662a521

Browse files
matteiusoz123
authored andcommitted
Vendor in pythonfinder==2.0.5
1 parent 76d40f5 commit 662a521

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

pipenv/vendor/pythonfinder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .models import SystemPath
55
from .pythonfinder import Finder
66

7-
__version__ = "2.0.4"
7+
__version__ = "2.0.5"
88

99

1010
__all__ = ["Finder", "SystemPath", "InvalidPythonVersion"]

pipenv/vendor/pythonfinder/environment.py

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import os
44
import platform
55
import sys
6-
import posixpath
7-
import ntpath
86
import re
97
import shutil
108

@@ -21,28 +19,30 @@ def possibly_convert_to_windows_style_path(path):
2119
if not isinstance(path, str):
2220
path = str(path)
2321
# Check if the path is in Unix-style (Git Bash)
24-
if os.name == 'nt':
25-
if path.startswith('/'):
26-
drive, tail = re.match(r"^/([a-zA-Z])/(.*)", path).groups()
27-
revised_path = drive.upper() + ":\\" + tail.replace('/', '\\')
28-
return revised_path
29-
elif path.startswith('\\'):
30-
drive, tail = re.match(r"^\\([a-zA-Z])\\(.*)", path).groups()
31-
revised_path = drive.upper() + ":\\" + tail.replace('\\', '\\')
32-
return revised_path
33-
22+
if os.name != 'nt':
23+
return path
24+
if os.path.exists(path):
25+
return path
26+
match = re.match(r"[/\\]([a-zA-Z])[/\\](.*)", path)
27+
if match is None:
28+
return path
29+
drive, rest_of_path = match.groups()
30+
rest_of_path = rest_of_path.replace("/", "\\")
31+
revised_path = f"{drive.upper()}:\\{rest_of_path}"
32+
if os.path.exists(revised_path):
33+
return revised_path
3434
return path
3535

3636

3737
PYENV_ROOT = os.path.expanduser(
3838
os.path.expandvars(os.environ.get("PYENV_ROOT", "~/.pyenv"))
3939
)
4040
PYENV_ROOT = possibly_convert_to_windows_style_path(PYENV_ROOT)
41-
PYENV_INSTALLED = shutil.which("pyenv") != None
41+
PYENV_INSTALLED = shutil.which("pyenv") is not None
4242
ASDF_DATA_DIR = os.path.expanduser(
4343
os.path.expandvars(os.environ.get("ASDF_DATA_DIR", "~/.asdf"))
4444
)
45-
ASDF_INSTALLED = shutil.which("asdf") != None
45+
ASDF_INSTALLED = shutil.which("asdf") is not None
4646
IS_64BIT_OS = None
4747
SYSTEM_ARCH = platform.architecture()[0]
4848

@@ -61,20 +61,9 @@ def possibly_convert_to_windows_style_path(path):
6161
"""
6262

6363

64-
def join_path_for_platform(path, path_parts):
65-
# If we're on Unix or Unix-like system
66-
if os.name == 'posix' or sys.platform == 'linux':
67-
return posixpath.join(path, *path_parts)
68-
# If we're on Windows
69-
elif os.name == 'nt' or sys.platform == 'win32':
70-
return ntpath.join(path, *path_parts)
71-
else:
72-
raise Exception("Unknown environment")
73-
74-
7564
def set_asdf_paths():
7665
if ASDF_INSTALLED:
77-
python_versions = join_path_for_platform(ASDF_DATA_DIR, ["installs", "python"])
66+
python_versions = os.path.join(ASDF_DATA_DIR, "installs", "python")
7867
try:
7968
# Get a list of all files and directories in the given path
8069
all_files_and_dirs = os.listdir(python_versions)
@@ -92,10 +81,10 @@ def set_pyenv_paths():
9281
if PYENV_INSTALLED:
9382
is_windows = False
9483
if os.name == "nt":
95-
python_versions = join_path_for_platform(PYENV_ROOT, ["pyenv-win", "versions"])
84+
python_versions = os.path.join(PYENV_ROOT, "pyenv-win", "versions")
9685
is_windows = True
9786
else:
98-
python_versions = join_path_for_platform(PYENV_ROOT, ["versions"])
87+
python_versions = os.path.join(PYENV_ROOT, "versions")
9988
try:
10089
# Get a list of all files and directories in the given path
10190
all_files_and_dirs = os.listdir(python_versions)

pipenv/vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plette==0.4.4
1010
ptyprocess==0.7.0
1111
pydantic==1.10.10
1212
python-dotenv==1.0.0
13-
pythonfinder==2.0.4
13+
pythonfinder==2.0.5
1414
requirementslib==3.0.0
1515
ruamel.yaml==0.17.21
1616
shellingham==1.5.0.post1

0 commit comments

Comments
 (0)