@@ -334,6 +334,7 @@ class PEP621Parser(RequiredKeysConfigParser):
334334"readme" ,
335335"requires-python" ,
336336"license" ,
337+ "license-files" ,
337338"authors" ,
338339"maintainers" ,
339340"keywords" ,
@@ -678,6 +679,51 @@ def parse_license(config: Dict[str, TOML_TYPES]) -> License:
678679else :
679680raise BadConfigError ("The 'project.license' table should contain one of 'text' or 'file'." )
680681
682+ # TODO: equivalent of PEP 621 direcrive for 639
683+ @_documentation_url ("https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license-files" )
684+ def parse_license_files (self , config : Dict [str , TOML_TYPES ]) -> List [str ]:
685+ """
686+ Parse the ``license-files`` key, giving paths to the licence(s) for the project.
687+
688+ * **Format**: :toml:`Array` of :toml:`strings <string>`
689+ * **Core Metadata**: :core-meta:`License-Files`
690+
691+ .. versionadded:: 0.14.0
692+
693+ .. latex:vspace:: -5px
694+
695+ :bold-title:`Example:`
696+
697+ .. code-block:: TOML
698+
699+ [project]
700+ license-files = ["LICEN[CS]E*", "vendored/licenses/*.txt", "AUTHORS.md"]
701+
702+ .. latex:vspace:: -5px
703+
704+ :param config: The unparsed TOML config for the :pep621:`project table <table-name>`.
705+ """
706+
707+ parsed_paths = set ()
708+ key_path = [self .table_name , "license-files" ]
709+
710+ license_files : List [str ] = config ["license-files" ]
711+ self .assert_sequence_not_str (license_files , key_path )
712+
713+ for idx , pattern in enumerate (license_files ):
714+ name = construct_path (key_path ) + f"[{ idx } ]"
715+ self .assert_indexed_type (pattern , str , key_path , idx = idx )
716+ if pattern .startswith ('/' ):
717+ raise BadConfigError (f"{ name !r} : pattern cannot start with '/'" )
718+ if '\\ ' in pattern :
719+ raise BadConfigError (f"{ name !r} : pattern cannot contain '\\ '" )
720+ if ".." in pattern :
721+ raise BadConfigError (f"{ name !r} : pattern cannot contain '..'" )
722+
723+ parsed_paths .add (pattern )
724+
725+ return natsorted (parsed_paths , alg = ns .GROUPLETTERS )
726+
681727@staticmethod
682728def _parse_authors (config : Dict [str , TOML_TYPES ], key_name : str = "authors" ) -> List [Author ]:
683729all_authors : List [Author ] = []
0 commit comments