comparison planemo/lib/python3.7/site-packages/pip/_internal/distributions/source.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
1 import logging
2
3 from pip._internal.build_env import BuildEnvironment
4 from pip._internal.distributions.base import AbstractDistribution
5 from pip._internal.exceptions import InstallationError
6
7 logger = logging.getLogger(__name__)
8
9
10 class SourceDistribution(AbstractDistribution):
11 """Represents a source distribution.
12
13 The preparation step for these needs metadata for the packages to be
14 generated, either using PEP 517 or using the legacy `setup.py egg_info`.
15
16 NOTE from @pradyunsg (14 June 2019)
17 I expect SourceDistribution class will need to be split into
18 `legacy_source` (setup.py based) and `source` (PEP 517 based) when we start
19 bringing logic for preparation out of InstallRequirement into this class.
20 """
21
22 def get_pkg_resources_distribution(self):
23 return self.req.get_dist()
24
25 def prepare_distribution_metadata(self, finder, build_isolation):
26 # Prepare for building. We need to:
27 # 1. Load pyproject.toml (if it exists)
28 # 2. Set up the build environment
29
30 self.req.load_pyproject_toml()
31 should_isolate = self.req.use_pep517 and build_isolation
32
33 def _raise_conflicts(conflicting_with, conflicting_reqs):
34 raise InstallationError(
35 "Some build dependencies for %s conflict with %s: %s." % (
36 self.req, conflicting_with, ', '.join(
37 '%s is incompatible with %s' % (installed, wanted)
38 for installed, wanted in sorted(conflicting))))
39
40 if should_isolate:
41 # Isolate in a BuildEnvironment and install the build-time
42 # requirements.
43 self.req.build_env = BuildEnvironment()
44 self.req.build_env.install_requirements(
45 finder, self.req.pyproject_requires, 'overlay',
46 "Installing build dependencies"
47 )
48 conflicting, missing = self.req.build_env.check_requirements(
49 self.req.requirements_to_check
50 )
51 if conflicting:
52 _raise_conflicts("PEP 517/518 supported requirements",
53 conflicting)
54 if missing:
55 logger.warning(
56 "Missing build requirements in pyproject.toml for %s.",
57 self.req,
58 )
59 logger.warning(
60 "The project does not specify a build backend, and "
61 "pip cannot fall back to setuptools without %s.",
62 " and ".join(map(repr, sorted(missing)))
63 )
64 # Install any extra build dependencies that the backend requests.
65 # This must be done in a second pass, as the pyproject.toml
66 # dependencies must be installed before we can call the backend.
67 with self.req.build_env:
68 # We need to have the env active when calling the hook.
69 self.req.spin_message = "Getting requirements to build wheel"
70 reqs = self.req.pep517_backend.get_requires_for_build_wheel()
71 conflicting, missing = self.req.build_env.check_requirements(reqs)
72 if conflicting:
73 _raise_conflicts("the backend dependencies", conflicting)
74 self.req.build_env.install_requirements(
75 finder, missing, 'normal',
76 "Installing backend dependencies"
77 )
78
79 self.req.prepare_metadata()
80 self.req.assert_source_matches_version()