Skip to content

Conversation

@notatallshaw
Copy link
Member

@notatallshaw notatallshaw commented Jan 15, 2026

Packaging 26.0 is coming out shortly. Here's a blog on some of the performance improvements: https://iscinumpy.dev/post/packaging-faster/.

As part of this release a lot of internal objects were changed or removed, @henryiii noticed that dropping ._version in pypa/packaging#995 causes failures in hatch (specifically I found it breaks bumping via hatch version), and has added a compatibility layer with a deprecation warning in pypa/packaging#1062.

This PR does the following:

  • Bumps packaging 26 to the minimum version of packaging
  • Replaces reset_version_parts with calls to the new __replace__ API: feat: support __replace__ for Version packaging#1003
  • Fixes the various formatting changes that packaging has made to better comply with the spec / vendor a newer version of spdx

I've raised this PR in draft to see if this is the direction maintainers want to go in, and waiting on packaging 26.0 final (expected Monday). Let me know any feedback or questions.

@henryiii
Copy link
Contributor

IMO, partially due to the fact that pip's build isolation is actually a hack and doesn't work correctly, a range of packaging needs to be supported. Otherwise, system libraries can leak in even when you've installed something newer in the fake build env.

@notatallshaw
Copy link
Member Author

I could loosen hatchling's requirements, as I don't think this code is ever called by the build process. Or could just rework into a different approach.

@notatallshaw notatallshaw force-pushed the use-`__replace__`-to-get-new-packaging-Versions branch from 081466e to 045f919 Compare January 16, 2026 15:54
@notatallshaw notatallshaw changed the title Update packaging to 26.0 and apply fixes Update to work with packaging to 26.0 Jan 16, 2026
@notatallshaw
Copy link
Member Author

Okay I've made the following changes:

  • No longer bumped packaging requirement, this means tests will fail until packaging 26.0 is released.
  • Kept reset_version_parts, but now it returns a Version object as part of it's API, it uses __replace__ when available, otherwise it uses the existing logic to minimize the chances of problems.

Once packaging 26.0 is out and tests pass again I may need to also fix coverage tests.

Question, does hatch expect this function is internal only or other projects are depending on it? As now on packaging 26.0 it will not mutate the underlying Version object, which may break expectations if there are dependencies on it? I could make a new function that hatch depends on, and wrap the old function in a deprecation warning the same as was done in packaging: https://github.com/pypa/packaging/pull/1062/files

@notatallshaw notatallshaw changed the title Update to work with packaging to 26.0 Fix warning and tests with packaging 26.0 Jan 16, 2026
@henryiii
Copy link
Contributor

Looks better! One downside is the spacing changes mean that you can't run tests against an older packaging. Not sure if that's a problem here; if it is the tests could be made to ignore whitespace or replacement could be used (table will be a little harder. CC @ofek or @cjames23, no real rush though as it will still work with 26.0, just tests will fail with spacing changes and maybe warnings.

@cjames23
Copy link
Member

Question, does hatch expect this function is internal only or other projects are depending on it?

This should be internal only but I can check some of the known plugins to see if anyone was utilizing this function

@notatallshaw
Copy link
Member Author

if it is the tests could be made to ignore whitespace or replacement could be used

Happy to do this is requirements by maintainers, not going to start making changes like that to the test suite on my own.

Some of the tests would be easy to fix by using str(Requirement("baz@file:///path/to/project")), but as I can't fix all of them like that not sure what the point is.

And if tests are fine to run on just the latest packaging we can wait until 26.0 releases next week.

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.

3 participants