Commit 30831426 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #1973 from jdufresne/makedirs

Remove pkg_resources.py31compat.makedirs() in favor of the stdlib
parents 55bfb7d8 b3de7989
Removed ``pkg_resources.py31compat.makedirs`` in favor of the stdlib. Use ``os.makedirs()`` instead.
......@@ -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')
......@@ -3180,7 +3179,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):
......
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
......@@ -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] +
......
......@@ -63,7 +63,7 @@ from pkg_resources import (
Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound,
VersionConflict, DEVELOP_DIST,
)
import pkg_resources.py31compat
import pkg_resources
__metaclass__ = type
......@@ -564,7 +564,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()
......
......@@ -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
......
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):
......
......@@ -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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment