Skip to content

Commit

Permalink
Ducktape for downlowding LICENSE of pipdeptree
Browse files Browse the repository at this point in the history
This package uses hatchling as a build backend and required special
case.
There should be a better way, but for now this works.
  • Loading branch information
oz123 committed Sep 8, 2022
1 parent 6437584 commit eb8a96e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 11 deletions.
20 changes: 20 additions & 0 deletions pipenv/vendor/pipdeptree/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2015 Vineet Naik ([email protected])

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.
37 changes: 26 additions & 11 deletions tasks/vendoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,27 +486,42 @@ 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:
exe_cmd = "{} --no-build-isolation -d {} {}".format(cmd, tmp_dir.as_posix(), req)
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)
Expand Down

0 comments on commit eb8a96e

Please sign in to comment.