14
14
15
15
import mesonpy
16
16
17
- from .conftest import in_git_repo_context
17
+ from .conftest import in_git_repo_context , metadata
18
18
19
19
20
20
def test_no_pep621 (sdist_library ):
21
21
with tarfile .open (sdist_library , 'r:gz' ) as sdist :
22
- sdist_pkg_info = sdist .extractfile ('library-1.0.0/PKG-INFO' ).read (). decode ()
22
+ sdist_pkg_info = sdist .extractfile ('library-1.0.0/PKG-INFO' ).read ()
23
23
24
- assert sdist_pkg_info == textwrap .dedent ('''\
24
+ assert metadata ( sdist_pkg_info ) == metadata ( textwrap .dedent ('''\
25
25
Metadata-Version: 2.1
26
26
Name: library
27
27
Version: 1.0.0
28
- ''' )
28
+ ''' ))
29
29
30
30
31
31
def test_pep621 (sdist_full_metadata ):
32
32
with tarfile .open (sdist_full_metadata , 'r:gz' ) as sdist :
33
- sdist_pkg_info = sdist .extractfile ('full_metadata-1.2.3/PKG-INFO' ).read (). decode ()
33
+ sdist_pkg_info = sdist .extractfile ('full_metadata-1.2.3/PKG-INFO' ).read ()
34
34
35
- metadata = textwrap .dedent ('''\
35
+ meta = metadata (sdist_pkg_info )
36
+
37
+ # pyproject-metadata prior to 0.9.0 strips trailing newlines
38
+ meta ['license' ] = meta ['license' ].rstrip ()
39
+
40
+ # pyproject-metadata 0.9.0 and later does not emit Home-Page
41
+ meta .pop ('home_page' , None )
42
+ # nor normalizes Project-URL keys
43
+ meta ['project_urls' ] = {k .lower (): v for k , v in meta ['project_urls' ].items ()}
44
+
45
+ assert meta == metadata (textwrap .dedent ('''\
36
46
Metadata-Version: 2.1
37
47
Name: full-metadata
38
48
Version: 1.2.3
39
49
Summary: Some package with all of the PEP 621 metadata
40
50
Keywords: full,metadata,keyword with spaces
41
- Home-page: https://example.com
42
51
Author: Jane Doe
43
52
Author-Email: Unknown <[email protected] >
44
53
Maintainer-Email: Jane Doe <[email protected] >
45
54
License: some license
46
55
Classifier: Development Status :: 4 - Beta
47
56
Classifier: Programming Language :: Python
48
- Project-URL: Homepage , https://example.com
49
- Project-URL: Documentation , https://readthedocs.org
50
- Project-URL: Repository , https://github.com/mesonbuild/meson-python
51
- Project-URL: Changelog , https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst
57
+ Project-URL: homepage , https://example.com
58
+ Project-URL: documentation , https://readthedocs.org
59
+ Project-URL: repository , https://github.com/mesonbuild/meson-python
60
+ Project-URL: changelog , https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst
52
61
Requires-Python: >=3.7
53
62
Requires-Dist: a
54
63
Requires-Dist: b>1
@@ -67,20 +76,18 @@ def test_pep621(sdist_full_metadata):
67
76
# full-metadata
68
77
69
78
An example package with all of the PEP 621 metadata!
70
- ''' )
71
-
72
- assert sdist_pkg_info == metadata
79
+ ''' ))
73
80
74
81
75
82
def test_dynamic_version (sdist_dynamic_version ):
76
83
with tarfile .open (sdist_dynamic_version , 'r:gz' ) as sdist :
77
- sdist_pkg_info = sdist .extractfile ('dynamic_version-1.0.0/PKG-INFO' ).read (). decode ()
84
+ sdist_pkg_info = sdist .extractfile ('dynamic_version-1.0.0/PKG-INFO' ).read ()
78
85
79
- assert sdist_pkg_info == textwrap .dedent ('''\
86
+ assert metadata ( sdist_pkg_info ) == metadata ( textwrap .dedent ('''\
80
87
Metadata-Version: 2.1
81
88
Name: dynamic-version
82
89
Version: 1.0.0
83
- ''' )
90
+ ''' ))
84
91
85
92
86
93
def test_contents (sdist_library ):
0 commit comments