summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-11-16 15:19:37 -0500
committerGitHub <noreply@github.com>2019-11-16 15:19:37 -0500
commit68dbb703705cdd64e25261a6fcc1c0cc96bcf431 (patch)
tree7b52801746baba0bc73d39e4f4f5af0a2a3e48fa /setuptools/command
parent402240c01964f078254c53ce9db7f1c816146225 (diff)
parente08ec2b640f6b2bf943fea70e2a7f9881bbe6e91 (diff)
downloadpython-setuptools-git-68dbb703705cdd64e25261a6fcc1c0cc96bcf431.tar.gz
Merge pull request #1767 from kchmck/feat-license-files
Add support for `license_files` option in metadata
Diffstat (limited to 'setuptools/command')
-rw-r--r--setuptools/command/sdist.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index dc253981..55ecdd97 100644
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -5,7 +5,7 @@ import sys
import io
import contextlib
-from setuptools.extern import six
+from setuptools.extern import six, ordered_set
from .py36compat import sdist_add_defaults
@@ -200,10 +200,12 @@ class sdist(sdist_add_defaults, orig.sdist):
manifest.close()
def check_license(self):
- """Checks if license_file' is configured and adds it to
- 'self.filelist' if the value contains a valid path.
+ """Checks if license_file' or 'license_files' is configured and adds any
+ valid paths to 'self.filelist'.
"""
+ files = ordered_set.OrderedSet()
+
opts = self.distribution.get_option_dict('metadata')
# ignore the source of the value
@@ -211,11 +213,19 @@ class sdist(sdist_add_defaults, orig.sdist):
if license_file is None:
log.debug("'license_file' option was not specified")
- return
+ else:
+ files.add(license_file)
- if not os.path.exists(license_file):
- log.warn("warning: Failed to find the configured license file '%s'",
- license_file)
- return
+ try:
+ files.update(self.distribution.metadata.license_files)
+ except TypeError:
+ log.warn("warning: 'license_files' option is malformed")
+
+ for f in files:
+ if not os.path.exists(f):
+ log.warn(
+ "warning: Failed to find the configured license file '%s'",
+ f)
+ files.remove(f)
- self.filelist.append(license_file)
+ self.filelist.extend(files)