summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst1
-rw-r--r--changelog.d/1416.change.rst1
-rw-r--r--pkg_resources/py31compat.py4
-rw-r--r--setuptools/command/bdist_egg.py2
-rwxr-xr-xsetuptools/command/egg_info.py61
-rw-r--r--setuptools/extern/__init__.py2
-rw-r--r--setuptools/pep425tags.py6
-rw-r--r--setuptools/tests/test_register.py4
-rw-r--r--towncrier_template.rst1
9 files changed, 49 insertions, 33 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 2f96af99..05de4cfc 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,5 +1,6 @@
v40.0.0
-------
+
* #1342: Drop support for Python 3.3.
* #1366: In package_index, fixed handling of encoded entities in URLs.
* #1383: In pkg_resources VendorImporter, avoid removing packages imported from the root.
diff --git a/changelog.d/1416.change.rst b/changelog.d/1416.change.rst
new file mode 100644
index 00000000..e4138a8f
--- /dev/null
+++ b/changelog.d/1416.change.rst
@@ -0,0 +1 @@
+Moved several Python version checks over to using ``six.PY2`` and ``six.PY3``.
diff --git a/pkg_resources/py31compat.py b/pkg_resources/py31compat.py
index fd4b6fd0..a381c424 100644
--- a/pkg_resources/py31compat.py
+++ b/pkg_resources/py31compat.py
@@ -2,6 +2,8 @@ import os
import errno
import sys
+from .extern import six
+
def _makedirs_31(path, exist_ok=False):
try:
@@ -15,7 +17,7 @@ def _makedirs_31(path, exist_ok=False):
# and exists_ok considerations are disentangled.
# See https://github.com/pypa/setuptools/pull/1083#issuecomment-315168663
needs_makedirs = (
- sys.version_info.major == 2 or
+ six.PY2 or
(3, 4) <= sys.version_info < (3, 4, 1)
)
makedirs = _makedirs_31 if needs_makedirs else os.makedirs
diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py
index 14530729..9f8df917 100644
--- a/setuptools/command/bdist_egg.py
+++ b/setuptools/command/bdist_egg.py
@@ -411,7 +411,7 @@ def scan_module(egg_dir, base, name, stubs):
return True # Extension module
pkg = base[len(egg_dir) + 1:].replace(os.sep, '.')
module = pkg + (pkg and '.' or '') + os.path.splitext(name)[0]
- if sys.version_info.major == 2:
+ if six.PY2:
skip = 8 # skip magic & date
elif sys.version_info < (3, 7):
skip = 12 # skip magic & date & file size
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index f3e604d3..5fd6c888 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -116,7 +116,33 @@ def translate_pattern(glob):
return re.compile(pat, flags=re.MULTILINE|re.DOTALL)
-class egg_info(Command):
+class InfoCommon:
+ tag_build = None
+ tag_date = None
+
+ @property
+ def name(self):
+ return safe_name(self.distribution.get_name())
+
+ def tagged_version(self):
+ version = self.distribution.get_version()
+ # egg_info may be called more than once for a distribution,
+ # in which case the version string already contains all tags.
+ if self.vtags and version.endswith(self.vtags):
+ return safe_version(version)
+ return safe_version(version + self.vtags)
+
+ def tags(self):
+ version = ''
+ if self.tag_build:
+ version += self.tag_build
+ if self.tag_date:
+ version += time.strftime("-%Y%m%d")
+ return version
+ vtags = property(tags)
+
+
+class egg_info(InfoCommon, Command):
description = "create a distribution's .egg-info directory"
user_options = [
@@ -133,14 +159,9 @@ class egg_info(Command):
}
def initialize_options(self):
- self.egg_name = None
- self.egg_version = None
self.egg_base = None
self.egg_info = None
- self.tag_build = None
- self.tag_date = 0
self.broken_egg_info = False
- self.vtags = None
####################################
# allow the 'tag_svn_revision' to be detected and
@@ -167,11 +188,15 @@ class egg_info(Command):
egg_info['tag_date'] = 0
edit_config(filename, dict(egg_info=egg_info))
- def finalize_options(self):
- self.egg_name = safe_name(self.distribution.get_name())
- self.vtags = self.tags()
- self.egg_version = self.tagged_version()
+ @property
+ def egg_name(self):
+ return self.name
+
+ @property
+ def egg_version(self):
+ return self.tagged_version()
+ def finalize_options(self):
parsed_version = parse_version(self.egg_version)
try:
@@ -254,14 +279,6 @@ class egg_info(Command):
if not self.dry_run:
os.unlink(filename)
- def tagged_version(self):
- version = self.distribution.get_version()
- # egg_info may be called more than once for a distribution,
- # in which case the version string already contains all tags.
- if self.vtags and version.endswith(self.vtags):
- return safe_version(version)
- return safe_version(version + self.vtags)
-
def run(self):
self.mkpath(self.egg_info)
installer = self.distribution.fetch_build_egg
@@ -277,14 +294,6 @@ class egg_info(Command):
self.find_sources()
- def tags(self):
- version = ''
- if self.tag_build:
- version += self.tag_build
- if self.tag_date:
- version += time.strftime("-%Y%m%d")
- return version
-
def find_sources(self):
"""Generate SOURCES.txt manifest file"""
manifest_filename = os.path.join(self.egg_info, "SOURCES.txt")
diff --git a/setuptools/extern/__init__.py b/setuptools/extern/__init__.py
index 52785a03..cb2fa329 100644
--- a/setuptools/extern/__init__.py
+++ b/setuptools/extern/__init__.py
@@ -48,7 +48,7 @@ class VendorImporter:
# on later Python versions to cause relative imports
# in the vendor package to resolve the same modules
# as those going through this importer.
- if sys.version_info.major >= 3:
+ if sys.version_info >= (3, ):
del sys.modules[extant]
return mod
except ImportError:
diff --git a/setuptools/pep425tags.py b/setuptools/pep425tags.py
index a86a0d18..8bf4277d 100644
--- a/setuptools/pep425tags.py
+++ b/setuptools/pep425tags.py
@@ -12,6 +12,8 @@ import sysconfig
import warnings
from collections import OrderedDict
+from .extern import six
+
from . import glibc
_osx_arch_pat = re.compile(r'(.+)_(\d+)_(\d+)_(.+)')
@@ -97,8 +99,8 @@ def get_abi_tag():
lambda: sys.maxunicode == 0x10ffff,
expected=4,
warn=(impl == 'cp' and
- sys.version_info.major == 2)) \
- and sys.version_info.major == 2:
+ six.PY2)) \
+ and six.PY2:
u = 'u'
abi = '%s%s%s%s%s' % (impl, get_impl_ver(), d, m, u)
elif soabi and soabi.startswith('cpython-'):
diff --git a/setuptools/tests/test_register.py b/setuptools/tests/test_register.py
index 92d576db..96114595 100644
--- a/setuptools/tests/test_register.py
+++ b/setuptools/tests/test_register.py
@@ -18,7 +18,7 @@ class TestRegisterTest:
cmd.run()
- cmd.announce.assert_called_once_with(
+ cmd.announce.assert_called_with(
"WARNING: Registering is deprecated, use twine to upload instead "
"(https://pypi.org/p/twine/)",
log.WARN
@@ -36,7 +36,7 @@ class TestRegisterTest:
with pytest.raises(Exception):
cmd.run()
- cmd.announce.assert_called_once_with(
+ cmd.announce.assert_called_with(
"WARNING: Registering is deprecated, use twine to upload instead "
"(https://pypi.org/p/twine/)",
log.WARN
diff --git a/towncrier_template.rst b/towncrier_template.rst
index 9c23b977..fbc5ef03 100644
--- a/towncrier_template.rst
+++ b/towncrier_template.rst
@@ -2,6 +2,7 @@
{% set underline = underlines[0] %}{% if section %}{{section}}
{{ underline * section|length }}
{% endif %}
+
{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section]%}
{% if definitions[category]['showcontent'] %}