aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeniz Taneli <7292227+dtaneli@users.noreply.github.com>2018-10-28 15:36:02 +0000
committerDeniz Taneli <7292227+dtaneli@users.noreply.github.com>2018-10-28 15:36:02 +0000
commit4e4efa77722cc2e99171a2396252a4ddc98450e3 (patch)
treeb701d0c534caaca932119c9d41ecb22d15a4dd6e
parent742457284db958bdf5efacde6e2b885c81247b27 (diff)
downloadexternal_python_setuptools-4e4efa77722cc2e99171a2396252a4ddc98450e3.tar.gz
external_python_setuptools-4e4efa77722cc2e99171a2396252a4ddc98450e3.tar.bz2
external_python_setuptools-4e4efa77722cc2e99171a2396252a4ddc98450e3.zip
`check_license` no longer needs to parse `setup.cfg`
-rw-r--r--setuptools/command/sdist.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index a1b20733..347f8817 100644
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -201,25 +201,21 @@ class sdist(sdist_add_defaults, orig.sdist):
manifest.close()
def check_license(self):
- """Read the setup configuration file ('setup.cfg') and use it to find
- if a license is defined with the 'license_file' attribute.
- If the license is declared and exists, it will be added to
- 'self.filelist'.
+ """Checks if license_file' is configured and adds it to
+ 'self.filelist' if the value contains a valid path.
"""
- cfg_file = 'setup.cfg'
- log.debug("Reading configuration from %s", cfg_file)
- parser = configparser.RawConfigParser()
- parser.read(cfg_file)
+ opts = self.distribution.get_option_dict('metadata')
try:
- license_file = parser.get('metadata', 'license_file')
-
- if not os.path.exists(license_file):
- log.warn("warning: Failed to find license file '%s' in setup.cfg",
- license_file)
- return
+ # ignore the source of the value
+ _, license_file = opts.get('license_file')
+ except TypeError:
+ log.debug("'license_file' attribute is not defined")
+ return
- self.filelist.append(license_file)
- except configparser.Error:
- log.debug("license_file attribute is not defined in setup.cfg")
+ if not os.path.exists(license_file):
+ log.warn("warning: Failed to find the configured license file '%s'",
+ license_file)
return
+
+ self.filelist.append(license_file)