@@ -297,6 +297,33 @@ def test_default_patterns(self, tmp_path):
297
297
assert set (dist .metadata .license_files ) == {* license_files , "LICENSE.txt" }
298
298
299
299
300
+ class TestPyModules :
301
+ # https://github.com/pypa/setuptools/issues/4316
302
+
303
+ def dist (self , name ):
304
+ toml_config = f"""
305
+ [project]
306
+ name = "test"
307
+ version = "42.0"
308
+ [tool.setuptools]
309
+ py-modules = [{ name !r} ]
310
+ """
311
+ pyproject = Path ("pyproject.toml" )
312
+ pyproject .write_text (cleandoc (toml_config ), encoding = "utf-8" )
313
+ return pyprojecttoml .apply_configuration (Distribution ({}), pyproject )
314
+
315
+ @pytest .mark .parametrize ("module" , ["pip-run" , "abc-d.λ-xyz-e" ])
316
+ def test_valid_module_name (self , tmp_path , monkeypatch , module ):
317
+ monkeypatch .chdir (tmp_path )
318
+ assert module in self .dist (module ).py_modules
319
+
320
+ @pytest .mark .parametrize ("module" , ["pip run" , "-pip-run" , "pip-run-stubs" ])
321
+ def test_invalid_module_name (self , tmp_path , monkeypatch , module ):
322
+ monkeypatch .chdir (tmp_path )
323
+ with pytest .raises (ValueError , match = "py-modules" ):
324
+ self .dist (module ).py_modules
325
+
326
+
300
327
class TestDeprecatedFields :
301
328
def test_namespace_packages (self , tmp_path ):
302
329
pyproject = tmp_path / "pyproject.toml"
0 commit comments