Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor in pythonfinder==2.0.5 #5812

Merged
merged 2 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pipenv/vendor/pythonfinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .models import SystemPath
from .pythonfinder import Finder

__version__ = "2.0.4"
__version__ = "2.0.5"


__all__ = ["Finder", "SystemPath", "InvalidPythonVersion"]
45 changes: 17 additions & 28 deletions pipenv/vendor/pythonfinder/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import os
import platform
import sys
import posixpath
import ntpath
import re
import shutil

Expand All @@ -21,28 +19,30 @@ 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


PYENV_ROOT = os.path.expanduser(
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]

Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading