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

Fix "Wheel naming is not following PEP 491 convention" #4766

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

di
Copy link
Member

@di di commented Dec 10, 2024

Summary of changes

Fixes #3777.

Marking this as draft as there is one outstanding failing test that I have been unable to resolve (setuptools/tests/test_easy_install.py::TestSetupRequires::test_setup_requires_override_nspkg).

Pull Request Checklist

@abravalheri
Copy link
Contributor

Thank you!

The failing test seems to be happening now regardless of this change: https://github.com/pypa/setuptools/actions/runs/12298183072/job/34321035714#step:3:49.

I don't know if anything changed in the latest versions of Python being distributed to macOS, so that __file__ is no longer available on the scope.

@di
Copy link
Member Author

di commented Dec 12, 2024

Aha, that's a different failure actually, setuptools/tests/test_easy_install.py::TestSetupRequires::test_setup_requires_override_nspkg is the test that is legitimately failing and would need to be updated here.

@abravalheri
Copy link
Contributor

setuptools/tests/test_easy_install.py::TestSetupRequires::test_setup_requires_override_nspkg is the test that is legitimately failing and would need to be updated here.

This looks like it is checking deprecated functionality? Not sure we have to account such an edge case since we are moving away from easy_install. Maybe we can do a major bump to show that the change may be considered a breaking change.

@di
Copy link
Member Author

di commented Dec 12, 2024

I'm not sure! I think the test is just broken in a way I haven't been able to figure out (it mixes the distribution name and the namespace name as one thing in the helper functions) but I think the underlying functionality probably still works?

@di
Copy link
Member Author

di commented Jan 9, 2025

All tests are passing, this is now ready for review.

@di di marked this pull request as ready for review January 9, 2025 22:55
Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

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

It doesn't make me happy to approve this change, but I've conceded the fight. Let's align with the spec.

Comment on lines 137 to 143
return (
# Per https://packaging.python.org/en/latest/specifications/name-normalization/#name-normalization
re.sub(r"[-_.]+", "-", safe_name(name))
.lower()
# Per https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode
.replace("-", "_")
)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of this duplicated code being further expanded. I'd like to see this logic consolidated (in setuptools if not in something like packaging), especially since now it's more than one line that's being duplicated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved in 9f764e8.

Comment on lines 1123 to 1125
# The project name might not contain periods. Replace dashes and
# underscores with periods before constructing the namespace.
namespace = distname.replace('-', '.').replace('_', '.')
Copy link
Member

Choose a reason for hiding this comment

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

This seems slightly terrible. Is this helper called with a normalized distname, in which case it's not possible to know what the separators are? Is it always called with a normalized distname, or is it called with the specified distribution name? This function, if called with more-itertools will produce a namespace package for more. I guess I can see from the previous implementation that it always assumes there's a single namespace component at the front.

Still, the previous implementation would have accepted j_o.foo and produced a namespace package j_o, but this new implementation will get j-o-foo and produce a namespace packgae j.

More importantly, however, I notice that setuptools.setup is being called with name={distname}. In that case, {distname} should not be normalized and should contain the periods.

I think this change is a mistake, and instead, this function should require that distname contain at least one period.

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved in 8795306, ae5df97 and 1ec0c91.

foobar_1_archive = os.path.join(temp_dir, 'foo.bar-0.1.tar.gz')
make_nspkg_sdist(foobar_1_archive, 'foo.bar', '0.1')
foobar_1_archive = os.path.join(temp_dir, 'foo_bar-0.1.tar.gz')
make_nspkg_sdist(foobar_1_archive, 'foo_bar', '0.1')
Copy link
Member

Choose a reason for hiding this comment

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

Per the comment in make_nspkg_sdist, distname should be foo.bar.

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved in 8795306.

@di di requested a review from jaraco January 27, 2025 16:38
@di
Copy link
Member Author

di commented Jan 29, 2025

This is ready for re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Wheel naming is not following PEP 491 convention
3 participants