Drop the support of Python 2.7, 3.4, and 3.5. All versions have reached end-of-life for more than a year now.
PiperOrigin-RevId: 405511743
Change-Id: Id0f78693a6de9474576c3cfa879caf2cc177d8f6
diff --git a/WORKSPACE b/WORKSPACE
index 9c87875..5397414 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -36,14 +36,3 @@
strip_prefix = "mock-1.0.1",
build_file = "@//third_party:mock.BUILD",
)
-
-http_archive(
- # NOTE: The name here is used in _enum_module.py to find the sys.path entry.
- name = "enum34_archive",
- urls = [
- "https://mirror.bazel.build/pypi.python.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz",
- "https://pypi.python.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz"
- ],
- sha256 = "8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1",
- build_file = "@//third_party:enum34.BUILD"
-)
diff --git a/absl/BUILD b/absl/BUILD
index ed861c3..cbc72fe 100644
--- a/absl/BUILD
+++ b/absl/BUILD
@@ -39,21 +39,6 @@
)
py_library(
- name = "_enum_module",
- srcs = ["_enum_module.py"],
- visibility = [":__subpackages__"],
- deps = [
- "@six_archive//:six",
- ] + select({
- # In some Python 3 environments, despite the _enum_module import path
- # tricks, the enum backport still ends up on sys.path before the
- # stdlib, which more-or-less breaks Python
- ":py3_mode": [],
- "//conditions:default": ["@enum34_archive//:enum"],
- }),
-)
-
-py_library(
name = "_collections_abc",
srcs = ["_collections_abc.py"],
visibility = [":__subpackages__"],
@@ -91,7 +76,6 @@
python_version = "PY3",
srcs_version = "PY3",
deps = [
- ":_enum_module",
":app",
":tests/app_test_helper",
"//absl/flags",
diff --git a/absl/CHANGELOG.md b/absl/CHANGELOG.md
index 33e7c41..d427e8e 100644
--- a/absl/CHANGELOG.md
+++ b/absl/CHANGELOG.md
@@ -6,7 +6,10 @@
## Unreleased
-Nothing notable unreleased.
+### Changed
+
+* `absl-py` no longer supports Python 2.7, 3.4, 3.5. All versions have reached
+ end-of-life for more than a year now.
## 0.15.0 (2021-10-19)
diff --git a/absl/_enum_module.py b/absl/_enum_module.py
deleted file mode 100644
index 899c488..0000000
--- a/absl/_enum_module.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2019 The Abseil Authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Import workaround so that Bazel, Py2/Py3, and enum34 package work together.
-
-This works around a problem due to the combination of Bazel putting
-third party packages before the stdlib in PYTHONPATH. What happens is:
- * The enum34 PyPi package is imported as 'enum'.
- * Bazel puts the path to enum34 before the stdlib, hence 'import enum'
- will prefer to use enum34 from above instead of the stdlib.
- * In Python 3, enum34 is used instead of the stdlib, which breaks
- lots of things. It works fine in Python 2, since there is no enum
- module.
-
-To work around this, we do 3 things:
- 1. Put the enum34 code on PYTHONPATH, but not directly importable as
- 'enum'; it is under the (non importable) directory name with the
- PyPi package name and version.
- 2. Try to import enum normally, if it works, great. This makes Py3 work
- (as well as Py2 when enum is available as normal).
- 3. If the normal enum import failed, then try to find the enum34
- entry on sys.path, and append the missing directory name.
-
-Once it is successfully imported, expose the module directly. This
-prevents importing the module twice under different names. e.g.,
-the following is true:
- from absl._enum_module import enum as absl_enum
- import enum as normal_enum
- assert absl_enum is normal_enum
-"""
-# pylint: disable=unused-import
-import sys
-import six
-
-try:
- import enum
-except ImportError:
- if six.PY3:
- # While not all Py3's have enum, only the ones we support do.
- raise
- for i, path in enumerate(sys.path):
- if '/enum34_archive' in path:
- sys.path[i] = path + '/enum34-1.1.6'
-
- import enum
diff --git a/absl/flags/BUILD b/absl/flags/BUILD
index 5457c37..326fe0b 100644
--- a/absl/flags/BUILD
+++ b/absl/flags/BUILD
@@ -122,7 +122,6 @@
srcs_version = "PY3",
deps = [
":_argument_parser",
- "//absl:_enum_module",
"//absl/testing:absltest",
"//absl/testing:parameterized",
"@six_archive//:six",
@@ -138,7 +137,6 @@
":_argument_parser",
":_exceptions",
":_flag",
- "//absl:_enum_module",
"//absl/testing:absltest",
"//absl/testing:parameterized",
],
@@ -249,7 +247,6 @@
":_helpers",
":flags",
":tests/module_bar",
- "//absl:_enum_module",
"//absl/testing:absltest",
"@six_archive//:six",
],
@@ -282,7 +279,6 @@
":tests/module_bar",
":tests/module_baz",
":tests/module_foo",
- "//absl:_enum_module",
"//absl/testing:absltest",
"@six_archive//:six",
],
diff --git a/absl/flags/tests/_argument_parser_test.py b/absl/flags/tests/_argument_parser_test.py
index 247249c..5373838 100644
--- a/absl/flags/tests/_argument_parser_test.py
+++ b/absl/flags/tests/_argument_parser_test.py
@@ -20,7 +20,7 @@
from __future__ import division
from __future__ import print_function
-from absl._enum_module import enum
+import enum
from absl.flags import _argument_parser
from absl.testing import absltest
from absl.testing import parameterized
diff --git a/absl/flags/tests/_flag_test.py b/absl/flags/tests/_flag_test.py
index fb08b51..800a00c 100644
--- a/absl/flags/tests/_flag_test.py
+++ b/absl/flags/tests/_flag_test.py
@@ -22,9 +22,9 @@
from __future__ import print_function
import copy
+import enum
import pickle
-from absl._enum_module import enum
from absl.flags import _argument_parser
from absl.flags import _exceptions
from absl.flags import _flag
diff --git a/absl/flags/tests/flags_helpxml_test.py b/absl/flags/tests/flags_helpxml_test.py
index 92b59bb..2f5ca17 100644
--- a/absl/flags/tests/flags_helpxml_test.py
+++ b/absl/flags/tests/flags_helpxml_test.py
@@ -18,6 +18,7 @@
from __future__ import division
from __future__ import print_function
+import enum
import io
import os
import string
@@ -26,7 +27,6 @@
import xml.sax.saxutils
from absl import flags
-from absl._enum_module import enum
from absl.flags import _helpers
from absl.flags.tests import module_bar
from absl.testing import absltest
diff --git a/absl/flags/tests/flags_test.py b/absl/flags/tests/flags_test.py
index 2d63c40..a0a301d 100644
--- a/absl/flags/tests/flags_test.py
+++ b/absl/flags/tests/flags_test.py
@@ -18,6 +18,7 @@
from __future__ import print_function
import contextlib
+import enum
import io
import os
import shutil
@@ -26,7 +27,6 @@
import unittest
from absl import flags
-from absl._enum_module import enum
from absl.flags import _exceptions
from absl.flags import _helpers
from absl.flags.tests import module_bar
diff --git a/absl/testing/BUILD b/absl/testing/BUILD
index 14c9a5f..4ed9126 100644
--- a/absl/testing/BUILD
+++ b/absl/testing/BUILD
@@ -30,7 +30,6 @@
":_pretty_print_reporter",
":xml_reporter",
"//absl:_collections_abc",
- "//absl:_enum_module",
"//absl:app",
"//absl/flags",
"//absl/logging",
diff --git a/absl/testing/absltest.py b/absl/testing/absltest.py
index a79cde7..39fa1c9 100644
--- a/absl/testing/absltest.py
+++ b/absl/testing/absltest.py
@@ -24,6 +24,7 @@
import contextlib
import difflib
+import enum
import errno
import getpass
import inspect
@@ -57,7 +58,6 @@
from absl import flags
from absl import logging
from absl._collections_abc import abc
-from absl._enum_module import enum
from absl.testing import _pretty_print_reporter
from absl.testing import xml_reporter
from absl.third_party import unittest3_backport
diff --git a/absl/tests/app_test.py b/absl/tests/app_test.py
index c879f76..38eb108 100644
--- a/absl/tests/app_test.py
+++ b/absl/tests/app_test.py
@@ -21,6 +21,7 @@
import codecs
import contextlib
import copy
+import enum
import os
import re
import subprocess
@@ -30,7 +31,6 @@
from absl import app
from absl import flags
-from absl._enum_module import enum
from absl.testing import _bazelize_command
from absl.testing import absltest
from absl.testing import flagsaver
diff --git a/setup.py b/setup.py
index f6688e0..1ecfa2b 100644
--- a/setup.py
+++ b/setup.py
@@ -28,9 +28,8 @@
use_setuptools()
import setuptools
-py_version = sys.version_info
-if py_version < (2, 7) or py_version[0] == 3 and py_version < (3, 4):
- raise RuntimeError('Python version 2.7 or 3.4+ is required.')
+if sys.version_info < (3, 6):
+ raise RuntimeError('Python version 3.6+ is required.')
INSTALL_REQUIRES = [
'six',
@@ -39,22 +38,11 @@
setuptools_version = tuple(
int(x) for x in setuptools.__version__.split('.')[:2])
-# A variety of environments have very, very old versions of setuptools that
-# don't support the environment markers ("foo; python_version < X"). Since
-# we're using sdist, this setup.py gets run directly when installing, so
-# we can just manually do the dependency checking.
-# See these for more info:
-# https://github.com/abseil/abseil-py/issues/79
-# https://hynek.me/articles/conditional-python-dependencies/
-# Environment marker support was added in setuptools 36.2, see
-# https://github.com/pypa/setuptools/blob/master/CHANGES.rst#v3620
-if setuptools_version < (36, 2):
- if sys.version_info[0:2] < (3, 4):
- INSTALL_REQUIRES.append('enum34')
-else:
- # Environment markers are the preferred way: it allows correct non-source
- # distributions (i.e., wheels) to be generated.
- INSTALL_REQUIRES.append("enum34; python_version < '3.4'")
+additional_kwargs = {}
+if setuptools_version >= (24, 2):
+ # `python_requires` was added in 24.2, see
+ # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
+ additional_kwargs['python_requires'] = '>=3.6'
_README_PATH = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'README.md')
@@ -79,18 +67,16 @@
license='Apache 2.0',
classifiers=[
'Programming Language :: Python',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
+ 'Programming Language :: Python :: 3.10',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
],
+ **additional_kwargs,
)
diff --git a/smoke_tests/smoke_test.sh b/smoke_tests/smoke_test.sh
index 75dee05..3dde82b 100755
--- a/smoke_tests/smoke_test.sh
+++ b/smoke_tests/smoke_test.sh
@@ -60,11 +60,6 @@
curl https://bootstrap.pypa.io/get-pip.py | python
pip --version
pip install six
-# For some reason, the setup.py install command on Mac with Python 3.4 fails to
-# install enum34 due to a TLS error. Installing it explicitly beforehand works.
-# enum34 isn't needed for >= 3.5, but installing it in other versions won't
-# cause problems.
-pip install enum34
python --version
python setup.py install
diff --git a/third_party/enum34.BUILD b/third_party/enum34.BUILD
deleted file mode 100644
index a5ac255..0000000
--- a/third_party/enum34.BUILD
+++ /dev/null
@@ -1,13 +0,0 @@
-# Description:
-# enum34 provides a backport of the enum module for Python 2.
-
-licenses(["notice"]) # MIT
-
-exports_files(["LICENSE"])
-
-py_library(
- name = "enum",
- srcs = ["enum34-1.1.6/enum/__init__.py"],
- srcs_version = "PY2AND3",
- visibility = ["//visibility:public"],
-)