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

Store license-files in licenses subfolder #4728

Merged
merged 3 commits into from
Feb 17, 2025

Conversation

cdce8p
Copy link
Contributor

@cdce8p cdce8p commented Nov 3, 2024

Summary of changes

The initial draft of PEP 639 specified that license files should be written directly to the .dist-info folder. This was changed in later iterations. The files should now be written to .dist-info/licenses and the root folder structure should be recreated to avoid name conflicts.

Additional changes to be spec compliant:

  • Added support for recursive license_files specifier, e.g. **/LICENSE.
  • Normalize License-File path delimiter.

Closes #3596
Refs #4629

@abravalheri abravalheri changed the base branch from main to feature/pep639 February 14, 2025 16:26
@@ -418,7 +418,10 @@ def _finalize_license_files(self) -> None:
patterns = ['LICEN[CS]E*', 'COPYING*', 'NOTICE*', 'AUTHORS*']

self.metadata.license_files = list(
unique_everseen(self._expand_patterns(patterns))
map(
lambda path: path.replace("\\", "/"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use os.sep here instead of \\ (e.g. if somehow \\ ends showing up on a linux build, we want the build to crash right, because it would mean incorrect input from the user)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that's necessary here. path isn't a user input but rather the glob matched license path from self._expand_patterns. The idea with this line is just to normalize the separator since the core metadata field only allows forward /.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about valid paths in linux containing \? (e.g. mkdir 'hello\world' && touch 'hello\world/LICENSE.txt')... It is a bit of a problematic choice if the user decides to do that, but os.sep would be less error prone in that case, right?

Copy link
Contributor Author

@cdce8p cdce8p Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I've ever seen that in the wild but you're right it's a possibility. Pushed 3e9b9c7 to use os.sep instead.

@abravalheri abravalheri mentioned this pull request Feb 17, 2025
6 tasks
@abravalheri abravalheri merged commit 62fab41 into pypa:feature/pep639 Feb 17, 2025
22 of 24 checks passed
@abravalheri
Copy link
Contributor

Thank you!

@cdce8p cdce8p deleted the license-files branch February 17, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Support License-File root license directory (PEP 639)
2 participants