question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Unusually named license_files not included in dist-info

See original GitHub issue

setuptools version

setuptools===57.4.0

Python version

3.9.6

OS

Fedora Linux 33, x86_64

Additional environment information

wheel===0.36.2

Description

I’ve tried to test out https://github.com/pypa/setuptools/pull/2645 but including license files not named according to this pattern:

https://github.com/pypa/setuptools/blob/0c302d232dd1a1f4ec531050532a84274edac2f4/setuptools/dist.py#L596

Are not included in dist info.

Expected behavior

I expected that files explicitly listed in license_files will always be listed in METADATA under License-File: and will always be included in the dist-info directory regardless of their filename.

How to Reproduce

Consider this setup.py:

from setuptools import setup

setup(
    name='nested_dist',
    version='666',
    license_files=['LICENSE'],
)

And an empty LICENSE file.

Run:

$ python -c 'import setuptools.build_meta; setuptools.build_meta.__legacy__.prepare_metadata_for_build_wheel(".")'

Or:

$ python setup.py bdist_wheel

Or:

$ pip wheel .

You’ll see something like:

running dist_info
...
adding license file 'LICENSE'
...
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
...

The LICENSE file will be listed in METADATA under License-File: and it will be included in the dist-info directory.

Now rename LICENSE to DIFFERENT and adapt license_files accordingly:

from setuptools import setup

setup(
    name='nested_dist',
    version='666',
    license_files=['DIFFERENT'],
)

You’ll get:

...
adding license file 'DIFFERENT'
...

The DIFFERENT file will be listed in METADATA under License-File: and it will not be included in the dist-info directory.

Output

See above.

Code of Conduct

  • I agree to follow the PSF Code of Conduct

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
encukoucommented, Jul 26, 2021

Also, what happens if someone names the license file RECORD?

Raise an error if an existing file in dist-info would be overwritten? That’d allow adding better solutions in the future.

0reactions
cdce8pcommented, Jul 25, 2021

I don’t understand what is the point of listing missing files as License-File. If wheel cannot add files like this, setuptools should not list them and fail instead.

If you’re referring to the license_files argument in setup(), I agree this should be deprecated / removed.

With setup.cfg, it kinda works.

However, when the licenses are in nested directories, as listed in the given example: https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-file

The license files are included directly in the dist-info directory (e.g. as license.txt) and the License-File: entries are incorrect (e.g. 3rdparty/license.txt).

That is still a point that needs to be addressed. IMO wheel needs to update their implementation here. Although they do mention the behavior in their docs, it can cause name conflicts, e.g., if a file named LICENSE is present in a sub dir in addition to the main one.

No matter the path, all the matching license files are written in the wheel in the .dist-info
directory based on their file name only.

In that case 3rdparty/LICENSE would overwrite the previous one.

– I’m open to suggestions if you have an idea how to better resolve this conflict.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Knowledge Bits — Common Python Packaging Mistakes
Python Package Not Included in Wheel ... At time of writing, Poetry does not support adding license files to a wheel's *.dist-info directory ......
Read more >
python - pip install . creates only the dist-info not the package
I am trying to make a python package which I want to install using pip install . locally. The package name is listed...
Read more >
PEP 639: Improving license clarity with better package metadata
There has been some recent discussion to improve the clarity of license-related metadata. What's the problem? We have two license fields (License and ......
Read more >
Bug listing with status CONFIRMED as at 2022/12/20 18:46:38
status:CONFIRMED resolution: severity:normal · Bug:21527 - "net-misc/ntp: ntp-client init.d: default to `sntp` instead of `ntpdate`" status:CONFIRMED ...
Read more >
Changelog - pip documentation v22.3.1
Improve error message when pip config edit is provided an editor that doesn't exist. ... Ignore .dist-info directories if the stem is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found