1"""Orchestrator for building wheels from InstallRequirements.
8from typing
import Iterable, List, Optional, Tuple
34BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]
38 """Determine whether the string looks like an egg_info.
40 :param s: The string to parse. E.g. foo-2.1
46 req: InstallRequirement,
49 """Return whether an InstallRequirement should be built into a wheel."""
56 "Skipping %s, due to already being wheel.",
78def should_build_for_wheel_command(
79 req: InstallRequirement,
84def should_build_for_install_command(
85 req: InstallRequirement,
91 req: InstallRequirement,
94 Return whether a built InstallRequirement can be stored in the persistent
95 wheel cache, assuming the wheel cache is available, and _should_build()
96 has determined a wheel needs to be built.
123 req: InstallRequirement,
124 wheel_cache: WheelCache,
126 """Return the persistent or temporary cache directory where the built
127 wheel need to be stored.
139 canonical_name = canonicalize_name(
req.name or "")
141 if canonicalize_name(
w.name) != canonical_name:
143 "Wheel has unexpected file name: expected {!r}, "
144 "got {!r}".format(canonical_name,
w.name),
146 dist = get_wheel_distribution(
FilesystemWheel(wheel_path), canonical_name)
148 if canonicalize_version(dist_verstr) != canonicalize_version(
w.version):
150 "Wheel has unexpected file name: expected {!r}, "
151 "got {!r}".format(dist_verstr,
w.version),
154 if metadata_version_value
is None:
157 metadata_version =
Version(metadata_version_value)
158 except InvalidVersion:
159 msg = f
"Invalid Metadata-Version: {metadata_version_value}"
163 "Metadata 1.2 mandates PEP 440 version, "
164 "but {!r} is not".format(dist_verstr)
169 req: InstallRequirement,
172 build_options: List[str],
173 global_options: List[str],
178 :return: The filename of the built wheel, or None if the build failed.
180 artifact =
"editable" if editable
else "wheel"
182 ensure_dir(output_dir)
185 "Building %s for %s failed: %s",
195 req, output_dir, build_options, global_options, editable
197 if wheel_path
and verify:
200 except (InvalidWheelFilename, UnsupportedWheel)
as e:
207 req: InstallRequirement,
209 build_options: List[str],
210 global_options: List[str],
220 "Ignoring --global-option when building %s using PEP 517",
req.name
224 "Ignoring --build-option when building %s using PEP 517",
req.name
227 wheel_path = build_wheel_editable(
234 wheel_path = build_wheel_pep517(
241 wheel_path = build_wheel_legacy(
245 global_options=global_options,
246 build_options=build_options,
250 if wheel_path
is not None:
254 wheel_hash, length = hash_file(wheel_path)
257 "Created wheel for %s: filename=%s size=%d sha256=%s",
265 except Exception
as e:
267 "Building wheel for %s failed: %s",
278 clean_args = make_setuptools_clean_args(
280 global_options=global_options,
286 clean_args, command_desc=
"python setup.py clean", cwd=
req.source_dir
295 requirements: Iterable[InstallRequirement],
296 wheel_cache: WheelCache,
298 build_options: List[str],
299 global_options: List[str],
303 :return: The list of InstallRequirement that succeeded to build and
304 the list of InstallRequirement that failed to build.
311 "Building wheels for collected packages: %s",
312 ", ".join(
req.name for req
in requirements),
316 build_successes, build_failures = [], []
317 for req
in requirements:
346 "Successfully built %s",
347 " ".join([
req.name for req
in build_successes]),
351 "Failed to build %s",
352 " ".join([
req.name for req
in build_failures]),
355 return build_successes, build_failures
bool _contains_egg_info(str s)
Optional[str] _build_one_inside_env(InstallRequirement req, str output_dir, List[str] build_options, List[str] global_options, bool editable)
bool _should_build(InstallRequirement req, bool need_wheel)
str _get_cache_dir(InstallRequirement req, WheelCache wheel_cache)
Optional[bool] _should_cache(InstallRequirement req)
bool _clean_one_legacy(InstallRequirement req, List[str] global_options)
Optional[str] _build_one(InstallRequirement req, str output_dir, bool verify, List[str] build_options, List[str] global_options, bool editable)
None _verify_one(InstallRequirement req, str wheel_path)