diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-01-18 08:13:23 -0800 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2020-02-16 09:33:32 -0800 |
commit | b3de7989665740cd4218d7d814e719d90e75de73 (patch) | |
tree | d805a67fc0f5ff68e26c806191f8d74b88709af3 | |
parent | 43edec2506f901ab939390951383025682448edd (diff) | |
download | external_python_setuptools-b3de7989665740cd4218d7d814e719d90e75de73.tar.gz external_python_setuptools-b3de7989665740cd4218d7d814e719d90e75de73.tar.bz2 external_python_setuptools-b3de7989665740cd4218d7d814e719d90e75de73.zip |
Remove pkg_resources.py31compat.makedirs() in favor of the stdlib
As setuptools is now python 3.5+, this compatibility shim is no longer
necessary.
-rw-r--r-- | changelog.d/1973.breaking.rst | 1 | ||||
-rw-r--r-- | pkg_resources/__init__.py | 3 | ||||
-rw-r--r-- | pkg_resources/py31compat.py | 23 | ||||
-rw-r--r-- | setuptools/build_meta.py | 3 | ||||
-rw-r--r-- | setuptools/command/easy_install.py | 4 | ||||
-rw-r--r-- | setuptools/sandbox.py | 4 | ||||
-rw-r--r-- | setuptools/tests/files.py | 5 | ||||
-rw-r--r-- | setuptools/tests/test_manifest.py | 3 |
8 files changed, 9 insertions, 37 deletions
diff --git a/changelog.d/1973.breaking.rst b/changelog.d/1973.breaking.rst new file mode 100644 index 00000000..398fdd71 --- /dev/null +++ b/changelog.d/1973.breaking.rst @@ -0,0 +1 @@ +Removed ``pkg_resources.py31compat.makedirs`` in favor of the stdlib. Use ``os.makedirs()`` instead. diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 75563f95..149ab6d2 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -76,7 +76,6 @@ try: except ImportError: importlib_machinery = None -from . import py31compat from pkg_resources.extern import appdirs from pkg_resources.extern import packaging __import__('pkg_resources.extern.packaging.version') @@ -3172,7 +3171,7 @@ def _find_adapter(registry, ob): def ensure_directory(path): """Ensure that the parent directory of `path` exists""" dirname = os.path.dirname(path) - py31compat.makedirs(dirname, exist_ok=True) + os.makedirs(dirname, exist_ok=True) def _bypass_ensure_directory(path): diff --git a/pkg_resources/py31compat.py b/pkg_resources/py31compat.py deleted file mode 100644 index a381c424..00000000 --- a/pkg_resources/py31compat.py +++ /dev/null @@ -1,23 +0,0 @@ -import os -import errno -import sys - -from .extern import six - - -def _makedirs_31(path, exist_ok=False): - try: - os.makedirs(path) - except OSError as exc: - if not exist_ok or exc.errno != errno.EEXIST: - raise - - -# rely on compatibility behavior until mode considerations -# and exists_ok considerations are disentangled. -# See https://github.com/pypa/setuptools/pull/1083#issuecomment-315168663 -needs_makedirs = ( - six.PY2 or - (3, 4) <= sys.version_info < (3, 4, 1) -) -makedirs = _makedirs_31 if needs_makedirs else os.makedirs diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index a1c951cf..46266814 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -38,7 +38,6 @@ import distutils from setuptools.py31compat import TemporaryDirectory from pkg_resources import parse_requirements -from pkg_resources.py31compat import makedirs __all__ = ['get_requires_for_build_sdist', 'get_requires_for_build_wheel', @@ -190,7 +189,7 @@ class _BuildMetaBackend(object): result_directory = os.path.abspath(result_directory) # Build in a temporary directory, then copy to the target. - makedirs(result_directory, exist_ok=True) + os.makedirs(result_directory, exist_ok=True) with TemporaryDirectory(dir=result_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + setup_command + ['--dist-dir', tmp_dist_dir] + diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index abca1ae1..d224ea05 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -64,7 +64,7 @@ from pkg_resources import ( Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound, VersionConflict, DEVELOP_DIST, ) -import pkg_resources.py31compat +import pkg_resources __metaclass__ = type @@ -559,7 +559,7 @@ class easy_install(Command): if ok_exists: os.unlink(ok_file) dirname = os.path.dirname(ok_file) - pkg_resources.py31compat.makedirs(dirname, exist_ok=True) + os.makedirs(dirname, exist_ok=True) f = open(pth_file, 'w') except (OSError, IOError): self.cant_write_to_target() diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index e46dfc8d..93ae8eb4 100644 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -12,7 +12,7 @@ import textwrap from setuptools.extern import six from setuptools.extern.six.moves import builtins, map -import pkg_resources.py31compat +import pkg_resources from distutils.errors import DistutilsError from pkg_resources import working_set @@ -70,7 +70,7 @@ def override_temp(replacement): """ Monkey-patch tempfile.tempdir with replacement, ensuring it exists """ - pkg_resources.py31compat.makedirs(replacement, exist_ok=True) + os.makedirs(replacement, exist_ok=True) saved = tempfile.tempdir diff --git a/setuptools/tests/files.py b/setuptools/tests/files.py index bad2189d..71194b9d 100644 --- a/setuptools/tests/files.py +++ b/setuptools/tests/files.py @@ -1,9 +1,6 @@ import os -import pkg_resources.py31compat - - def build_files(file_defs, prefix=""): """ Build a set of files/directories, as described by the @@ -30,7 +27,7 @@ def build_files(file_defs, prefix=""): for name, contents in file_defs.items(): full_name = os.path.join(prefix, name) if isinstance(contents, dict): - pkg_resources.py31compat.makedirs(full_name, exist_ok=True) + os.makedirs(full_name, exist_ok=True) build_files(contents, prefix=full_name) else: if isinstance(contents, bytes): diff --git a/setuptools/tests/test_manifest.py b/setuptools/tests/test_manifest.py index 2a0e9c86..042a8b17 100644 --- a/setuptools/tests/test_manifest.py +++ b/setuptools/tests/test_manifest.py @@ -10,7 +10,6 @@ import itertools from distutils import log from distutils.errors import DistutilsTemplateError -import pkg_resources.py31compat from setuptools.command.egg_info import FileList, egg_info, translate_pattern from setuptools.dist import Distribution from setuptools.extern import six @@ -364,7 +363,7 @@ class TestFileListTest(TempDirTestCase): for file in files: file = os.path.join(self.temp_dir, file) dirname, basename = os.path.split(file) - pkg_resources.py31compat.makedirs(dirname, exist_ok=True) + os.makedirs(dirname, exist_ok=True) open(file, 'w').close() def test_process_template_line(self): |