Fetch binary wheel(s) using pip for the ``envt`` Environment given a list of pip ``requirements_files`` and a list of ``requirements_specifiers`` string (such as package names or as name==version). Return a tuple of (list of downloaded files, error string). Do NOT fail on errors
(
requirements_specifiers=tuple(),
requirements_files=tuple(),
environment=None,
dest_dir=THIRDPARTY_DIR,
index_url=PYPI_SIMPLE_URL,
links_url=ABOUT_LINKS_URL,
)
| 2163 | |
| 2164 | |
| 2165 | def download_wheels_with_pip( |
| 2166 | requirements_specifiers=tuple(), |
| 2167 | requirements_files=tuple(), |
| 2168 | environment=None, |
| 2169 | dest_dir=THIRDPARTY_DIR, |
| 2170 | index_url=PYPI_SIMPLE_URL, |
| 2171 | links_url=ABOUT_LINKS_URL, |
| 2172 | ): |
| 2173 | """ |
| 2174 | Fetch binary wheel(s) using pip for the ``envt`` Environment given a list of |
| 2175 | pip ``requirements_files`` and a list of ``requirements_specifiers`` string |
| 2176 | (such as package names or as name==version). |
| 2177 | Return a tuple of (list of downloaded files, error string). |
| 2178 | Do NOT fail on errors, but return an error message on failure. |
| 2179 | """ |
| 2180 | |
| 2181 | cli_args = [ |
| 2182 | "pip", |
| 2183 | "download", |
| 2184 | "--only-binary", |
| 2185 | ":all:", |
| 2186 | "--dest", |
| 2187 | dest_dir, |
| 2188 | "--index-url", |
| 2189 | index_url, |
| 2190 | "--find-links", |
| 2191 | links_url, |
| 2192 | "--no-color", |
| 2193 | "--progress-bar", |
| 2194 | "off", |
| 2195 | "--no-deps", |
| 2196 | "--no-build-isolation", |
| 2197 | "--verbose", |
| 2198 | # "--verbose", |
| 2199 | ] |
| 2200 | |
| 2201 | if environment: |
| 2202 | eopts = environment.get_pip_cli_options() |
| 2203 | cli_args.extend(eopts) |
| 2204 | else: |
| 2205 | print("WARNING: no download environment provided.") |
| 2206 | |
| 2207 | cli_args.extend(requirements_specifiers) |
| 2208 | for req_file in requirements_files: |
| 2209 | cli_args.extend(["--requirement", req_file]) |
| 2210 | |
| 2211 | if TRACE: |
| 2212 | print(f"Downloading wheels using command:", " ".join(cli_args)) |
| 2213 | |
| 2214 | existing = set(os.listdir(dest_dir)) |
| 2215 | error = False |
| 2216 | try: |
| 2217 | returncode, _stdout, stderr = call(cli_args, verbose=True) |
| 2218 | if returncode != 0: |
| 2219 | error = stderr |
| 2220 | except Exception as e: |
| 2221 | error = str(e) |
| 2222 |
nothing calls this directly
no test coverage detected