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

allow to include license text file in the wheel metadata #829

Closed
anthrotype opened this issue Mar 4, 2022 · 9 comments · Fixed by #836 or #837
Closed

allow to include license text file in the wheel metadata #829

anthrotype opened this issue Mar 4, 2022 · 9 comments · Fixed by #836 or #837
Labels
enhancement New feature or request

Comments

@anthrotype
Copy link

the official wheel package (used by setuptools' bdist_wheel) has a handy license_files option (defined in setup.cfg [metadata] section) that allows one to list the license file paths to be included in the generated wheel.

https://wheel.readthedocs.io/en/stable/user_guide.html?highlight=license_files#including-license-files-in-the-generated-wheel-file

Some OSS licenses require one to include the license text along with distributed binaries.

I couldn't find a way to achive this when using maturin. Is it possible to add support for this?

thank you for considering.

@anthrotype anthrotype added the enhancement New feature or request label Mar 4, 2022
@anthrotype anthrotype changed the title allow to include license file in the wheel metadata allow to include license text file in the wheel metadata Mar 4, 2022
@messense
Copy link
Member

messense commented Mar 5, 2022

I think you can use the license field defined in PEP 621: https://maturin.rs/metadata.html

@anthrotype
Copy link
Author

oh I didn't know that, thanks! Will that copy the full text of the license file to the wheel .dist-info?

@anthrotype
Copy link
Author

ok I just tried, I see it copied the full LICENSE text to the METADATA file, not as a separate LICENSE file. That's fine by me. Thank you!

@anthrotype anthrotype reopened this Mar 7, 2022
@anthrotype
Copy link
Author

actually I'm having issues embedding the full text of the LICENSE file when running on Windows.
When I use license = {file = LICENSE.txt}, the LICENSE.txt full text is copied to the METADATA file as a multi-line RFC5322 string separated by CRLF, but on Windows I get CRLF twice and that breaks parsing the following README section.

E.g. download the dist.zip file from here, and try to run twine check pngquant_cli-2.17.0.post2-py3-none-win32.whl. I get this FAIL error:

Checking /Users/clupo/Downloads/dist (8)/pngquant_cli-2.17.0.post2-py3-none-win32.whl: FAILED
  `long_description` has syntax errors in markup and would not be rendered on PyPI.
    line 1335: Warning: Block quote ends without a blank line; unexpected unindent.

If I do the same for the other non-Windows wheels (e.g. the mac or linux ones in the same archive), it works. They differ only by their line endings.

@messense
Copy link
Member

messense commented Mar 8, 2022

@anthrotype Thanks for the report, I'll look into it soon.

anthrotype added a commit to anthrotype/pngquant-wheels that referenced this issue Mar 8, 2022
maturing has issues embedding license full text in the wheels so for now we do it ourselves.
PyO3/maturin#829
anthrotype added a commit to anthrotype/pngquant-wheels that referenced this issue Mar 8, 2022
maturing has issues embedding license full text in the wheels so for now we do it ourselves.
PyO3/maturin#829

There's another problem using wheeltools on windows (it creates zip files with backslashes...) so I run this on Linux after all the wheels have been built.
@messense
Copy link
Member

messense commented Mar 8, 2022

@anthrotype Can you try #836 ? Released in v0.12.10-beta.8.

@anthrotype
Copy link
Author

anthrotype commented Mar 9, 2022

thanks! The windows wheels now pass twine check.
However, I noticed that when I upload it to PyPI, it shows the full text of the license under the section named "Meta" at the lower left corner, but it loses all line breaks and formatting, it's like it's on a single very long line of uninterrupted text: e.g.
https://pypi.org/project/pngquant-cli/2.17.1b1/

What the wheel module does (when building a wheel with setup.py bdist_wheel command) is adding the license file as its own separate text file inside .dist-info directory. The name of the license is what the setup.py's license keyword contains, then the LICENSE.txt file contains the actual license full text and is automatically included in the sdist manifest. Then bdst_wheel can be configured (via setup.cfg's license_files) to include the license files in the distribution.

Would it be possible for maturin to distinguish between the license parameter (being the name or short line describing a license) and the license_files pointing to the paths of the files to be added to the wheel dist-info?

@messense messense reopened this Mar 10, 2022
@messense
Copy link
Member

@anthrotype Opened #837 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants