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

Functions

str get_major_minor_version ()
 
str change_root (str new_root, str pathname)
 
str get_src_prefix ()
 
bool is_osx_framework ()
 

Variables

 USER_CACHE_DIR = appdirs.user_cache_dir("pip")
 
str site_packages = sysconfig.get_path("purelib")
 
typing user_site = site.getusersitepackages()
 

Function Documentation

◆ change_root()

str change_root ( str  new_root,
str  pathname 
)
Return 'pathname' with 'new_root' prepended.

If 'pathname' is relative, this is equivalent to os.path.join(new_root, pathname).
Otherwise, it requires making 'pathname' relative and then joining the
two, which is tricky on DOS/Windows and Mac OS.

This is borrowed from Python's standard library's distutils module.

Definition at line 27 of file base.py.

27def change_root(new_root: str, pathname: str) -> str:
28 """Return 'pathname' with 'new_root' prepended.
29
30 If 'pathname' is relative, this is equivalent to os.path.join(new_root, pathname).
31 Otherwise, it requires making 'pathname' relative and then joining the
32 two, which is tricky on DOS/Windows and Mac OS.
33
34 This is borrowed from Python's standard library's distutils module.
35 """
36 if os.name == "posix":
37 if not os.path.isabs(pathname):
38 return os.path.join(new_root, pathname)
39 else:
40 return os.path.join(new_root, pathname[1:])
41
42 elif os.name == "nt":
43 (drive, path) = os.path.splitdrive(pathname)
44 if path[0] == "\\":
45 path = path[1:]
46 return os.path.join(new_root, path)
47
48 else:
49 raise InstallationError(
50 f"Unknown platform: {os.name}\n"
51 "Can not change root path prefix on unknown platform."
52 )
53
54
for i

References i.

◆ get_major_minor_version()

str get_major_minor_version ( )
Return the major-minor version of the current Python as a string, e.g.
"3.7" or "3.10".

Definition at line 19 of file base.py.

19def get_major_minor_version() -> str:
20 """
21 Return the major-minor version of the current Python as a string, e.g.
22 "3.7" or "3.10".
23 """
24 return "{}.{}".format(*sys.version_info)
25
26

References i.

◆ get_src_prefix()

str get_src_prefix ( )

Definition at line 55 of file base.py.

55def get_src_prefix() -> str:
56 if running_under_virtualenv():
57 src_prefix = os.path.join(sys.prefix, "src")
58 else:
59 # FIXME: keep src in cwd for now (it is not a temporary folder)
60 try:
61 src_prefix = os.path.join(os.getcwd(), "src")
62 except OSError:
63 # In case the current working directory has been renamed or deleted
64 sys.exit("The folder you are executing pip from can no longer be found.")
65
66 # under macOS + virtualenv sys.prefix is not properly resolved
67 # it is something like /path/to/python/bin/..
68 return os.path.abspath(src_prefix)
69
70

References i.

◆ is_osx_framework()

bool is_osx_framework ( )

Definition at line 80 of file base.py.

80def is_osx_framework() -> bool:
81 return bool(sysconfig.get_config_var("PYTHONFRAMEWORK"))

References i.

Variable Documentation

◆ site_packages

str site_packages = sysconfig.get_path("purelib")

Definition at line 16 of file base.py.

◆ USER_CACHE_DIR

USER_CACHE_DIR = appdirs.user_cache_dir("pip")

Definition at line 13 of file base.py.

◆ user_site

user_site = site.getusersitepackages()

Definition at line 74 of file base.py.