File pep-0639.patch of Package python-setuptools.42318
Index: setuptools-67.7.2/setuptools/config/_apply_pyprojecttoml.py
===================================================================
--- setuptools-67.7.2.orig/setuptools/config/_apply_pyprojecttoml.py
+++ setuptools-67.7.2/setuptools/config/_apply_pyprojecttoml.py
@@ -159,14 +159,20 @@ def _long_description(dist: "Distributio
dist._referenced_files.add(cast(str, file))
-def _license(dist: "Distribution", val: dict, root_dir: _Path):
+def _license(dist: "Distribution", val: dict | str, root_dir: _Path):
from setuptools.config import expand
- if "file" in val:
- _set_config(dist, "license", expand.read_files([val["file"]], root_dir))
- dist._referenced_files.add(val["file"])
+ if isinstance(val, str):
+ if getattr(dist.metadata, "license", None):
+ SetuptoolsWarning.emit("`license` overwritten by `pyproject.toml`")
+ dist.metadata.license = None
+ _set_config(dist, "license", val)
else:
- _set_config(dist, "license", val["text"])
+ if "file" in val:
+ _set_config(dist, "license", expand.read_files([val["file"]], root_dir))
+ dist._referenced_files.add(val["file"])
+ else:
+ _set_config(dist, "license", val["text"])
def _people(dist: "Distribution", val: List[dict], _root_dir: _Path, kind: str):
Index: setuptools-67.7.2/setuptools/config/_validate_pyproject/fastjsonschema_validations.py
===================================================================
--- setuptools-67.7.2.orig/setuptools/config/_validate_pyproject/fastjsonschema_validations.py
+++ setuptools-67.7.2/setuptools/config/_validate_pyproject/fastjsonschema_validations.py
@@ -767,39 +767,52 @@ def validate_https___packaging_python_or
if "license" in data_keys:
data_keys.remove("license")
data__license = data["license"]
- data__license_one_of_count11 = 0
- if data__license_one_of_count11 < 2:
- try:
- data__license_is_dict = isinstance(data__license, dict)
- if data__license_is_dict:
- data__license_len = len(data__license)
- if not all(prop in data__license for prop in ['file']):
- raise JsonSchemaValueException("" + (name_prefix or "data") + ".license must contain ['file'] properties", value=data__license, name="" + (name_prefix or "data") + ".license", definition={'properties': {'file': {'type': 'string', '$$description': ['Relative path to the file (UTF-8) which contains the license for the', 'project.']}}, 'required': ['file']}, rule='required')
- data__license_keys = set(data__license.keys())
- if "file" in data__license_keys:
- data__license_keys.remove("file")
- data__license__file = data__license["file"]
- if not isinstance(data__license__file, (str)):
- raise JsonSchemaValueException("" + (name_prefix or "data") + ".license.file must be string", value=data__license__file, name="" + (name_prefix or "data") + ".license.file", definition={'type': 'string', '$$description': ['Relative path to the file (UTF-8) which contains the license for the', 'project.']}, rule='type')
- data__license_one_of_count11 += 1
- except JsonSchemaValueException: pass
- if data__license_one_of_count11 < 2:
- try:
- data__license_is_dict = isinstance(data__license, dict)
- if data__license_is_dict:
- data__license_len = len(data__license)
- if not all(prop in data__license for prop in ['text']):
- raise JsonSchemaValueException("" + (name_prefix or "data") + ".license must contain ['text'] properties", value=data__license, name="" + (name_prefix or "data") + ".license", definition={'properties': {'text': {'type': 'string', '$$description': ['The license of the project whose meaning is that of the', '`License field from the core metadata', '<https://packaging.python.org/specifications/core-metadata/#license>`_.']}}, 'required': ['text']}, rule='required')
- data__license_keys = set(data__license.keys())
- if "text" in data__license_keys:
- data__license_keys.remove("text")
- data__license__text = data__license["text"]
- if not isinstance(data__license__text, (str)):
- raise JsonSchemaValueException("" + (name_prefix or "data") + ".license.text must be string", value=data__license__text, name="" + (name_prefix or "data") + ".license.text", definition={'type': 'string', '$$description': ['The license of the project whose meaning is that of the', '`License field from the core metadata', '<https://packaging.python.org/specifications/core-metadata/#license>`_.']}, rule='type')
- data__license_one_of_count11 += 1
- except JsonSchemaValueException: pass
- if data__license_one_of_count11 != 1:
- raise JsonSchemaValueException("" + (name_prefix or "data") + ".license must be valid exactly by one definition" + (" (" + str(data__license_one_of_count11) + " matches found)"), value=data__license, name="" + (name_prefix or "data") + ".license", definition={'description': '`Project license <https://peps.python.org/pep-0621/#license>`_.', 'oneOf': [{'properties': {'file': {'type': 'string', '$$description': ['Relative path to the file (UTF-8) which contains the license for the', 'project.']}}, 'required': ['file']}, {'properties': {'text': {'type': 'string', '$$description': ['The license of the project whose meaning is that of the', '`License field from the core metadata', '<https://packaging.python.org/specifications/core-metadata/#license>`_.']}}, 'required': ['text']}]}, rule='oneOf')
+ data__license = data["license"]
+ if not isinstance(data__license, (str)):
+ data__license_one_of_count11 = 0
+ if data__license_one_of_count11 < 2:
+ try:
+ data__license_is_dict = isinstance(data__license, dict)
+ if data__license_is_dict:
+ data__license_len = len(data__license)
+ if not all(prop in data__license for prop in ['file']):
+ raise JsonSchemaValueException("" + (name_prefix or "data") + ".license must contain ['file'] properties", value=data__license, name="" + (name_prefix or "data") + ".license", definition={'properties': {'file': {'type': 'string', '$$description': ['Relative path to the file (UTF-8) which contains the license for the', 'project.']}}, 'required': ['file']}, rule='required')
+ data__license_keys = set(data__license.keys())
+ if "file" in data__license_keys:
+ data__license_keys.remove("file")
+ data__license__file = data__license["file"]
+ if not isinstance(data__license__file, (str)):
+ raise JsonSchemaValueException("" + (name_prefix or "data") + ".license.file must be string", value=data__license__file, name="" + (name_prefix or "data") + ".license.file", definition={'type': 'string', '$$description': ['Relative path to the file (UTF-8) which contains the license for the', 'project.']}, rule='type')
+ data__license_one_of_count11 += 1
+ except JsonSchemaValueException: pass
+ if data__license_one_of_count11 < 2:
+ try:
+ data__license_is_dict = isinstance(data__license, dict)
+ if data__license_is_dict:
+ data__license_len = len(data__license)
+ if not all(prop in data__license for prop in ['text']):
+ raise JsonSchemaValueException("" + (name_prefix or "data") + ".license must contain ['text'] properties", value=data__license, name="" + (name_prefix or "data") + ".license", definition={'properties': {'text': {'type': 'string', '$$description': ['The license of the project whose meaning is that of the', '`License field from the core metadata', '<https://packaging.python.org/specifications/core-metadata/#license>`_.']}}, 'required': ['text']}, rule='required')
+ data__license_keys = set(data__license.keys())
+ if "text" in data__license_keys:
+ data__license_keys.remove("text")
+ data__license__text = data__license["text"]
+ if not isinstance(data__license__text, (str)):
+ raise JsonSchemaValueException("" + (name_prefix or "data") + ".license.text must be string", value=data__license__text, name="" + (name_prefix or "data") + ".license.text", definition={'type': 'string', '$$description': ['The license of the project whose meaning is that of the', '`License field from the core metadata', '<https://packaging.python.org/specifications/core-metadata/#license>`_.']}, rule='type')
+ data__license_one_of_count11 += 1
+ except JsonSchemaValueException: pass
+ if data__license_one_of_count11 != 1:
+ raise JsonSchemaValueException("" + (name_prefix or "data") + ".license must be valid exactly by one definition" + (" (" + str(data__license_one_of_count11) + " matches found)"), value=data__license, name="" + (name_prefix or "data") + ".license", definition={'description': '`Project license <https://peps.python.org/pep-0621/#license>`_.', 'oneOf': [{'properties': {'file': {'type': 'string', '$$description': ['Relative path to the file (UTF-8) which contains the license for the', 'project.']}}, 'required': ['file']}, {'properties': {'text': {'type': 'string', '$$description': ['The license of the project whose meaning is that of the', '`License field from the core metadata', '<https://packaging.python.org/specifications/core-metadata/#license>`_.']}}, 'required': ['text']}]}, rule='oneOf')
+ if "license-files" in data_keys:
+ data_keys.remove("license-files")
+ data__licensefiles = data["license-files"]
+ if not isinstance(data__licensefiles, (list, tuple)):
+ raise JsonSchemaValueException("" + (name_prefix or "data") + ".license-files must be array", value=data__licensefiles, name="" + (name_prefix or "data") + ".license-files", definition={'description': 'Paths or globs to paths of license files', 'type': 'array', 'items': {'type': 'string'}}, rule='type')
+ data__licensefiles_is_list = isinstance(data__licensefiles, (list, tuple))
+ if data__licensefiles_is_list:
+ data__licensefiles_len = len(data__licensefiles)
+ for data__licensefiles_x, data__licensefiles_item in enumerate(data__licensefiles):
+ if not isinstance(data__licensefiles_item, (str)):
+ raise JsonSchemaValueException("" + (name_prefix or "data") + ".license-files[{data__licensefiles_x}]".format(**locals()) + " must be string", value=data__licensefiles_item, name="" + (name_prefix or "data") + ".license-files[{data__licensefiles_x}]".format(**locals()) + "", definition={'type': 'string'}, rule='type')
if "authors" in data_keys:
data_keys.remove("authors")
data__authors = data["authors"]
@@ -1049,4 +1062,4 @@ def validate_https___packaging_python_or
raise JsonSchemaValueException("" + (name_prefix or "data") + ".email must be idn-email", value=data__email, name="" + (name_prefix or "data") + ".email", definition={'type': 'string', 'format': 'idn-email', 'description': 'MUST be a valid email address'}, rule='format')
if data_keys:
raise JsonSchemaValueException("" + (name_prefix or "data") + " must not contain "+str(data_keys)+" properties", value=data, name="" + (name_prefix or "data") + "", definition={'$id': '#/definitions/author', 'title': 'Author or Maintainer', '$comment': 'https://peps.python.org/pep-0621/#authors-maintainers', 'type': 'object', 'additionalProperties': False, 'properties': {'name': {'type': 'string', '$$description': ['MUST be a valid email name, i.e. whatever can be put as a name, before an', 'email, in :rfc:`822`.']}, 'email': {'type': 'string', 'format': 'idn-email', 'description': 'MUST be a valid email address'}}}, rule='additionalProperties')
- return data
\ No newline at end of file
+ return data