Repository navigation
MAINT: require pyproject-metadata 0.10.0 - #939
CAOShurong wants to merge 5 commits into
Conversation
|
We don't do similar checks for other metadata fields (PEP 639 |
|
@dnicolodi what do you think about just dropping 0.9.0? 0.10.0 is over a year old by now, and there's no reason (unlike for our |
|
I do not see any reason to do not bump the required |
Raise the build and runtime minimum to the first release that supports PEP 794. Align the CI minimums and keep the metadata 2.5 regression.
I would say yes, that needs an exception with a clear message. Either an unclear exception or metadata silently going missing seems like a usability issue to me. |
|
Modulo commit history that is, since we normally rebase-merge and require a clean commit history. We can squash-merge though I think. Keyword validation is no longer relevant for this PR given the >=1.10.0 bump, but it may be a separate thing to follow up on (I didn't check). |
|
|
||
|
|
||
| def test_import_metadata_rfc822(): | ||
| data = {'project': { | ||
| 'name': 'test', | ||
| 'version': '1.0.0', | ||
| 'import-names': ['shared.example'], | ||
| 'import-namespaces': ['shared'], | ||
| }} | ||
| metadata = Metadata.from_pyproject(data).as_rfc822() | ||
| assert metadata['Metadata-Version'] == '2.5' | ||
| assert metadata.get_all('Import-Name') == ['shared.example'] | ||
| assert metadata.get_all('Import-Namespace') == ['shared'] |
There was a problem hiding this comment.
This should be dropped: we have no interest in validating pyproject-metadata correctness.
There was a problem hiding this comment.
I suggested that at #809 (comment). And we're doing this kind of test in multiple places already (just search for Metadata-Version), so I don't think this comment is right. It's in the end the artifact we produce, and it's useful to have one test per feature. It should work regardless of whether we call pyproject-metadata, packaging in the future (if the functionality gets upstreamed), or rework it in some other way.
There was a problem hiding this comment.
Removed the direct parser test in 06bf3fd. The replacement builds a wheel and checks Import-Name and Import-Namespace in its .dist-info/METADATA.
There was a problem hiding this comment.
And we're doing this kind of test in multiple places already (just search for
Metadata-Version), so I don't think this comment is right.
The tests I could find verify metadata compilation by meson-python (handling of dynamic metadata, presence of license files, etc..). The test added here does not test anything implemented by meson-python. However, we can keep it, if you think it is useful.
My general policy for tests is that at least one of tho things need to be true for making a test worth having:
- can the project carrying the test fix something if the test starts failing?
- can the project carrying the test do introduce a change that can make the test fail?
In the case at hand, I think the answer is no to both questions. Thus I think the test is redundant.
There was a problem hiding this comment.
The test got already adapted in the meantime; I think we can figure out the optimal form here (I don't think a whole new test package is it), but I do think we need one test for import-names and import-namespaces. It's a feature build backend support, and we want to get signal if it'd stop working.
I think adding these keys to an existing test package (TBD which one) and updating the expected Core Metadata version and content would be reasonable?
I'd also write it in a single assert rather than three separate ones, a la:
meson-python/tests/test_wheel.py
Lines 137 to 143 in 32cdb09
There was a problem hiding this comment.
Switched the test to the existing module-types package in 8aeb43d. It now checks the complete wheel metadata in one assertion, including the native module and the namespace package. The separate fixture is gone.
| # Older packaging releases return PEP 794 headers as unparsed fields. | ||
| for header, field in (('import-name', 'import_names'), ('import-namespace', 'import_namespaces')): | ||
| if header in other: | ||
| meta[field] = other.pop(header) |
There was a problem hiding this comment.
This handles older versions of packaging in the wheel test. On the same wheel, parse_email() in 23.2, 24.2 and 25.0 returns Import-Name and Import-Namespace in the unparsed mapping, so the helper would fail at assert not other. In 26.0 it recognizes both. The loop keeps all four import names and the namespace for the metadata assertion, like the PEP 639 handling above it.
There was a problem hiding this comment.
That's not the way to handle this - just skip the test instead if the packaging version is too old, same as for a meson version that's too old:
meson-python/tests/test_wheel.py
Line 167 in 32cdb09
There was a problem hiding this comment.
I think that having to add the handling of these fields here may be due to having added the test for PEP 794 to an existing test package. Otherwise, it is not needed at all, because the added test checks for the METADATA file to have some specific content, without parsing it.
The best way to do add the test is IMO to use a synthetic test package, like done in #923.
There was a problem hiding this comment.
Sorry, I misread the test code. The test code parses the METADATA file. Therefore the parsing would need to be updated. However, skipping the test on too old packaging as @rgommers suggested is a better solution.
There was a problem hiding this comment.
Removed the compatibility loop in dff3fbd. The import-name test now skips with packaging older than 26.0. With 26.0, the real module-types wheel still passes the full METADATA assertion. The Windows wheel suite passed with both 23.2 and 26.0.
Fixes #809.
Raise the build and runtime minimum to
pyproject-metadata0.10.0, the first release that readsimport-namesandimport-namespaces. Align the CI and Pixi constraints and keep the regression test for the Core Metadata 2.5 headers.Verified five wheel builds on Windows with
pyproject-metadata0.10.0 andpackaging23.2, covering explicit import names and namespaces, an empty import-name list, and license metadata. The built backend installs with 0.10.0 and 0.12.1. The dependency resolver rejects 0.9.0.