Commit 952c1baf authored by Jason R. Coombs's avatar Jason R. Coombs

Modeling after Astropy's technique for bundling libraries, the imports are now...

Modeling after Astropy's technique for bundling libraries, the imports are now much cleaner. Thanks @embray. Ref #229.

--HG--
branch : feature/issue-229
parent 06872bb0
[pytest]
addopts=--doctest-modules --ignore release.py --ignore setuptools/lib2to3_ex.py --ignore tests/manual_test.py --ignore tests/shlib_test --doctest-glob=pkg_resources/api_tests.txt --ignore scripts/upload-old-releases-as-zip.py
norecursedirs=dist build *.egg
norecursedirs=dist build *.egg setuptools/extern
......@@ -8,12 +8,7 @@ from distutils.core import Command as _Command
from distutils.util import convert_path
from fnmatch import fnmatchcase
try:
from setuptools._vendor.six.moves import filterfalse
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
from six.moves import filterfalse
from setuptools.extern.six.moves import filterfalse
import setuptools.version
from setuptools.extension import Extension
......
......@@ -11,12 +11,7 @@ import os
import marshal
import textwrap
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
from pkg_resources import get_build_platform, Distribution, ensure_directory
from pkg_resources import EntryPoint
......
......@@ -5,12 +5,7 @@ import os
import glob
import io
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
from pkg_resources import Distribution, PathMetadata, normalize_path
from setuptools.command.easy_install import easy_install
......
......@@ -40,14 +40,8 @@ import subprocess
import shlex
import io
try:
from setuptools._vendor import six
from setuptools._vendor.six.moves import configparser
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from six.moves import configparser
from setuptools.extern import six
from setuptools.extern.six.moves import configparser
from setuptools import Command
from setuptools.sandbox import run_setup
......
......@@ -14,12 +14,7 @@ import io
import warnings
import time
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
from setuptools import Command
from setuptools.command.sdist import sdist
......
......@@ -3,12 +3,7 @@ from distutils import log
from distutils.errors import DistutilsOptionError
import os
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
from setuptools import Command
......
......@@ -5,12 +5,7 @@ import os
import sys
import io
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
from setuptools.utils import cs_path_exists
......
......@@ -4,12 +4,7 @@ from distutils.errors import DistutilsOptionError
import distutils
import os
try:
from setuptools._vendor.six.moves import configparser
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
from six.moves import configparser
from setuptools.extern.six.moves import configparser
from setuptools import Command
......
......@@ -2,12 +2,7 @@ from distutils.errors import DistutilsOptionError
from unittest import TestLoader
import sys
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
from pkg_resources import (resource_listdir, resource_exists, normalize_path,
working_set, _namespace_packages,
......
......@@ -16,14 +16,8 @@ import tempfile
import sys
import shutil
try:
from setuptools._vendor import six
from setuptools._vendor.six.moves import http_client, urllib
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from six.moves import http_client, urllib
from setuptools.extern import six
from setuptools.extern.six.moves import http_client, urllib
from pkg_resources import iter_entry_points
......
......@@ -4,12 +4,7 @@ import marshal
from imp import PKG_DIRECTORY, PY_COMPILED, PY_SOURCE, PY_FROZEN
from distutils.version import StrictVersion
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
__all__ = [
'Require', 'find_module', 'get_module_constant', 'extract_constant'
......
......@@ -13,12 +13,7 @@ from distutils.core import Distribution as _Distribution
from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
DistutilsSetupError)
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
from setuptools.depends import Require
from setuptools import windows_support
......
"""
Handle loading six package from system or from the bundled copy
"""
import imp
_SIX_SEARCH_PATH = ['setuptools._vendor.six', 'six']
def _find_module(name, path=None):
"""
Alternative to `imp.find_module` that can also search in subpackages.
"""
parts = name.split('.')
for part in parts:
if path is not None:
path = [path]
fh, path, descr = imp.find_module(part, path)
return fh, path, descr
def _import_six(search_path=_SIX_SEARCH_PATH):
for mod_name in search_path:
try:
mod_info = _find_module(mod_name)
except ImportError:
continue
imp.load_module(__name__, *mod_info)
break
else:
raise ImportError(
"The 'six' module of minimum version {0} is required; "
"normally this is bundled with this package so if you get "
"this warning, consult the packager of your "
"distribution.")
_import_six()
......@@ -14,14 +14,8 @@ try:
except ImportError:
from urllib2 import splituser
try:
from setuptools._vendor import six
from setuptools._vendor.six.moves import urllib, http_client, configparser
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from six.moves import urllib, http_client, configparser
from setuptools.extern import six
from setuptools.extern.six.moves import urllib, http_client, configparser
from pkg_resources import (
CHECKOUT_DIST, Distribution, BINARY_DIST, normalize_path, SOURCE_DIST,
......
......@@ -8,14 +8,8 @@ import re
import contextlib
import pickle
try:
from setuptools._vendor import six
from setuptools._vendor.six.moves import builtins
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from six.moves import builtins
from setuptools.extern import six
from setuptools.extern.six.moves import builtins
import pkg_resources
......
......@@ -3,12 +3,7 @@ import socket
import atexit
import re
try:
from setuptools._vendor.six.moves import urllib, http_client
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
from six.moves import urllib, http_client
from setuptools.extern.six.moves import urllib, http_client
import pkg_resources
from pkg_resources import ResolutionError, ExtractionError
......
......@@ -8,12 +8,7 @@ from distutils.errors import DistutilsSetupError
from distutils.core import Extension
from distutils.version import LooseVersion
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
import pytest
import setuptools.dist
......
......@@ -5,12 +5,7 @@ import sys
import contextlib
import site
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
@contextlib.contextmanager
......
......@@ -4,12 +4,7 @@
import time
import threading
try:
from setuptools._vendor.six.moves import BaseHTTPServer, SimpleHTTPServer
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
from six.moves import BaseHTTPServer, SimpleHTTPServer
from setuptools.extern.six.moves import BaseHTTPServer, SimpleHTTPServer
class IndexServer(BaseHTTPServer.HTTPServer):
......
......@@ -5,12 +5,7 @@ import site
import sys
import io
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
import pytest
......
......@@ -16,14 +16,8 @@ import itertools
import distutils.errors
import io
try:
from setuptools._vendor import six
from setuptools._vendor.six.moves import urllib
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from six.moves import urllib
from setuptools.extern import six
from setuptools.extern.six.moves import urllib
import pytest
try:
......
......@@ -7,14 +7,7 @@ import glob
import os
import sys
try:
from setuptools._vendor.six.moves import urllib
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
from six.moves import urllib
from setuptools.extern.six.moves import urllib
import pytest
from setuptools.command.easy_install import easy_install
......
......@@ -4,14 +4,8 @@ import sys
import os
import distutils.errors
try:
from setuptools._vendor import six
from setuptools._vendor.six.moves import urllib, http_client
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from six.moves import urllib, http_client
from setuptools.extern import six
from setuptools.extern.six.moves import urllib, http_client
from .textwrap import DALS
import pkg_resources
......
......@@ -9,12 +9,7 @@ import unicodedata
import contextlib
import io
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
import pytest
......
import unicodedata
import sys
try:
from setuptools._vendor import six
except ImportError:
# fallback to naturally-installed version; allows system packagers to
# omit vendored packages.
import six
from setuptools.extern import six
# HFS Plus uses decomposed UTF-8
def decompose(path):
......
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