Commit 04a306fa authored by Jason R. Coombs's avatar Jason R. Coombs

Use makedirs with future compatibility throughout setuptools. Ref #1083.

parent 902edffb
...@@ -59,7 +59,7 @@ from pkg_resources import ( ...@@ -59,7 +59,7 @@ from pkg_resources import (
Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound, Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound,
VersionConflict, DEVELOP_DIST, VersionConflict, DEVELOP_DIST,
) )
import pkg_resources import pkg_resources.py31compat
# Turn on PEP440Warnings # Turn on PEP440Warnings
warnings.filterwarnings("default", category=pkg_resources.PEP440Warning) warnings.filterwarnings("default", category=pkg_resources.PEP440Warning)
...@@ -544,8 +544,7 @@ class easy_install(Command): ...@@ -544,8 +544,7 @@ class easy_install(Command):
if ok_exists: if ok_exists:
os.unlink(ok_file) os.unlink(ok_file)
dirname = os.path.dirname(ok_file) dirname = os.path.dirname(ok_file)
if not os.path.exists(dirname): pkg_resources.py31compat.makedirs(dirname, exist_ok=True)
os.makedirs(dirname)
f = open(pth_file, 'w') f = open(pth_file, 'w')
except (OSError, IOError): except (OSError, IOError):
self.cant_write_to_target() self.cant_write_to_target()
......
...@@ -12,7 +12,7 @@ import textwrap ...@@ -12,7 +12,7 @@ import textwrap
from setuptools.extern import six from setuptools.extern import six
from setuptools.extern.six.moves import builtins, map from setuptools.extern.six.moves import builtins, map
import pkg_resources import pkg_resources.py31compat
if sys.platform.startswith('java'): if sys.platform.startswith('java'):
import org.python.modules.posix.PosixModule as _os import org.python.modules.posix.PosixModule as _os
...@@ -26,6 +26,7 @@ _open = open ...@@ -26,6 +26,7 @@ _open = open
from distutils.errors import DistutilsError from distutils.errors import DistutilsError
from pkg_resources import working_set from pkg_resources import working_set
__all__ = [ __all__ = [
"AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup", "AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup",
] ]
...@@ -73,8 +74,7 @@ def override_temp(replacement): ...@@ -73,8 +74,7 @@ def override_temp(replacement):
""" """
Monkey-patch tempfile.tempdir with replacement, ensuring it exists Monkey-patch tempfile.tempdir with replacement, ensuring it exists
""" """
if not os.path.isdir(replacement): pkg_resources.py31compat.makedirs(replacement, exist_ok=True)
os.makedirs(replacement)
saved = tempfile.tempdir saved = tempfile.tempdir
......
import os import os
import pkg_resources.py31compat
def build_files(file_defs, prefix=""): def build_files(file_defs, prefix=""):
""" """
Build a set of files/directories, as described by the file_defs dictionary. Build a set of files/directories, as described by the file_defs dictionary.
...@@ -24,8 +27,7 @@ def build_files(file_defs, prefix=""): ...@@ -24,8 +27,7 @@ def build_files(file_defs, prefix=""):
for name, contents in file_defs.items(): for name, contents in file_defs.items():
full_name = os.path.join(prefix, name) full_name = os.path.join(prefix, name)
if isinstance(contents, dict): if isinstance(contents, dict):
if not os.path.exists(full_name): pkg_resources.py31compat.makedirs(full_name, exist_ok=True)
os.makedirs(full_name)
build_files(contents, prefix=full_name) build_files(contents, prefix=full_name)
else: else:
with open(full_name, 'w') as f: with open(full_name, 'w') as f:
......
...@@ -10,6 +10,7 @@ import itertools ...@@ -10,6 +10,7 @@ import itertools
from distutils import log from distutils import log
from distutils.errors import DistutilsTemplateError from distutils.errors import DistutilsTemplateError
import pkg_resources.py31compat
from setuptools.command.egg_info import FileList, egg_info, translate_pattern from setuptools.command.egg_info import FileList, egg_info, translate_pattern
from setuptools.dist import Distribution from setuptools.dist import Distribution
from setuptools.extern import six from setuptools.extern import six
...@@ -361,8 +362,7 @@ class TestFileListTest(TempDirTestCase): ...@@ -361,8 +362,7 @@ class TestFileListTest(TempDirTestCase):
for file in files: for file in files:
file = os.path.join(self.temp_dir, file) file = os.path.join(self.temp_dir, file)
dirname, basename = os.path.split(file) dirname, basename = os.path.split(file)
if not os.path.exists(dirname): pkg_resources.py31compat.makedirs(dirname, exist_ok=True)
os.makedirs(dirname)
open(file, 'w').close() open(file, 'w').close()
def test_process_template_line(self): 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