mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Ducktape for downloading LICENSE of pipdeptree
This package uses hatchling as a build backend and required special case. There should be a better way, but for now this works.
This commit is contained in:
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2015 Vineet Naik (naikvin@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+26
-11
@@ -486,6 +486,7 @@ def download_licenses(
|
||||
log(requirements)
|
||||
tmp_dir = vendor_dir / "__tmp__"
|
||||
# TODO: Fix this whenever it gets sorted out (see https://github.com/pypa/pip/issues/5739)
|
||||
|
||||
cmd = "pip download --no-binary :all: --only-binary requests_download --no-deps"
|
||||
ctx.run("pip install flit") # needed for the next step
|
||||
for req in requirements:
|
||||
@@ -493,20 +494,34 @@ def download_licenses(
|
||||
try:
|
||||
ctx.run(exe_cmd)
|
||||
except invoke.exceptions.UnexpectedExit as e:
|
||||
if "Disabling PEP 517 processing is invalid" not in e.result.stderr:
|
||||
if "ModuleNotFoundErr" in e.result.stderr.strip():
|
||||
|
||||
target = parse.parse(
|
||||
"ModuleNotFoundError: No module named '{backend}'",
|
||||
e.result.stderr.strip().split("\n")[-1],
|
||||
)
|
||||
backend = target.named.get("backend")
|
||||
if backend is not None:
|
||||
if "." in backend:
|
||||
backend, _, _ = backend.partition(".")
|
||||
ctx.run(f"pip install {backend}")
|
||||
ctx.run("pip install hatch-vcs")
|
||||
elif "Disabling PEP 517 processing is invalid" not in e.result.stderr:
|
||||
log(f"WARNING: Failed to download license for {req}")
|
||||
continue
|
||||
parse_target = (
|
||||
"Disabling PEP 517 processing is invalid: project specifies a build "
|
||||
"backend of {backend} in pyproject.toml"
|
||||
)
|
||||
target = parse.parse(parse_target, e.result.stderr.strip())
|
||||
backend = target.named.get("backend")
|
||||
if backend is not None:
|
||||
if "." in backend:
|
||||
backend, _, _ = backend.partition(".")
|
||||
ctx.run(f"pip install {backend}")
|
||||
else:
|
||||
parse_target = (
|
||||
"Disabling PEP 517 processing is invalid: project specifies a build "
|
||||
"backend of {backend} in pyproject.toml"
|
||||
)
|
||||
target = parse.parse(parse_target, e.result.stderr.strip())
|
||||
backend = target.named.get("backend")
|
||||
if backend is not None:
|
||||
if "." in backend:
|
||||
backend, _, _ = backend.partition(".")
|
||||
ctx.run(f"pip install {backend}")
|
||||
ctx.run(f"{cmd} --no-build-isolation -d {tmp_dir.as_posix()} {req}")
|
||||
|
||||
for sdist in tmp_dir.iterdir():
|
||||
extract_license(vendor_dir, sdist)
|
||||
drop_dir(tmp_dir)
|
||||
|
||||
Reference in New Issue
Block a user