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

ENH: add support for dynamic dependencies computation #319

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dnicolodi
Copy link
Member

@dnicolodi dnicolodi commented Feb 23, 2023

When dependencies is specified as a dynamic field in the [project] section in pyproject.toml, the dependencies reported for the sdist are copied from the dependencies field in the [tool.meson-python] section. More importantly, the dependencies reported for the wheels are computed combining this field and the "build-time-pins" field in the same section completed with the build time version information.

The dependencies and build-time-pins fields in the [tool.meson-python] section accept the standard metadata
dependencies syntax as specified in PEP 440. The build-time-pins field cannot contain markers or extras but it is expanded as a format string where the v variable is bound to the version of the package to which the dependency requirements applies present at the time of the build parsed as a packaging.version.Version object.

This is based on #304 to incorporate the metadata handling simplification introduced there.

This ass a dependency on importlib_metatada for Python 3.7. In principle it could be made conditional to the use of build-time-pins but I don't think it is worth the trouble. It also adds a dependency on packaging, but it is already a transitive dependency of meson-python via the pyproject_metadata dependency.

@dnicolodi dnicolodi marked this pull request as draft February 23, 2023 22:05
@dnicolodi dnicolodi force-pushed the dynamic-dependencies branch 2 times, most recently from 7c02c7f to 3617eba Compare February 23, 2023 22:15
Copy link
Member

@FFY00 FFY00 left a comment

Choose a reason for hiding this comment

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

This approach is not enough. You need to be able to match versions with more than 3 parts on the release field.

Let's discuss this on the issue first. I had written a reply to you and Ralf, but I've been trying to put all my thoughts down regarding this in a document, so I haven't submitted it yet. Some more discussion happened, so I'll probably have to rewrite my reply, but please just wait for my reply there.

@dnicolodi
Copy link
Member Author

dnicolodi commented Feb 23, 2023

I just wanted to experiment with how this would look like in practice. Working on this made me realize that I didn't completely understand the problem.

Matching version with more than three components is an easy fix. Added. You can use {v.major}.{v.minor}.{v.micro}.{v[3]}.{v[4]}. It is not pretty, but that's what you get for using crazy version numbers.

@FFY00 FFY00 added the enhancement New feature or request label Mar 1, 2023
@dnicolodi dnicolodi force-pushed the dynamic-dependencies branch 13 times, most recently from f5c992d to 4af1454 Compare March 4, 2023 10:11
@dnicolodi dnicolodi marked this pull request as ready for review March 4, 2023 10:12
@dnicolodi dnicolodi force-pushed the dynamic-dependencies branch 4 times, most recently from 824217e to 57d4e49 Compare March 12, 2023 20:26
@FFY00 FFY00 marked this pull request as draft March 14, 2023 03:05
@FFY00
Copy link
Member

FFY00 commented Mar 14, 2023

I converted the PR to draft while we wait for a resolution in #29, so that the state of PR log is easier to understand. @dnicolodi I hope that is okay.

Once we get a decision on the issue, we can go ahead with a proper review and merge of this PR :)

To support "dependencies" as a dynamic filed in pyproject.toml and
implement build time dependencies pins we need to rewrite this part of
the metadata in the wheel builder. Move the RFC 822 serialization of
the metadata closer to where it is written to the wheel archive.
@dnicolodi dnicolodi force-pushed the dynamic-dependencies branch 2 times, most recently from f0cd7a6 to ef3d287 Compare March 22, 2023 22:37
Move to stand-alone function for clarity and to enable unit testing.
When "dependencies" is specified as a dynamic field in the "[project]"
section in pyproject.toml, the dependencies reported for the sdist are
copied from the "dependencies" field in the "[tool.meson-python]"
section. More importantly, the dependencies reported for the wheels
are computed combining this field and the "build-time-pins" field in
the same section completed with the build time version information.

The "dependencies" and "build-time-pins" fields in the
"[tool.meson-python]" section accept the standard metadata
dependencies syntax as specified in PEP 440. The "build-time-pins"
field cannot contain markers or extras but it is expanded as a format
string where the 'v' variable is bound to the version of the package
to which the dependency requirements applies present at the time of
the build parsed as a packaging.version.Version object.
It is not possible to define a universally useful semantic for
build-time pins involving pre-releases. Do not generate them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants