aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/dist.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-07-20 19:28:05 -0400
committerGitHub <noreply@github.com>2016-07-20 19:28:05 -0400
commitb2f50d5ddf0be280d0b0106f178437a4aad1b306 (patch)
tree507b2701d1ba2bf13233d5670509d042af4e863a /setuptools/dist.py
parent18f760aa07da104d7ed156b7f085bd05fb0c964d (diff)
parent020771f5e631741de31255283aa81adc05a26a9d (diff)
downloadexternal_python_setuptools-b2f50d5ddf0be280d0b0106f178437a4aad1b306.tar.gz
external_python_setuptools-b2f50d5ddf0be280d0b0106f178437a4aad1b306.tar.bz2
external_python_setuptools-b2f50d5ddf0be280d0b0106f178437a4aad1b306.zip
Merge pull request #631 from xavfernandez/xfernandez/python_requires
Add python_requires keywords to setup
Diffstat (limited to 'setuptools/dist.py')
-rw-r--r--setuptools/dist.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py
index b8ada9b9..bfdbb3b5 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -39,6 +39,20 @@ def _get_unpatched(cls):
_Distribution = _get_unpatched(_Distribution)
+def _patch_distribution_metadata_write_pkg_file():
+ """Patch write_pkg_file to also write Requires-Python/Requires-External"""
+ original_write = distutils.dist.DistributionMetadata.write_pkg_file
+ def write_pkg_file(self, file):
+ """Write the PKG-INFO format data to a file object.
+ """
+ original_write(self, file)
+ if hasattr(self, 'python_requires'):
+ file.write('Requires-Python: %s\n' % self.python_requires)
+
+ distutils.dist.DistributionMetadata.write_pkg_file = write_pkg_file
+_patch_distribution_metadata_write_pkg_file()
+
+
def _patch_distribution_metadata_write_pkg_info():
"""
Workaround issue #197 - Python 3 prior to 3.2.2 uses an environment-local
@@ -138,6 +152,18 @@ def check_requirements(dist, attr, value):
raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
+def check_specifier(dist, attr, value):
+ """Verify that value is a valid version specifier"""
+ try:
+ packaging.specifiers.SpecifierSet(value)
+ except packaging.specifiers.InvalidSpecifier as error:
+ tmpl = (
+ "{attr!r} must be a string or list of strings "
+ "containing valid version specifiers; {error}"
+ )
+ raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
+
+
def check_entry_points(dist, attr, value):
"""Verify that entry_points map is parseable"""
try:
@@ -305,6 +331,8 @@ class Distribution(_Distribution):
"setuptools, pip, and PyPI. Please see PEP 440 for more "
"details." % self.metadata.version
)
+ if getattr(self, 'python_requires', None):
+ self.metadata.python_requires = self.python_requires
def parse_command_line(self):
"""Process features after parsing command line options"""