@@ -314,9 +314,6 @@ def test_license_in_metadata(
314314
315315
316316class TestLicenseFiles :
317- # TODO: After PEP 639 is accepted, we have to move the license-files
318- # to the `project` table instead of `tool.setuptools`
319-
320317 def base_pyproject (self , tmp_path , additional_text ):
321318 pyproject = _pep621_example_project (tmp_path , "README" )
322319 text = pyproject .read_text (encoding = "utf-8" )
@@ -329,6 +326,24 @@ def base_pyproject(self, tmp_path, additional_text):
329326 pyproject .write_text (text , encoding = "utf-8" )
330327 return pyproject
331328
329+ def base_pyproject_license_pep639 (self , tmp_path ):
330+ pyproject = _pep621_example_project (tmp_path , "README" )
331+ text = pyproject .read_text (encoding = "utf-8" )
332+
333+ # Sanity-check
334+ assert 'license = {file = "LICENSE.txt"}' in text
335+ assert 'license-files' not in text
336+ assert "[tool.setuptools]" not in text
337+
338+ text = re .sub (
339+ r"(license = {file = \"LICENSE.txt\"})\n" ,
340+ ("license = \" licenseref-Proprietary\" \n license-files = [\" _FILE*\" ]\n " ),
341+ text ,
342+ count = 1 ,
343+ )
344+ pyproject .write_text (text , encoding = "utf-8" )
345+ return pyproject
346+
332347 def test_both_license_and_license_files_defined (self , tmp_path ):
333348 setuptools_config = '[tool.setuptools]\n license-files = ["_FILE*"]'
334349 pyproject = self .base_pyproject (tmp_path , setuptools_config )
@@ -345,6 +360,18 @@ def test_both_license_and_license_files_defined(self, tmp_path):
345360 assert set (dist .metadata .license_files ) == {"_FILE.rst" , "_FILE.txt" }
346361 assert dist .metadata .license == "LicenseRef-Proprietary\n "
347362
363+ def test_both_license_and_license_files_defined_pep639 (self , tmp_path ):
364+ # Set license and license-files
365+ pyproject = self .base_pyproject_license_pep639 (tmp_path )
366+
367+ (tmp_path / "_FILE.txt" ).touch ()
368+ (tmp_path / "_FILE.rst" ).touch ()
369+
370+ dist = pyprojecttoml .apply_configuration (makedist (tmp_path ), pyproject )
371+ assert set (dist .metadata .license_files ) == {"_FILE.rst" , "_FILE.txt" }
372+ assert dist .metadata .license is None
373+ assert dist .metadata .license_expression == "LicenseRef-Proprietary"
374+
348375 def test_default_patterns (self , tmp_path ):
349376 setuptools_config = '[tool.setuptools]\n zip-safe = false'
350377 # ^ used just to trigger section validation
0 commit comments