Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pip local install (via PEP 517) fails if a folder named LICENSES is present in the source code #2565

Closed
3 tasks done
MrJohz opened this issue Jun 16, 2020 · 6 comments · Fixed by python-poetry/poetry-core#57
Assignees
Labels
kind/bug Something isn't working as expected

Comments

@MrJohz
Copy link

MrJohz commented Jun 16, 2020

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Linux (Pop OS 20.04)
  • Poetry version: 1.0.9
  • Link of a Gist with the contents of your pyproject.toml file: See project here

Issue

Running pip install . in a poetry project that has a folder named LICENSES will fail with the following exception:

$ pip install .
Processing /home/frere76/projects/tests/poetry-licenses-bug
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: poetry-licenses-bug
  Building wheel for poetry-licenses-bug (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/frere76/.asdf/installs/python/3.8.3/bin/python3.8 /home/frere76/.asdf/installs/python/3.8.3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpjwp444l1
       cwd: /tmp/pip-req-build-u5w5jo8u
  Complete output (18 lines):
  Traceback (most recent call last):
    File "/home/frere76/.asdf/installs/python/3.8.3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/home/frere76/.asdf/installs/python/3.8.3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/frere76/.asdf/installs/python/3.8.3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 204, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/tmp/pip-build-env-0mpwncyw/overlay/lib/python3.8/site-packages/poetry/masonry/api.py", line 62, in build_wheel
      WheelBuilder.make_in(
    File "/tmp/pip-build-env-0mpwncyw/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 55, in make_in
      wb.build()
    File "/tmp/pip-build-env-0mpwncyw/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 82, in build
      self._write_metadata(zip_file)
    File "/tmp/pip-build-env-0mpwncyw/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 188, in _write_metadata
      self._add_file(wheel, path, "%s/%s" % (self.dist_info, path.name))
    File "/tmp/pip-build-env-0mpwncyw/overlay/lib/python3.8/site-packages/poetry/masonry/builders/wheel.py", line 265, in _add_file
      with open(full_path, "rb") as src:
  IsADirectoryError: [Errno 21] Is a directory: 'LICENSES'
  ----------------------------------------
  ERROR: Failed building wheel for poetry-licenses-bug
Failed to build poetry-licenses-bug
ERROR: Could not build wheels for poetry-licenses-bug which use PEP 517 and cannot be installed directly

See the linked repository (https://github.com/MrJohz/poetry-license-error-demo) for a full reproduction example.

@MrJohz MrJohz added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 16, 2020
@MrJohz
Copy link
Author

MrJohz commented Jun 16, 2020

Having looked briefly through the source, I think the issue is here:

for base in ("COPYING", "LICENSE"):
for path in sorted(self._path.glob(base + "*")):
self._add_file(wheel, path, "%s/%s" % (self.dist_info, path.name))

Poetry automatically adds any COPYING* and LICENSE* files to the wheel if they exist. The directory name LICENSES technically matches the second glob pattern, but as it is a directory it causes issues.

Perhaps a way of solving this would be to enumerate a few more different options for these automatic inclusion files:

  • LICENSE and COPYING (with no extension, and not if they are directories)
  • LICENSE.* and COPYING.* (with any extensions, and not if they are directories)
  • LICENSES/** (any file that is in the folder LICENSES, as matches the REUSE spec)

If it helps, I can create a pull request to implement the above changes.

@abn
Copy link
Member

abn commented Jun 19, 2020

Another way to solve this and any similar issues might be to fix _add_file in core to recurse through all files correctly if directory.

https://github.com/python-poetry/core/blob/d582844eb503e6b0232c72680add2eb8b498a854/poetry/core/masonry/builders/wheel.py#L205-L236

@MrJohz
Copy link
Author

MrJohz commented Jul 1, 2020

@abn - would you prefer me to go down that route to fixing this issue? I have a potential fix in PR #2573 - could you review this and check if this is sufficient? If not I could create an alternative PR going down the route you suggest.

milliams added a commit to milliams/mebula that referenced this issue Jul 29, 2020
This avoids only hitting an error when making a release.
Currently this is failing due to python-poetry/poetry#2565
@milliams
Copy link

This issue is affecting poetry build as well which is preventing us from being able to make a release of our software. While waiting for a fix, is there a possible workaround?

As alluded to by @MrJohz, the use of the LICENSES directory will increase as it is a requirement of the REUSE spec:

Each License File MUST be placed in the LICENSES/ directory in the root of the Project. The name of the License File MUST be the SPDX License Identifier of the license followed by an appropriate file extension (example: LICENSES/GPL-3.0-or-later.txt). The License File MUST be in plain text format.

@MrJohz
Copy link
Author

MrJohz commented Jul 29, 2020

As an aside, it looks like since I last looked at this, the relevant code moved to python-poetry/poetry-core here, which also makes the current pull request kind of useless. @finswimmer / @abn - is there a way for you to move this issue & PR to the other repository, or should I just create a new issue there?

I would second @milliams' point about the REUSE spec - it's becoming increasingly common to see this in research software engineering, and the fact that anyone trying to implement this spec cannot, by default, use poetry to manage their project makes this a bit of a blocker.

Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
4 participants