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

Functions

int _wrapper (Optional[List[str]] args=None)
 
str get_best_invocation_for_this_pip ()
 
str get_best_invocation_for_this_python ()
 

Variables

list _EXECUTABLE_NAMES
 
dict _allowed_extensions = {"", ".exe"}
 

Function Documentation

◆ _wrapper()

int _wrapper ( Optional[List[str]]   args = None)
protected
Central wrapper for all old entrypoints.

Historically pip has had several entrypoints defined. Because of issues
arising from PATH, sys.path, multiple Pythons, their interactions, and most
of them having a pip installed, users suffer every time an entrypoint gets
moved.

To alleviate this pain, and provide a mechanism for warning users and
directing them to an appropriate place for help, we now define all of
our old entrypoints as wrappers for the current one.

Definition at line 23 of file entrypoints.py.

23def _wrapper(args: Optional[List[str]] = None) -> int:
24 """Central wrapper for all old entrypoints.
25
26 Historically pip has had several entrypoints defined. Because of issues
27 arising from PATH, sys.path, multiple Pythons, their interactions, and most
28 of them having a pip installed, users suffer every time an entrypoint gets
29 moved.
30
31 To alleviate this pain, and provide a mechanism for warning users and
32 directing them to an appropriate place for help, we now define all of
33 our old entrypoints as wrappers for the current one.
34 """
36 "WARNING: pip is being invoked by an old script wrapper. This will "
37 "fail in a future version of pip.\n"
38 "Please see https://github.com/pypa/pip/issues/5599 for advice on "
39 "fixing the underlying issue.\n"
40 "To avoid this problem you can invoke Python with '-m pip' instead of "
41 "running pip directly.\n"
42 )
43 return main(args)
44
45
for i

References i.

◆ get_best_invocation_for_this_pip()

str get_best_invocation_for_this_pip ( )
Try to figure out the best way to invoke pip in the current environment.

Definition at line 46 of file entrypoints.py.

46def get_best_invocation_for_this_pip() -> str:
47 """Try to figure out the best way to invoke pip in the current environment."""
48 binary_directory = "Scripts" if WINDOWS else "bin"
49 binary_prefix = os.path.join(sys.prefix, binary_directory)
50
51 # Try to use pip[X[.Y]] names, if those executables for this environment are
52 # the first on PATH with that name.
53 path_parts = os.path.normcase(os.environ.get("PATH", "")).split(os.pathsep)
54 exe_are_in_PATH = os.path.normcase(binary_prefix) in path_parts
55 if exe_are_in_PATH:
56 for exe_name in _EXECUTABLE_NAMES:
57 found_executable = shutil.which(exe_name)
58 binary_executable = os.path.join(binary_prefix, exe_name)
59 if (
60 found_executable
61 and os.path.exists(binary_executable)
63 found_executable,
64 binary_executable,
65 )
66 ):
67 return exe_name
68
69 # Use the `-m` invocation, if there's no "nice" invocation.
70 return f"{get_best_invocation_for_this_python()} -m pip"
71
72

References i.

◆ get_best_invocation_for_this_python()

str get_best_invocation_for_this_python ( )
Try to figure out the best way to invoke the current Python.

Definition at line 73 of file entrypoints.py.

73def get_best_invocation_for_this_python() -> str:
74 """Try to figure out the best way to invoke the current Python."""
75 exe = sys.executable
76 exe_name = os.path.basename(exe)
77
78 # Try to use the basename, if it's the first executable.
79 found_executable = shutil.which(exe_name)
80 if found_executable and os.path.samefile(found_executable, exe):
81 return exe_name
82
83 # Use the full executable name, because we couldn't find something simpler.
84 return exe

References i.

Variable Documentation

◆ _allowed_extensions

dict _allowed_extensions = {"", ".exe"}
protected

Definition at line 16 of file entrypoints.py.

◆ _EXECUTABLE_NAMES

list _EXECUTABLE_NAMES
protected
Initial value:
1= [
2 "pip",
3 f"pip{sys.version_info.major}",
4 f"pip{sys.version_info.major}.{sys.version_info.minor}",
5]

Definition at line 10 of file entrypoints.py.