Skip to content

Conversation

cdce8p
Copy link
Member

@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
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
Member 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
Member 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!

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