Commit 57a5c05e authored by Jason R. Coombs's avatar Jason R. Coombs

Move monkeypatching in package module into monkey.

parent d6efc942
"""Extensions to the 'distutils' for large or complex distributions"""
import os
import sys
import functools
import distutils.core
import distutils.filelist
......@@ -13,8 +12,8 @@ from setuptools.extern.six.moves import filterfalse, map
import setuptools.version
from setuptools.extension import Extension
from setuptools.dist import Distribution, Feature
from setuptools.monkey import _get_unpatched
from setuptools.depends import Require
from . import monkey
__all__ = [
'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
......@@ -122,7 +121,7 @@ find_packages = PackageFinder.find
setup = distutils.core.setup
_Command = _get_unpatched(distutils.core.Command)
_Command = monkey._get_unpatched(distutils.core.Command)
class Command(_Command):
......@@ -144,10 +143,6 @@ class Command(_Command):
return cmd
# we can't patch distutils.cmd, alas
distutils.core.Command = Command
def _find_all_simple(path):
"""
Find all files under 'path'
......@@ -172,31 +167,4 @@ def findall(dir=os.curdir):
return list(files)
has_issue_12885 = (
sys.version_info < (3, 4, 6)
or
(3, 5) < sys.version_info <= (3, 5, 3)
or
(3, 6) < sys.version_info
)
if has_issue_12885:
# fix findall bug in distutils (http://bugs.python.org/issue12885)
distutils.filelist.findall = findall
needs_warehouse = (
sys.version_info < (2, 7, 13)
or
(3, 0) < sys.version_info < (3, 3, 7)
or
(3, 4) < sys.version_info < (3, 4, 6)
or
(3, 5) < sys.version_info <= (3, 5, 3)
or
(3, 6) < sys.version_info
)
if needs_warehouse:
warehouse = 'https://upload.pypi.org/legacy/'
distutils.config.PyPIRCCommand.DEFAULT_REPOSITORY = warehouse
monkey.patch_all()
......@@ -2,6 +2,11 @@
Monkey patching of distutils.
"""
import sys
import distutils.filelist
import setuptools
__all__ = []
"everything is private"
......@@ -20,3 +25,36 @@ def _get_unpatched(cls):
"distutils has already been patched by %r" % cls
)
return cls
def patch_all():
# we can't patch distutils.cmd, alas
distutils.core.Command = setuptools.Command
has_issue_12885 = (
sys.version_info < (3, 4, 6)
or
(3, 5) < sys.version_info <= (3, 5, 3)
or
(3, 6) < sys.version_info
)
if has_issue_12885:
# fix findall bug in distutils (http://bugs.python.org/issue12885)
distutils.filelist.findall = setuptools.findall
needs_warehouse = (
sys.version_info < (2, 7, 13)
or
(3, 0) < sys.version_info < (3, 3, 7)
or
(3, 4) < sys.version_info < (3, 4, 6)
or
(3, 5) < sys.version_info <= (3, 5, 3)
or
(3, 6) < sys.version_info
)
if needs_warehouse:
warehouse = 'https://upload.pypi.org/legacy/'
distutils.config.PyPIRCCommand.DEFAULT_REPOSITORY = warehouse
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