Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._internal.utils.compat Namespace Reference

Functions

bool has_tls ()
 
int get_path_uid (str path)
 

Variables

 logger = logging.getLogger(__name__)
 
dict stdlib_pkgs = {"python", "wsgiref", "argparse"}
 
 WINDOWS = sys.platform.startswith("win") or (sys.platform == "cli" and os.name == "nt")
 

Detailed Description

Stuff that differs in different Python versions and platform
distributions.

Function Documentation

◆ get_path_uid()

int get_path_uid ( str  path)
Return path's uid.

Does not follow symlinks:
    https://github.com/pypa/pip/pull/935#discussion_r5307003

Placed this function in compat due to differences on AIX and
Jython, that should eventually go away.

:raises OSError: When path is a symlink or can't be read.

Definition at line 27 of file compat.py.

27def get_path_uid(path: str) -> int:
28 """
29 Return path's uid.
30
31 Does not follow symlinks:
32 https://github.com/pypa/pip/pull/935#discussion_r5307003
33
34 Placed this function in compat due to differences on AIX and
35 Jython, that should eventually go away.
36
37 :raises OSError: When path is a symlink or can't be read.
38 """
39 if hasattr(os, "O_NOFOLLOW"):
41 file_uid = os.fstat(fd).st_uid
42 os.close(fd)
43 else: # AIX and Jython
44 # WARNING: time of check vulnerability, but best we can do w/o NOFOLLOW
45 if not os.path.islink(path):
46 # older versions of Jython don't have `os.fstat`
47 file_uid = os.stat(path).st_uid
48 else:
49 # raise OSError for parity with os.O_NOFOLLOW above
50 raise OSError(f"{path} is a symlink; Will not return uid for symlinks")
51 return file_uid
52
53
54# packages in the stdlib that may have installation metadata, but should not be
55# considered 'installed'. this theoretically could be determined based on
56# dist.location (py27:`sysconfig.get_paths()['stdlib']`,
57# py26:sysconfig.get_config_vars('LIBDEST')), but fear platform variation may
58# make this ineffective, so hard-coding
for i

References i.

◆ has_tls()

bool has_tls ( )

Definition at line 14 of file compat.py.

14def has_tls() -> bool:
15 try:
16 import _ssl # noqa: F401 # ignore unused
17
18 return True
19 except ImportError:
20 pass
21
22 from pip._vendor.urllib3.util import IS_PYOPENSSL
23
24 return IS_PYOPENSSL
25
26

Variable Documentation

◆ logger

logger = logging.getLogger(__name__)

Definition at line 11 of file compat.py.

◆ stdlib_pkgs

dict stdlib_pkgs = {"python", "wsgiref", "argparse"}

Definition at line 59 of file compat.py.

◆ WINDOWS

WINDOWS = sys.platform.startswith("win") or (sys.platform == "cli" and os.name == "nt")

Definition at line 63 of file compat.py.