Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build-backend/pex_build/hatchling/metadata_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def update(self, metadata):
file=sys.stderr,
)
metadata["requires-python"] = requires_python
else:
metadata["requires-python"] = ">=2.7,<3.13,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*"

expand = self.config.get("expand")
if expand:
Expand Down
12 changes: 2 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
# entry point metadata so the hook is discovered.
backend-path = ["build-backend"]
build-backend = "pex_build.hatchling.build"

# The hatchling 1.22.0 release breaks our build in several ways:
# + Our console scripts are no longer generated.
# + The `project.readme` pyproject.toml key now has its value hydrated before our metadata plugin
# runs, which foils our metadata expansion since our README.rst contains inadvertant expansion
# tokens.
# This pin low buys time to work through the issues.
requires = ["hatchling<1.22.0"]
requires = ["hatchling"]

[tool.hatch.metadata.hooks.pex-adjust-metadata]
expand = {"pex_version" = "version"}
Expand All @@ -22,8 +15,7 @@ expand = {"pex_version" = "version"}

[project]
name = "pex"
dynamic = ["version"]
requires-python = ">=2.7,<3.13,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*"
dynamic = ["version", "requires-python"]
Copy link
Copy Markdown
Member

@jsirois jsirois May 8, 2024

Choose a reason for hiding this comment

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

If this is now required I'm not a fan. The intent is to record the real requires-python here in the static metadata and only override in some CI tests when testing out Python 3.X alpha releases. Moving the real metadata to the metadata_hook obscures a bit too much for my liking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue is that the spec says that tools must adhere to what is defined statically (e.g. they cannot be changed) and Hatchling had a bug that it was not enforcing that.

If you would prefer I can add an option to enable that unsafe behavior but it would be bad for the ecosystem. What do you think?

FYI here is a comment that explains a little bit https://discuss.python.org/t/respecting-core-metadata-2-2-when-building-from-source-distributions/48886/60

It's not exactly related but the bug was revealed during that discussion/thread.

Copy link
Copy Markdown
Member

@jsirois jsirois May 8, 2024

Choose a reason for hiding this comment

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

Well, I think PyPA itself is bad for the ecosystem! I'm neck deep in packaging maintaining Pex and I lost patience long ago. I'd rather you not distort your tool for this case and thus continue the trail of tears. Let me step back and consider how to handle this given the thread you pointed to. I won't be back to a keyboard for a few days, but I'll circle back here then and let you know how I'd like to proceed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, I think I grok the thread you pointed me to. IIUC the criux lies in PEP-621 under https://peps.python.org/pep-0621/#dynamic:

  • Build back-ends MUST raise an error if the metadata specifies a field statically as well as being listed in dynamic.

If that were, instead:

* When a field is specified statically as well as marked dynamic, its value must be obtained from the backend dynamic generation process.

All would be well.

@ofek I'll send up a PR and add you as a reviewer that sortof acheives the end I want here using non-canonical fields in pyproject.toml to carry the static metadata / template metadata. That PR may contain comments about the PyPA that you want no association with; so feel free to not comment if you're uncomfortable!

Thanks for hunting down users affected by your rocky release period though, I really appreciate it.

authors = [
{name = "The PEX developers", email="developers@pex-tool.org"}
]
Expand Down