File tree Expand file tree Collapse file tree 6 files changed +51
-2
lines changed Expand file tree Collapse file tree 6 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -734,10 +734,18 @@ def __init__( # noqa: C901
734
734
self ._metadata = Metadata .from_pyproject (pyproject , self ._source_dir )
735
735
# set version from meson.build if version is declared as dynamic
736
736
if 'version' in self ._metadata .dynamic :
737
- self ._metadata .version = packaging .version .Version (self ._meson_version )
737
+ version = self ._meson_version
738
+ if version == 'undefined' :
739
+ raise pyproject_metadata .ConfigurationError (
740
+ 'Field "version" declared as dynamic but version is not defined in meson.build' )
741
+ self ._metadata .version = packaging .version .Version (version )
738
742
else :
739
743
# if project section is missing, use minimal metdata from meson.build
740
- self ._metadata = Metadata (name = self ._meson_name , version = packaging .version .Version (self ._meson_version ))
744
+ name , version = self ._meson_name , self ._meson_version
745
+ if version == 'undefined' :
746
+ raise pyproject_metadata .ConfigurationError (
747
+ 'Section "project" missing in pyproject.toml and version is not defined in meson.build' )
748
+ self ._metadata = Metadata (name = name , version = packaging .version .Version (version ))
741
749
742
750
# verify that we are running on a supported interpreter
743
751
if self ._metadata .requires_python :
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2023 The meson-python developers
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ project (' missing-dynamic-version' )
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2023 The meson-python developers
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ [build-system ]
6
+ build-backend = ' mesonpy'
7
+ requires = [' meson-python' ]
8
+
9
+ [project ]
10
+ name = ' missing-dynamic-version'
11
+ dynamic = [' version' ]
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2023 The meson-python developers
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ project (' missing-meson-version' )
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2023 The meson-python developers
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ [build-system ]
6
+ build-backend = ' mesonpy'
7
+ requires = [' meson-python' ]
Original file line number Diff line number Diff line change @@ -64,6 +64,19 @@ def test_missing_version(package_missing_version):
64
64
with mesonpy .Project .with_temp_working_dir ():
65
65
pass
66
66
67
+
68
+ def test_missing_meson_version (package_missing_meson_version ):
69
+ with pytest .raises (pyproject_metadata .ConfigurationError , match = 'Section "project" missing in pyproject.toml' ):
70
+ with mesonpy .Project .with_temp_working_dir ():
71
+ pass
72
+
73
+
74
+ def test_missing_dynamic_version (package_missing_dynamic_version ):
75
+ with pytest .raises (pyproject_metadata .ConfigurationError , match = 'Field "version" declared as dynamic but' ):
76
+ with mesonpy .Project .with_temp_working_dir ():
77
+ pass
78
+
79
+
67
80
def test_user_args (package_user_args , tmp_path , monkeypatch ):
68
81
project_run = mesonpy .Project ._run
69
82
cmds = []
You can’t perform that action at this time.
0 commit comments