-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Include license files in built distribution #18298
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
Conversation
Thanks @johnthagen ! |
I'm no expert on setup tools, so I guess the question is if this is canonical or if |
@jklymak This brings up a good point, in the source dist (.tar.gz file), the But they are not included in any of the wheel distributions. The subfolder is an important note though. I'll check if |
Yeah it was a comment from complete ignorance. It just seems we can't be the only project that has a sub directory? Not at all objecting to this PR though. |
From what I can tell, after matplotlib is installed, currently the LICENSEs don't end up in I think that I'm going to try to test the branch out with the sdist. |
Well, it looks like perhaps So while the LICENSE files are included in the I think this should work for wheels though, which is the default install most users will use. Another option is to put multiple LICENSE files in the root of the project. |
I am 👎 on moving the license files around or merging them into one file. There are already a bunch of tools out there that expect them to be where they are. If setuptools / wheel can not cope with this we should push back on that being an upstream bug. |
So after some further investigation, I've now realized that this will need to be fixed via [metadata]
license_files = LICENSE/* This was the only way that actually got the LICENSE files into the wheel. The important reading:
I moved this PR to a Draft since I don't want to merge this as is as it doesn't actually solve the problem (sorry for not realizing this earlier). matplotlib has a I tested locally on macOS and with the |
…ull LICENES files into built wheel
In my view the fact that matplotlib reuses setup.cfg for its own purposes, even though it's really here for setuptools (distutils), is a minor but real annoyance (see e.g. the hacky |
Can you also add a line to https://github.com/matplotlib/matplotlib/blob/master/.github/workflows/cibuildwheel.yml to copy the template over when we build the wheels? |
@tacaswell Done. First time working with GitHub actions though. Is there a way to look at the built wheels for this PR so I can validate the LICENSE files made it in? |
I don't think we build wheels on every PR, but it is probably worth adding a job to travis or azure to build the wheel and check if the licences are in it to make sure we don't break this in the future. You can also add a check after we run the ciwheel build in the GH actions to not publish wheels without the license. |
Wheels are currently built on |
For reference, the LICENSE files will be in:
|
The simplest way I've found to check if the LICENSE files are being added to the wheel is:
This will return success/0 if the LICENSE files were added and failure/1 if not. This method may be a little brittle though as it relies on the stdout of |
Here is a Python script that will check if the LICENSE files are in the #!/usr/bin/env python3
"""Check that all .whl files in the dist folder have the correct LICENSE files included."""
from pathlib import Path
import sys
import zipfile
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
LICENSE_FILE_NAMES = [
'LICENSE',
'LICENSE_AMSFONTS',
'LICENSE_BAKOMA',
'LICENSE_CARLOGO.txt',
'LICENSE_COLORBREWER',
'LICENSE_QT4_EDITOR',
'LICENSE_STIX',
'LICENSE_YORICK',
]
def main() -> int:
dist_dir = Path(__file__).parent / 'dist'
for wheel in dist_dir.glob('*.whl'):
with zipfile.ZipFile(wheel) as f:
license_file_names = [Path(path).name for path in sorted(f.namelist())
if '.dist-info/LICENSE' in path]
if license_file_names != LICENSE_FILE_NAMES:
return EXIT_FAILURE
return EXIT_SUCCESS
if __name__ == '__main__':
sys.exit(main()) |
That script could be put in |
@QuLogic I have updated the files as requested. GitHub Actions now has a step that validates that LICENSE files has been included in all built wheels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks great @johnthagen
Co-authored-by: Elliott Sales de Andrade <[email protected]>
I applied @QuLogic's latest suggestion, good catch. I believe this PR is ready for final review/merge. |
…298-on-v3.3.x Backport PR #18298 on branch v3.3.x (Include license files in built distribution)
PR Summary
Closes #18296
wheel
to include LICENSE filesSolarized.txt
as there is no way for a tool likepip-licenses
to glob for LICENSE file named that way that doesn't start withLICENSE
Note:
wheel >= 0.32.0
is needed for this option to be honored.PR Checklist