Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/pip/_internal/commands/wheel.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 # -*- coding: utf-8 -*- | |
2 from __future__ import absolute_import | |
3 | |
4 import logging | |
5 import os | |
6 | |
7 from pip._internal.cache import WheelCache | |
8 from pip._internal.cli import cmdoptions | |
9 from pip._internal.cli.base_command import RequirementCommand | |
10 from pip._internal.exceptions import CommandError, PreviousBuildDirError | |
11 from pip._internal.legacy_resolve import Resolver | |
12 from pip._internal.operations.prepare import RequirementPreparer | |
13 from pip._internal.req import RequirementSet | |
14 from pip._internal.req.req_tracker import RequirementTracker | |
15 from pip._internal.utils.temp_dir import TempDirectory | |
16 from pip._internal.wheel import WheelBuilder | |
17 | |
18 logger = logging.getLogger(__name__) | |
19 | |
20 | |
21 class WheelCommand(RequirementCommand): | |
22 """ | |
23 Build Wheel archives for your requirements and dependencies. | |
24 | |
25 Wheel is a built-package format, and offers the advantage of not | |
26 recompiling your software during every install. For more details, see the | |
27 wheel docs: https://wheel.readthedocs.io/en/latest/ | |
28 | |
29 Requirements: setuptools>=0.8, and wheel. | |
30 | |
31 'pip wheel' uses the bdist_wheel setuptools extension from the wheel | |
32 package to build individual wheels. | |
33 | |
34 """ | |
35 | |
36 name = 'wheel' | |
37 usage = """ | |
38 %prog [options] <requirement specifier> ... | |
39 %prog [options] -r <requirements file> ... | |
40 %prog [options] [-e] <vcs project url> ... | |
41 %prog [options] [-e] <local project path> ... | |
42 %prog [options] <archive url/path> ...""" | |
43 | |
44 summary = 'Build wheels from your requirements.' | |
45 | |
46 def __init__(self, *args, **kw): | |
47 super(WheelCommand, self).__init__(*args, **kw) | |
48 | |
49 cmd_opts = self.cmd_opts | |
50 | |
51 cmd_opts.add_option( | |
52 '-w', '--wheel-dir', | |
53 dest='wheel_dir', | |
54 metavar='dir', | |
55 default=os.curdir, | |
56 help=("Build wheels into <dir>, where the default is the " | |
57 "current working directory."), | |
58 ) | |
59 cmd_opts.add_option(cmdoptions.no_binary()) | |
60 cmd_opts.add_option(cmdoptions.only_binary()) | |
61 cmd_opts.add_option(cmdoptions.prefer_binary()) | |
62 cmd_opts.add_option( | |
63 '--build-option', | |
64 dest='build_options', | |
65 metavar='options', | |
66 action='append', | |
67 help="Extra arguments to be supplied to 'setup.py bdist_wheel'.", | |
68 ) | |
69 cmd_opts.add_option(cmdoptions.no_build_isolation()) | |
70 cmd_opts.add_option(cmdoptions.use_pep517()) | |
71 cmd_opts.add_option(cmdoptions.no_use_pep517()) | |
72 cmd_opts.add_option(cmdoptions.constraints()) | |
73 cmd_opts.add_option(cmdoptions.editable()) | |
74 cmd_opts.add_option(cmdoptions.requirements()) | |
75 cmd_opts.add_option(cmdoptions.src()) | |
76 cmd_opts.add_option(cmdoptions.ignore_requires_python()) | |
77 cmd_opts.add_option(cmdoptions.no_deps()) | |
78 cmd_opts.add_option(cmdoptions.build_dir()) | |
79 cmd_opts.add_option(cmdoptions.progress_bar()) | |
80 | |
81 cmd_opts.add_option( | |
82 '--global-option', | |
83 dest='global_options', | |
84 action='append', | |
85 metavar='options', | |
86 help="Extra global options to be supplied to the setup.py " | |
87 "call before the 'bdist_wheel' command.") | |
88 | |
89 cmd_opts.add_option( | |
90 '--pre', | |
91 action='store_true', | |
92 default=False, | |
93 help=("Include pre-release and development versions. By default, " | |
94 "pip only finds stable versions."), | |
95 ) | |
96 | |
97 cmd_opts.add_option(cmdoptions.no_clean()) | |
98 cmd_opts.add_option(cmdoptions.require_hashes()) | |
99 | |
100 index_opts = cmdoptions.make_option_group( | |
101 cmdoptions.index_group, | |
102 self.parser, | |
103 ) | |
104 | |
105 self.parser.insert_option_group(0, index_opts) | |
106 self.parser.insert_option_group(0, cmd_opts) | |
107 | |
108 def run(self, options, args): | |
109 cmdoptions.check_install_build_global(options) | |
110 | |
111 if options.build_dir: | |
112 options.build_dir = os.path.abspath(options.build_dir) | |
113 | |
114 options.src_dir = os.path.abspath(options.src_dir) | |
115 | |
116 with self._build_session(options) as session: | |
117 finder = self._build_package_finder(options, session) | |
118 build_delete = (not (options.no_clean or options.build_dir)) | |
119 wheel_cache = WheelCache(options.cache_dir, options.format_control) | |
120 | |
121 with RequirementTracker() as req_tracker, TempDirectory( | |
122 options.build_dir, delete=build_delete, kind="wheel" | |
123 ) as directory: | |
124 | |
125 requirement_set = RequirementSet( | |
126 require_hashes=options.require_hashes, | |
127 ) | |
128 | |
129 try: | |
130 self.populate_requirement_set( | |
131 requirement_set, args, options, finder, session, | |
132 self.name, wheel_cache | |
133 ) | |
134 | |
135 preparer = RequirementPreparer( | |
136 build_dir=directory.path, | |
137 src_dir=options.src_dir, | |
138 download_dir=None, | |
139 wheel_download_dir=options.wheel_dir, | |
140 progress_bar=options.progress_bar, | |
141 build_isolation=options.build_isolation, | |
142 req_tracker=req_tracker, | |
143 ) | |
144 | |
145 resolver = Resolver( | |
146 preparer=preparer, | |
147 finder=finder, | |
148 session=session, | |
149 wheel_cache=wheel_cache, | |
150 use_user_site=False, | |
151 upgrade_strategy="to-satisfy-only", | |
152 force_reinstall=False, | |
153 ignore_dependencies=options.ignore_dependencies, | |
154 ignore_requires_python=options.ignore_requires_python, | |
155 ignore_installed=True, | |
156 isolated=options.isolated_mode, | |
157 use_pep517=options.use_pep517 | |
158 ) | |
159 resolver.resolve(requirement_set) | |
160 | |
161 # build wheels | |
162 wb = WheelBuilder( | |
163 finder, preparer, wheel_cache, | |
164 build_options=options.build_options or [], | |
165 global_options=options.global_options or [], | |
166 no_clean=options.no_clean, | |
167 ) | |
168 build_failures = wb.build( | |
169 requirement_set.requirements.values(), session=session, | |
170 ) | |
171 if len(build_failures) != 0: | |
172 raise CommandError( | |
173 "Failed to build one or more wheels" | |
174 ) | |
175 except PreviousBuildDirError: | |
176 options.no_clean = True | |
177 raise | |
178 finally: | |
179 if not options.no_clean: | |
180 requirement_set.cleanup_files() | |
181 wheel_cache.cleanup() |