]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pip/_internal/utils/setuptools_build.py
3 from typing
import List
, Optional
, Sequence
5 # Shim to wrap setup.py invocation with setuptools
6 # Note that __file__ is handled via two {!r} *and* %r, to ensure that paths on
7 # Windows are correctly handled (it should be "C:\\Users" not "C:\Users").
8 _SETUPTOOLS_SHIM
= textwrap
.dedent(
11 # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
13 # - It imports setuptools before invoking setup.py, to enable projects that directly
14 # import from `distutils.core` to work with newer packaging standards.
15 # - It provides a clear error message when setuptools is not installed.
16 # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
17 # setuptools doesn't think the script is `-c`. This avoids the following warning:
18 # manifest_maker: standard file '-c' not found".
19 # - It generates a shim setup.py, for handling setup.cfg-only projects.
20 import os, sys, tokenize
24 except ImportError as error:
26 "ERROR: Can not execute `setup.py` since setuptools is not available in "
27 "the build environment.",
33 sys.argv[0] = __file__
35 if os.path.exists(__file__):
37 with tokenize.open(__file__) as f:
38 setup_py_code = f.read()
40 filename = "<auto-generated setuptools caller>"
41 setup_py_code = "from setuptools import setup; setup()"
43 exec(compile(setup_py_code, filename, "exec"))
44 ''' % ({!r},), "<pip-setuptools-caller>", "exec"))
49 def make_setuptools_shim_args(
51 global_options
: Optional
[Sequence
[str]] = None,
52 no_user_config
: bool = False,
53 unbuffered_output
: bool = False,
56 Get setuptools command arguments with shim wrapped setup file invocation.
58 :param setup_py_path: The path to setup.py to be wrapped.
59 :param global_options: Additional global options.
60 :param no_user_config: If True, disables personal user configuration.
61 :param unbuffered_output: If True, adds the unbuffered switch to the
64 args
= [sys
.executable
]
67 args
+= ["-c", _SETUPTOOLS_SHIM
.format(setup_py_path
)]
69 args
+= global_options
71 args
+= ["--no-user-cfg"]
75 def make_setuptools_bdist_wheel_args(
77 global_options
: Sequence
[str],
78 build_options
: Sequence
[str],
81 # NOTE: Eventually, we'd want to also -S to the flags here, when we're
82 # isolating. Currently, it breaks Python in virtualenvs, because it
83 # relies on site.py to find parts of the standard library outside the
85 args
= make_setuptools_shim_args(
86 setup_py_path
, global_options
=global_options
, unbuffered_output
=True
88 args
+= ["bdist_wheel", "-d", destination_dir
]
93 def make_setuptools_clean_args(
95 global_options
: Sequence
[str],
97 args
= make_setuptools_shim_args(
98 setup_py_path
, global_options
=global_options
, unbuffered_output
=True
100 args
+= ["clean", "--all"]
104 def make_setuptools_develop_args(
107 global_options
: Sequence
[str],
108 no_user_config
: bool,
109 prefix
: Optional
[str],
113 assert not (use_user_site
and prefix
)
115 args
= make_setuptools_shim_args(
117 global_options
=global_options
,
118 no_user_config
=no_user_config
,
121 args
+= ["develop", "--no-deps"]
124 args
+= ["--prefix", prefix
]
126 args
+= ["--install-dir", home
]
129 args
+= ["--user", "--prefix="]
134 def make_setuptools_egg_info_args(
136 egg_info_dir
: Optional
[str],
137 no_user_config
: bool,
139 args
= make_setuptools_shim_args(setup_py_path
, no_user_config
=no_user_config
)
144 args
+= ["--egg-base", egg_info_dir
]