@@ -535,9 +535,14 @@ def test_invalid_module_name(self, tmp_path, monkeypatch, module):
535535
536536
537537class TestExtModules :
538+ def make_dist (self , toml_config ):
539+ pyproject = Path ("pyproject.toml" )
540+ pyproject .write_text (cleandoc (toml_config ), encoding = "utf-8" )
541+ with pytest .warns (pyprojecttoml ._ExperimentalConfiguration ):
542+ return pyprojecttoml .apply_configuration (Distribution ({}), pyproject )
543+
538544 def test_pyproject_sets_attribute (self , tmp_path , monkeypatch ):
539545 monkeypatch .chdir (tmp_path )
540- pyproject = Path ("pyproject.toml" )
541546 toml_config = """
542547 [project]
543548 name = "test"
@@ -547,13 +552,28 @@ def test_pyproject_sets_attribute(self, tmp_path, monkeypatch):
547552 {name = "my.ext", sources = ["hello.c", "world.c"]}
548553 ]
549554 """
550- pyproject .write_text (cleandoc (toml_config ), encoding = "utf-8" )
551- with pytest .warns (pyprojecttoml ._ExperimentalConfiguration ):
552- dist = pyprojecttoml .apply_configuration (Distribution ({}), pyproject )
555+ dist = self .make_dist (toml_config )
553556 assert len (dist .ext_modules ) == 1
554557 assert dist .ext_modules [0 ].name == "my.ext"
555558 assert set (dist .ext_modules [0 ].sources ) == {"hello.c" , "world.c" }
556559
560+ def test_pyproject_define_macros_as_tuples (self , tmp_path , monkeypatch ):
561+ # https://github.com/pypa/setuptools/issues/4810
562+ monkeypatch .chdir (tmp_path )
563+ toml_config = """
564+ [project]
565+ name = "test"
566+ version = "42.0"
567+ [[tool.setuptools.ext-modules]]
568+ name = "my.ext"
569+ sources = ["hello.c", "world.c"]
570+ define-macros = [["FIRST_SINGLE"], ["SECOND_TWO", "1"]]
571+ """
572+ dist = self .make_dist (toml_config )
573+ assert isinstance (dist .ext_modules [0 ].define_macros [0 ], tuple )
574+ assert dist .ext_modules [0 ].define_macros [0 ] == ("FIRST_SINGLE" ,)
575+ assert dist .ext_modules [0 ].define_macros [1 ] == ("SECOND_TWO" , "1" )
576+
557577
558578class TestDeprecatedFields :
559579 def test_namespace_packages (self , tmp_path ):
0 commit comments