You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Unusually named license_files not included in dist-infoΒ #2739
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'],
)
@hroncok Thanks for the report, but this isn't a setuptools issue. The second entry is added by wheel.
Keep in mind that for wheel to be able to add license files based on patterns, you need to add license_files to the [metadata] section in setup.cfg, not define in in setup(). That will also add the license file to the .dist-info folder, once it's matched. For details, please refer to the wheel documentation: https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-file
As for the License-File: field in the METADATA: This one isn't in the official packaging spec yet. We only added it because it is useful for other project to be able and easily find the license files form the metadata. There is an effort to make it official, but it will take some more time. Until then, I don't expect wheel to support it. https://www.python.org/dev/peps/pep-0639/#license-file-multiple-use
I kinda expected that setuptools supports PEP 639 before it is accepted, as a "preview". I understand that the PEP is still a draft.
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.
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).
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.
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.
Activity
jaraco commentedon Jul 23, 2021
Agreed that looks like a bug. Thanks for the report.
jaraco commentedon Jul 23, 2021
@cdce8p Would you be willing to work on a fix?
cdce8p commentedon Jul 24, 2021
@hroncok Thanks for the report, but this isn't a
setuptoolsissue. The second entry is added bywheel.Keep in mind that for
wheelto be able to add license files based on patterns, you need to addlicense_filesto the[metadata]section insetup.cfg, not define in insetup(). That will also add the license file to the.dist-infofolder, once it's matched. For details, please refer to thewheeldocumentation: https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-fileAs for the
License-File:field in theMETADATA: This one isn't in the official packaging spec yet. We only added it because it is useful for other project to be able and easily find the license files form the metadata. There is an effort to make it official, but it will take some more time. Until then, I don't expect wheel to support it.https://www.python.org/dev/peps/pep-0639/#license-file-multiple-use
hroncok commentedon Jul 25, 2021
I kinda expected that setuptools supports PEP 639 before it is accepted, as a "preview". I understand that the PEP is still a draft.
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.hroncok commentedon Jul 25, 2021
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 theLicense-File:entries are incorrect (e.g.3rdparty/license.txt).cdce8p commentedon Jul 25, 2021
If you're referring to the
license_filesargument insetup(), I agree this should be deprecated / removed.That is still a point that needs to be addressed. IMO
wheelneeds to update their implementation here. Although they do mention the behavior in their docs, it can cause name conflicts, e.g., if a file namedLICENSEis present in a sub dir in addition to the main one.In that case
3rdparty/LICENSEwould overwrite the previous one.--
I'm open to suggestions if you have an idea how to better resolve this conflict.
encukou commentedon 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.
abravalheri commentedon Jan 20, 2023
The original problem seems to be already solved with the latest versions of setuptools and wheel:
I think that for the problems regarding name clashes and etc we should wait for PEP 639 implementation.
Fix broken 0.1.1 wheels and LICENSE (#14)