@@ -749,14 +749,14 @@ def __init__(
749
749
# set version from meson.build if version is declared as dynamic
750
750
if 'version' in self ._metadata .dynamic :
751
751
version = self ._meson_version
752
- if version == 'undefined' :
752
+ if version is None :
753
753
raise pyproject_metadata .ConfigurationError (
754
754
'Field "version" declared as dynamic but version is not defined in meson.build' )
755
755
self ._metadata .version = packaging .version .Version (version )
756
756
else :
757
757
# if project section is missing, use minimal metdata from meson.build
758
758
name , version = self ._meson_name , self ._meson_version
759
- if version == 'undefined' :
759
+ if version is None :
760
760
raise pyproject_metadata .ConfigurationError (
761
761
'Section "project" missing in pyproject.toml and version is not defined in meson.build' )
762
762
self ._metadata = Metadata (name = name , version = packaging .version .Version (version ))
@@ -870,17 +870,19 @@ def _manifest(self) -> DefaultDict[str, List[Tuple[pathlib.Path, str]]]:
870
870
871
871
@property
872
872
def _meson_name (self ) -> str :
873
- """Name in meson.build."""
874
- name = self ._info ('intro-projectinfo' )['descriptive_name' ]
875
- assert isinstance (name , str )
876
- return name
873
+ """The project name specified with ``project()`` in meson.build."""
874
+ value = self ._info ('intro-projectinfo' )['descriptive_name' ]
875
+ assert isinstance (value , str )
876
+ return value
877
877
878
878
@property
879
- def _meson_version (self ) -> str :
880
- """Version in meson.build."""
881
- name = self ._info ('intro-projectinfo' )['version' ]
882
- assert isinstance (name , str )
883
- return name
879
+ def _meson_version (self ) -> Optional [str ]:
880
+ """The version specified with the ``version`` argument to ``project()`` in meson.build."""
881
+ value = self ._info ('intro-projectinfo' )['version' ]
882
+ assert isinstance (value , str )
883
+ if value == 'undefined' :
884
+ return None
885
+ return value
884
886
885
887
def sdist (self , directory : Path ) -> pathlib .Path :
886
888
"""Generates a sdist (source distribution) in the specified directory."""
0 commit comments