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

Functions

Dict[str, str] distutils_scheme (str dist_name, bool user=False, Optional[str] home=None, Optional[str] root=None, bool isolated=False, Optional[str] prefix=None, *bool ignore_config_files=False)
 
Scheme get_scheme (str dist_name, bool user=False, Optional[str] home=None, Optional[str] root=None, bool isolated=False, Optional[str] prefix=None)
 
str get_bin_prefix ()
 
str get_purelib ()
 
str get_platlib ()
 

Variables

 logger = logging.getLogger(__name__)
 

Detailed Description

Locations where we look for configs, install stuff, etc

Function Documentation

◆ distutils_scheme()

Dict[str, str] distutils_scheme ( str  dist_name,
bool   user = False,
Optional[str]   home = None,
Optional[str]   root = None,
bool   isolated = False,
Optional[str]   prefix = None,
*bool   ignore_config_files = False 
)
Return a distutils install scheme

Definition at line 35 of file _distutils.py.

44) -> Dict[str, str]:
45 """
46 Return a distutils install scheme
47 """
48 from distutils.dist import Distribution
49
50 dist_args: Dict[str, Union[str, List[str]]] = {"name": dist_name}
51 if isolated:
52 dist_args["script_args"] = ["--no-user-cfg"]
53
54 d = Distribution(dist_args)
55 if not ignore_config_files:
56 try:
58 except UnicodeDecodeError:
59 # Typeshed does not include find_config_files() for some reason.
60 paths = d.find_config_files() # type: ignore
62 "Ignore distutils configs in %s due to encoding errors.",
63 ", ".join(os.path.basename(p) for p in paths),
64 )
65 obj: Optional[DistutilsCommand] = None
66 obj = d.get_command_obj("install", create=True)
67 assert obj is not None
68 i = cast(distutils_install_command, obj)
69 # NOTE: setting user or home has the side-effect of creating the home dir
70 # or user base for installations during finalize_options()
71 # ideally, we'd prefer a scheme class that has no side-effects.
72 assert not (user and prefix), f"user={user} prefix={prefix}"
73 assert not (home and prefix), f"home={home} prefix={prefix}"
74 i.user = user or i.user
75 if user or home:
76 i.prefix = ""
77 i.prefix = prefix or i.prefix
78 i.home = home or i.home
79 i.root = root or i.root
81
82 scheme = {}
83 for key in SCHEME_KEYS:
84 scheme[key] = getattr(i, "install_" + key)
85
86 # install_lib specified in setup.cfg should install *everything*
87 # into there (i.e. it takes precedence over both purelib and
88 # platlib). Note, i.install_lib is *always* set after
89 # finalize_options(); we only want to override here if the user
90 # has explicitly requested it hence going back to the config
91 if "install_lib" in d.get_option_dict("install"):
92 scheme.update(dict(purelib=i.install_lib, platlib=i.install_lib))
93
94 if running_under_virtualenv():
95 if home:
96 prefix = home
97 elif user:
98 prefix = i.install_userbase
99 else:
100 prefix = i.prefix
101 scheme["headers"] = os.path.join(
102 prefix,
103 "include",
104 "site",
105 f"python{get_major_minor_version()}",
106 dist_name,
107 )
108
109 if root is not None:
110 path_no_drive = os.path.splitdrive(os.path.abspath(scheme["headers"]))[1]
111 scheme["headers"] = os.path.join(root, path_no_drive[1:])
112
113 return scheme
114
115
for i

References i.

Referenced by pip._internal.locations._distutils.get_scheme().

Here is the caller graph for this function:

◆ get_bin_prefix()

str get_bin_prefix ( )

Definition at line 151 of file _distutils.py.

151def get_bin_prefix() -> str:
152 # XXX: In old virtualenv versions, sys.prefix can contain '..' components,
153 # so we need to call normpath to eliminate them.
155 if WINDOWS:
156 bin_py = os.path.join(prefix, "Scripts")
157 # buildout uses 'bin' on Windows too?
158 if not os.path.exists(bin_py):
159 bin_py = os.path.join(prefix, "bin")
160 return bin_py
161 # Forcing to use /usr/local/bin for standard macOS framework installs
162 # Also log to ~/Library/Logs/ for use with the Console.app log viewer
163 if sys.platform[:6] == "darwin" and prefix[:16] == "/System/Library/":
164 return "/usr/local/bin"
165 return os.path.join(prefix, "bin")
166
167

References i.

◆ get_platlib()

str get_platlib ( )

Definition at line 172 of file _distutils.py.

172def get_platlib() -> str:
173 return get_python_lib(plat_specific=True)

◆ get_purelib()

str get_purelib ( )

Definition at line 168 of file _distutils.py.

168def get_purelib() -> str:
169 return get_python_lib(plat_specific=False)
170
171

◆ get_scheme()

Scheme get_scheme ( str  dist_name,
bool   user = False,
Optional[str]   home = None,
Optional[str]   root = None,
bool   isolated = False,
Optional[str]   prefix = None 
)
Get the "scheme" corresponding to the input parameters. The distutils
documentation provides the context for the available schemes:
https://docs.python.org/3/install/index.html#alternate-installation

:param dist_name: the name of the package to retrieve the scheme for, used
    in the headers scheme path
:param user: indicates to use the "user" scheme
:param home: indicates to use the "home" scheme and provides the base
    directory for the same
:param root: root under which other directories are re-based
:param isolated: equivalent to --no-user-cfg, i.e. do not consider
    ~/.pydistutils.cfg (posix) or ~/pydistutils.cfg (non-posix) for
    scheme paths
:param prefix: indicates to use the "prefix" scheme and provides the
    base directory for the same

Definition at line 116 of file _distutils.py.

123) -> Scheme:
124 """
125 Get the "scheme" corresponding to the input parameters. The distutils
126 documentation provides the context for the available schemes:
127 https://docs.python.org/3/install/index.html#alternate-installation
128
129 :param dist_name: the name of the package to retrieve the scheme for, used
130 in the headers scheme path
131 :param user: indicates to use the "user" scheme
132 :param home: indicates to use the "home" scheme and provides the base
133 directory for the same
134 :param root: root under which other directories are re-based
135 :param isolated: equivalent to --no-user-cfg, i.e. do not consider
136 ~/.pydistutils.cfg (posix) or ~/pydistutils.cfg (non-posix) for
137 scheme paths
138 :param prefix: indicates to use the "prefix" scheme and provides the
139 base directory for the same
140 """
141 scheme = distutils_scheme(dist_name, user, home, root, isolated, prefix)
142 return Scheme(
143 platlib=scheme["platlib"],
144 purelib=scheme["purelib"],
145 headers=scheme["headers"],
146 scripts=scheme["scripts"],
147 data=scheme["data"],
148 )
149
150

References pip._internal.locations._distutils.distutils_scheme().

Here is the call graph for this function:

Variable Documentation

◆ logger

logger = logging.getLogger(__name__)

Definition at line 32 of file _distutils.py.