diff --git a/.travis.yml b/.travis.yml index 1168db6cb..499ba276d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,30 @@ x-pyenv-shard: &x-pyenv-shard "${PYENV}" global ${PYENV_VERSION} pip install -U tox "setuptools>=36" +x-py27: &x-py27 PYENV_VERSION=2.7.15 + +x-py37: &x-py37 PYENV_VERSION=3.7.0 + +x-pypy: &x-pypy PYENV_VERSION=pypy2.7-6.0.0 + x-linux-shard: &x-linux-shard <<: *x-pyenv-shard os: linux sudo: false dist: trusty +x-linux-27-shard: &x-linux-27-shard + <<: *x-linux-shard + env: + - *env + - *x-py27 + +x-linux-pypy-shard: &x-linux-pypy-shard + <<: *x-linux-shard + env: + - *env + - *x-pypy + # Python 3.7 requires at least OpenSSL 1.0.2: # https://docs.python.org/3/whatsnew/3.7.html#platform-support-removals. # Travis' `trusty` image does not get us there and, at the time of writing, the beta `xenial` @@ -41,12 +59,12 @@ x-linux-37-shard: &x-linux-37-shard - openssl env: - *env + - *x-py37 - OPENSSL_VERSION=1.0.2p - OPENSSL_DIR="${HOME}/.pyenv_pex_openssl" - LD_LIBRARY_PATH="${OPENSSL_DIR}/lib" - SSL_CERT_DIR=/usr/lib/ssl/certs - PYTHON_CONFIGURE_OPTS="--with-openssl=${OPENSSL_DIR}" - - PYENV_VERSION=3.7.0 - TOX_TESTENV_PASSENV=SSL_CERT_DIR cache: <<: *cache @@ -72,56 +90,55 @@ x-osx-shard: &x-osx-shard os: osx osx_image: xcode9.4 -x-py27: &x-py27 - - *env - - PYENV_VERSION=2.7.15 +x-osx-ssl: &x-osx-ssl > + CPPFLAGS=-I/usr/local/opt/openssl/include + LDFLAGS=-L/usr/local/opt/openssl/lib -x-py37: &x-py37 - - *env - - PYENV_VERSION=3.7.0 +x-osx-27-shard: &x-osx-27-shard + <<: *x-osx-shard + env: + - *env + - *x-py27 + - *x-osx-ssl -x-pypy: &x-pypy - - *env - - PYENV_VERSION=pypy2.7-6.0.0 +x-osx-37-shard: &x-osx-37-shard + <<: *x-osx-shard + env: + - *env + - *x-py37 + - *x-osx-ssl # NB: Travis partitions caches using a combination of os, language amd env vars. As such, we do not # use TOXENV and instead pass the toxenv via -e on the command line. This helps ensure we share # caches as much as possible (eg: all linux python 2.7.15 shards share a cache). matrix: include: - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=style - env: *x-py27 script: tox -ve style - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=isort-check - env: *x-py27 script: tox -ve isort-check - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=vendor-check - env: *x-py27 script: tox -ve vendor-check - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=py27 - env: *x-py27 script: tox -ve py27 - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=py27-subprocess - env: *x-py27 script: tox -ve py27-subprocess - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=py27-requests - env: *x-py27 script: tox -ve py27-requests - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=py27-requests-cachecontrol - env: *x-py27 script: tox -ve py27-requests-cachecontrol - <<: *x-linux-shard @@ -157,41 +174,34 @@ matrix: name: TOXENV=py37-requests-cachecontrol script: tox -ve py37-requests-cachecontrol - - <<: *x-linux-shard + - <<: *x-linux-pypy-shard name: TOXENV=pypy - env: *x-pypy script: tox -ve pypy - - <<: *x-linux-shard + - <<: *x-linux-27-shard name: TOXENV=py27-integration - env: *x-py27 script: tox -ve py27-integration - <<: *x-linux-37-shard name: TOXENV=py37-integration script: tox -ve py37-integration - - <<: *x-linux-shard + - <<: *x-linux-pypy-shard name: TOXENV=pypy-integration - env: *x-pypy script: tox -ve pypy-integration - - <<: *x-osx-shard + - <<: *x-osx-27-shard name: TOXENV=py27-requests - env: *x-py27 script: tox -ve py27-requests - - <<: *x-osx-shard + - <<: *x-osx-37-shard name: TOXENV=py37-requests - env: *x-py37 script: tox -ve py37-requests - - <<: *x-osx-shard + - <<: *x-osx-27-shard name: TOXENV=py27-integration - env: *x-py27 script: tox -ve py27-integration - - <<: *x-osx-shard + - <<: *x-osx-37-shard name: TOXENV=py37-integration - env: *x-py37 script: tox -ve py37-integration diff --git a/pex/commands/bdist_pex.py b/pex/commands/bdist_pex.py index c5eee2d61..8136dd17c 100644 --- a/pex/commands/bdist_pex.py +++ b/pex/commands/bdist_pex.py @@ -5,6 +5,7 @@ import os import shlex +import subprocess import sys from distutils import log from distutils.core import Command @@ -122,8 +123,9 @@ def run(self): log.info('Writing environment pex into %s' % target) log.debug('Building pex via: {}'.format(' '.join(cmd))) - process = Executor.open_process(cmd, env=env) + process = Executor.open_process(cmd, stderr=subprocess.PIPE, env=env) _, stderr = process.communicate() result = process.returncode if result != 0: - die('Failed to create pex via {}:\n{}'.format(' '.join(cmd), stderr), result) + die('Failed to create pex via {}:\n{}'.format(' '.join(cmd), stderr.decode('utf-8')), + result) diff --git a/pex/installer.py b/pex/installer.py index 3ae8e98e5..37f7900a3 100644 --- a/pex/installer.py +++ b/pex/installer.py @@ -11,6 +11,7 @@ from pex.compatibility import WINDOWS from pex.executor import Executor from pex.interpreter import PythonInterpreter +from pex.orderedset import OrderedSet from pex.tracer import TRACER __all__ = ( @@ -22,12 +23,12 @@ def after_installation(function): def function_wrapper(self, *args, **kw): self._installed = self.run() if not self._installed: - raise InstallerBase.InstallFailure('Failed to install %s' % self._source_dir) + raise SetuptoolsInstallerBase.InstallFailure('Failed to install %s' % self._source_dir) return function(self, *args, **kw) return function_wrapper -class InstallerBase(object): +class SetuptoolsInstallerBase(object): class Error(Exception): pass class InstallFailure(Error): pass class IncapableInterpreter(Error): pass @@ -36,57 +37,59 @@ def __init__(self, source_dir, interpreter=None, install_dir=None): """Create an installer from an unpacked source distribution in source_dir.""" self._source_dir = source_dir self._install_tmp = install_dir or safe_mkdtemp() + self._interpreter = interpreter or PythonInterpreter.get() self._installed = None - from pex import vendor - self._interpreter = vendor.setup_interpreter(distributions=self.mixins, - interpreter=interpreter or PythonInterpreter.get()) - if not self._interpreter.satisfies(self.mixins): - raise self.IncapableInterpreter('Interpreter %s not capable of running %s' % ( - self._interpreter.binary, self.__class__.__name__)) - @property def mixins(self): - """Return a list of requirements to load into the setup script prior to invocation.""" - raise NotImplementedError() + """Return a list of extra distribution names required by the `setup_command`.""" + return [] @property def install_tmp(self): return self._install_tmp - def _setup_command(self): - """the setup command-line to run, to be implemented by subclasses.""" + def setup_command(self): + """The setup command-line to run, to be implemented by subclasses.""" raise NotImplementedError @property - def bootstrap_script(self): + def setup_py_wrapper(self): + # NB: It would be more direct to just over-write setup.py by pre-pending the setuptools import. + # We cannot do this however because we would then run afoul of setup.py files in the wild with + # from __future__ imports. This mode of injecting the import works around that issue. return """ -import sys -sys.path.insert(0, {root!r}) - -# Expose vendored mixin path_items (setuptools, wheel, etc.) directly to the package's setup.py. -from pex import third_party -third_party.install(root={root!r}, expose={mixins!r}) +# We need to allow setuptools to monkeypatch distutils in case the underlying setup.py uses +# distutils; otherwise, we won't have access to distutils commands installed via the +# `distutils.commands` `entrypoints` setup metadata (which is only supported by setuptools). +# The prime example here is `bdist_wheel` offered by the wheel dist. +import setuptools # Now execute the package's setup.py such that it sees itself as a setup.py executed via # `python setup.py ...` +import sys __file__ = 'setup.py' sys.argv[0] = __file__ with open(__file__, 'rb') as fp: exec(fp.read()) -""".format(root=third_party.isolated(), mixins=self.mixins) +""" def run(self): if self._installed is not None: return self._installed with TRACER.timed('Installing %s' % self._install_tmp, V=2): - command = [self._interpreter.binary, '-sE', '-'] + self._setup_command() + env = self._interpreter.sanitized_environment() + mixins = OrderedSet(['setuptools'] + self.mixins) + env['PYTHONPATH'] = os.pathsep.join(third_party.expose(mixins)) + env['__PEX_UNVENDORED__'] = '1' + + command = [self._interpreter.binary, '-s', '-'] + self.setup_command() try: Executor.execute(command, - env=self._interpreter.sanitized_environment(), + env=env, cwd=self._source_dir, - stdin_payload=self.bootstrap_script.encode('ascii')) + stdin_payload=self.setup_py_wrapper.encode('ascii')) self._installed = True except Executor.NonZeroExit as e: self._installed = False @@ -101,11 +104,8 @@ def cleanup(self): safe_rmtree(self._install_tmp) -class DistributionPackager(InstallerBase): - @property - def mixins(self): - return ['setuptools'] - +class DistributionPackager(SetuptoolsInstallerBase): + @after_installation def find_distribution(self): dists = os.listdir(self.install_tmp) if len(dists) == 0: @@ -119,13 +119,12 @@ def find_distribution(self): class Packager(DistributionPackager): """Create a source distribution from an unpacked setup.py-based project.""" - def _setup_command(self): + def setup_command(self): if WINDOWS: return ['sdist', '--formats=zip', '--dist-dir=%s' % self._install_tmp] else: return ['sdist', '--formats=gztar', '--dist-dir=%s' % self._install_tmp] - @after_installation def sdist(self): return self.find_distribution() @@ -133,10 +132,9 @@ def sdist(self): class EggInstaller(DistributionPackager): """Create an egg distribution from an unpacked setup.py-based project.""" - def _setup_command(self): + def setup_command(self): return ['bdist_egg', '--dist-dir=%s' % self._install_tmp] - @after_installation def bdist(self): return self.find_distribution() @@ -146,11 +144,10 @@ class WheelInstaller(DistributionPackager): @property def mixins(self): - return ['setuptools', 'wheel'] + return ['wheel'] - def _setup_command(self): + def setup_command(self): return ['bdist_wheel', '--dist-dir=%s' % self._install_tmp] - @after_installation def bdist(self): return self.find_distribution() diff --git a/pex/interpreter.py b/pex/interpreter.py index 8518a99b7..db8760a19 100644 --- a/pex/interpreter.py +++ b/pex/interpreter.py @@ -11,7 +11,6 @@ from collections import defaultdict from inspect import getsource -from pex.base import maybe_requirement from pex.compatibility import string from pex.executor import Executor from pex.pep425tags import ( @@ -376,8 +375,8 @@ def filter(cls, pythons): MAJOR, MINOR, SUBMINOR = range(3) def version_filter(version): - return (version[MAJOR] == 2 and version[MINOR] >= 6 or - version[MAJOR] == 3 and version[MINOR] >= 2) + return (version[MAJOR] == 2 and version[MINOR] >= 7 or + version[MAJOR] == 3 and version[MINOR] >= 4) all_versions = set(interpreter.identity.version for interpreter in pythons) good_versions = filter(version_filter, all_versions) @@ -403,41 +402,17 @@ def sanitized_environment(cls): env_copy.pop('MACOSX_DEPLOYMENT_TARGET', None) return env_copy - @classmethod - def replace(cls, requirement): - self = cls.get() - if self.identity.matches(requirement): - return False - for pi in cls.all(): - if pi.identity.matches(requirement): - break - else: - raise cls.InterpreterNotFound('Could not find interpreter matching filter!') - os.execve(pi.binary, [pi.binary] + sys.argv, cls.sanitized_environment()) - - def __init__(self, binary, identity, extras=None): + def __init__(self, binary, identity): """Construct a PythonInterpreter. You should probably PythonInterpreter.from_binary instead. :param binary: The full path of the python binary. :param identity: The :class:`PythonIdentity` of the PythonInterpreter. - :param extras: A mapping from (dist.key, dist.version) to dist.location - of the extras associated with this interpreter. """ self._binary = os.path.realpath(binary) - self._extras = extras or {} self._identity = identity - def with_extra(self, key, version, location): - extras = {(k, v): loc for (k, v), loc in self._extras.items() if k != key} - extras[(key, version)] = location - return self.__class__(self._binary, self._identity, extras) - - @property - def extras(self): - return self._extras.copy() - @property def binary(self): return self._binary @@ -458,18 +433,6 @@ def version(self): def version_string(self): return str(self._identity) - def satisfies(self, capability): - if not isinstance(capability, list): - raise TypeError('Capability must be a list, got %s' % type(capability)) - return not any(self.get_location(req) is None for req in capability) - - def get_location(self, req): - req = maybe_requirement(req) - for dist, location in self.extras.items(): - dist_name, dist_version = dist - if req.key == dist_name and dist_version in req: - return location - def __hash__(self): return hash((self._binary, self._identity)) @@ -484,4 +447,4 @@ def __lt__(self, other): return self.version < other.version def __repr__(self): - return '%s(%r, %r, %r)' % (self.__class__.__name__, self._binary, self._identity, self._extras) + return '%s(%r, %r)' % (self.__class__.__name__, self._binary, self._identity) diff --git a/pex/resolvable.py b/pex/resolvable.py index 31f68a9e6..2eeaaa5ab 100644 --- a/pex/resolvable.py +++ b/pex/resolvable.py @@ -10,7 +10,7 @@ from pex.base import maybe_requirement, requirement_is_exact from pex.compatibility import AbstractClass from pex.compatibility import string as compatibility_string -from pex.installer import InstallerBase, Packager +from pex.installer import Packager, SetuptoolsInstallerBase from pex.package import Package from pex.resolver_options import ResolverOptionsBuilder, ResolverOptionsInterface from pex.third_party.pkg_resources import Requirement, safe_extra @@ -267,7 +267,7 @@ def from_string(cls, requirement_string, options_builder, interpreter=None): packager = Packager(requirement_string, interpreter=interpreter) try: sdist = packager.sdist() - except InstallerBase.Error: + except SetuptoolsInstallerBase.Error: raise cls.InvalidRequirement('Could not create source distribution for %s' % requirement_string) package = Package.from_href(sdist) diff --git a/pex/third_party/__init__.py b/pex/third_party/__init__.py index e845b13a8..d3c14062e 100644 --- a/pex/third_party/__init__.py +++ b/pex/third_party/__init__.py @@ -208,20 +208,35 @@ def install_vendored(cls, prefix, root=None, expose=None): if expose: # But only expose the bits needed. - path_by_key = OrderedDict((spec.key, spec.relpath) for spec in vendor.iter_vendor_specs() - if spec.key in expose) - path_by_key['pex'] = root # The pex distribution itself is trivially available to expose. - - unexposed = set(expose) - set(path_by_key.keys()) - if unexposed: - raise ValueError('The following vendored dists are not available to expose: {}' - .format(', '.join(sorted(unexposed)))) - - exposed_paths = path_by_key.values() - for exposed_path in exposed_paths: - sys.path.insert(0, os.path.join(root, exposed_path)) + exposed_paths = [] + for path in cls.expose(expose, root): + sys.path.insert(0, path) + exposed_paths.append(os.path.relpath(path, root)) + vendor_importer._expose(exposed_paths) + @classmethod + def expose(cls, dists, root=None): + from pex import vendor + + root = cls._abs_root(root) + + def iter_available(): + yield 'pex', root # The pex distribution itself is trivially available to expose. + for spec in vendor.iter_vendor_specs(): + yield spec.key, spec.relpath + + path_by_key = OrderedDict((key, relpath) for key, relpath in iter_available() if key in dists) + + unexposed = set(dists) - set(path_by_key.keys()) + if unexposed: + raise ValueError('The following vendored dists are not available to expose: {}' + .format(', '.join(sorted(unexposed)))) + + exposed_paths = path_by_key.values() + for exposed_path in exposed_paths: + yield os.path.join(root, exposed_path) + @classmethod def install(cls, uninstallable, prefix, path_items, root=None, warning=None): """Install an importer for modules found under ``path_items`` at the given import ``prefix``. @@ -396,5 +411,24 @@ def install(root=None, expose=None): VendorImporter.install_vendored(prefix=import_prefix(), root=root, expose=expose) +def expose(dists): + """Exposes vendored code in isolated chroots. + + Any vendored distributions listed in ``dists`` will be unpacked to individual chroots for addition + to the ``sys.path``; ie: ``expose(['setuptools', 'wheel'])`` will unpack these vendored + distributions and yield the two chroot paths they were unpacked to. + + :param dists: A list of vendored distribution names to expose. + :type dists: list of str + :raise: :class:`ValueError` if any distributions to expose cannot be found. + :returns: An iterator of exposed vendored distribution chroot paths. + """ + from pex.common import safe_delete + + for path in VendorImporter.expose(dists, root=isolated()): + safe_delete(os.path.join(path, '__init__.py')) + yield path + + # Implicitly install an importer for vendored code on the first import of pex.third_party. install() diff --git a/pex/vendor/__init__.py b/pex/vendor/__init__.py index c80f6a58b..d331e1d16 100644 --- a/pex/vendor/__init__.py +++ b/pex/vendor/__init__.py @@ -143,7 +143,11 @@ def vendor_runtime(chroot, dest_basedir, label, root_module_names): pkg_file = os.path.join(pkg_path, '__init__.py') src = os.path.join(VendorSpec.ROOT, pkg_file) dest = os.path.join(dest_basedir, pkg_file) - chroot.copy(src, dest, label) + if os.path.exists(src): + chroot.copy(src, dest, label) + else: + # We delete `pex/vendor/_vendored//__init__.py` when isolating third_party. + chroot.touch(dest, label) for name in vendored_names: vendor_module_names[name] = True TRACER.log('Vendoring {} from {} @ {}'.format(name, spec, spec.target_dir), V=3) diff --git a/pex/vendor/__main__.py b/pex/vendor/__main__.py index 1bda990a4..b06f8b680 100644 --- a/pex/vendor/__main__.py +++ b/pex/vendor/__main__.py @@ -61,6 +61,16 @@ def _find_literal_node(statement, call_argument): elif isinstance(call_argument.value, LiteralyEvaluable): return call_argument.value + @staticmethod + def _modify_import(original, modified): + indent = ' ' * (modified.absolute_bounding_box.top_left.column - 1) + return os.linesep.join(indent + line for line in ( + 'if "__PEX_UNVENDORED__" in __import__("os").environ:', + ' {} # vendor:skip'.format(original), + 'else:', + ' {}'.format(modified), + )) + @classmethod def for_path_items(cls, prefix, path_items): pkg_names = frozenset(pkg_name for _, pkg_name, _ in pkgutil.iter_modules(path=path_items)) @@ -98,10 +108,13 @@ def _modify__import__calls(self, red_baron): # noqa: We want __import__ as part root_package = value.split('.')[0] if root_package in self._packages: raw_value.replace('{!r}'.format(self._prefix + '.' + value)) + + parent.replace(self._modify_import(original, parent)) yield original, parent def _modify_import_statements(self, red_baron): for import_node in red_baron.find_all('ImportNode'): + modified = False if self._skip(import_node): continue @@ -129,6 +142,7 @@ def _modify_import_statements(self, red_baron): # imported). This ensures the code can traverse from the re-named root - `a` in this # example, through middle nodes (`a.b`) all the way to the leaf target (`a.b.c`). + modified = True def prefixed_fullname(): return '{prefix}.{module}'.format(prefix=self._prefix, module='.'.join(map(str, import_module))) @@ -144,6 +158,8 @@ def prefixed_fullname(): root=root_package.value) import_module.target = root_package.value + if modified: + import_node.replace(self._modify_import(original, import_node)) yield original, import_node def _modify_from_import_statements(self, red_baron): @@ -161,6 +177,8 @@ def _modify_from_import_statements(self, red_baron): if root_package.value in self._packages: root_package.replace('{prefix}.{root}'.format(prefix=self._prefix, root=root_package.value)) + + from_import_node.replace(self._modify_import(original, from_import_node)) yield original, from_import_node diff --git a/pex/vendor/_vendored/setuptools/pkg_resources/__init__.py b/pex/vendor/_vendored/setuptools/pkg_resources/__init__.py index 986a863e2..e31218395 100644 --- a/pex/vendor/_vendored/setuptools/pkg_resources/__init__.py +++ b/pex/vendor/_vendored/setuptools/pkg_resources/__init__.py @@ -52,8 +52,16 @@ except NameError: FileExistsError = OSError -from pex.third_party.pkg_resources.extern import six -from pex.third_party.pkg_resources.extern.six.moves import urllib, map, filter +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern import six # vendor:skip +else: + from pex.third_party.pkg_resources.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.six.moves import urllib, map, filter # vendor:skip +else: + from pex.third_party.pkg_resources.extern.six.moves import urllib, map, filter + # capture these to bypass sandboxing from os import utime @@ -75,12 +83,36 @@ importlib_machinery = None from . import py31compat -from pex.third_party.pkg_resources.extern import appdirs -from pex.third_party.pkg_resources.extern import packaging -__import__('pex.third_party.pkg_resources.extern.packaging.version') -__import__('pex.third_party.pkg_resources.extern.packaging.specifiers') -__import__('pex.third_party.pkg_resources.extern.packaging.requirements') -__import__('pex.third_party.pkg_resources.extern.packaging.markers') +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern import appdirs # vendor:skip +else: + from pex.third_party.pkg_resources.extern import appdirs + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern import packaging # vendor:skip +else: + from pex.third_party.pkg_resources.extern import packaging + +if "__PEX_UNVENDORED__" in __import__("os").environ: + __import__('pkg_resources.extern.packaging.version') # vendor:skip +else: + __import__('pex.third_party.pkg_resources.extern.packaging.version') + +if "__PEX_UNVENDORED__" in __import__("os").environ: + __import__('pkg_resources.extern.packaging.specifiers') # vendor:skip +else: + __import__('pex.third_party.pkg_resources.extern.packaging.specifiers') + +if "__PEX_UNVENDORED__" in __import__("os").environ: + __import__('pkg_resources.extern.packaging.requirements') # vendor:skip +else: + __import__('pex.third_party.pkg_resources.extern.packaging.requirements') + +if "__PEX_UNVENDORED__" in __import__("os").environ: + __import__('pkg_resources.extern.packaging.markers') # vendor:skip +else: + __import__('pex.third_party.pkg_resources.extern.packaging.markers') + __metaclass__ = type diff --git a/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/markers.py b/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/markers.py index fc27edf4a..953d408af 100644 --- a/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/markers.py +++ b/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/markers.py @@ -8,9 +8,21 @@ import platform import sys -from pex.third_party.pkg_resources.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd -from pex.third_party.pkg_resources.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString -from pex.third_party.pkg_resources.extern.pyparsing import Literal as L # noqa +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd # vendor:skip +else: + from pex.third_party.pkg_resources.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString # vendor:skip +else: + from pex.third_party.pkg_resources.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.pyparsing import Literal as L # vendor:skip +else: + from pex.third_party.pkg_resources.extern.pyparsing import Literal as L + # noqa from ._compat import string_types from .specifiers import Specifier, InvalidSpecifier diff --git a/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/requirements.py b/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/requirements.py index 3a138e5ae..fb42a954a 100644 --- a/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/requirements.py +++ b/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/requirements.py @@ -6,10 +6,26 @@ import string import re -from pex.third_party.pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException -from pex.third_party.pkg_resources.extern.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine -from pex.third_party.pkg_resources.extern.pyparsing import Literal as L # noqa -from pex.third_party.pkg_resources.extern.six.moves.urllib import parse as urlparse +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException # vendor:skip +else: + from pex.third_party.pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine # vendor:skip +else: + from pex.third_party.pkg_resources.extern.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.pyparsing import Literal as L # vendor:skip +else: + from pex.third_party.pkg_resources.extern.pyparsing import Literal as L + # noqa +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources.extern.six.moves.urllib import parse as urlparse # vendor:skip +else: + from pex.third_party.pkg_resources.extern.six.moves.urllib import parse as urlparse + from .markers import MARKER_EXPR, Marker from .specifiers import LegacySpecifier, Specifier, SpecifierSet diff --git a/pex/vendor/_vendored/setuptools/setuptools/__init__.py b/pex/vendor/_vendored/setuptools/setuptools/__init__.py index 47648607b..f613df9c9 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/__init__.py +++ b/pex/vendor/_vendored/setuptools/setuptools/__init__.py @@ -10,13 +10,37 @@ from ._deprecation_warning import SetuptoolsDeprecationWarning -from pex.third_party.setuptools.extern.six import PY3 -from pex.third_party.setuptools.extern.six.moves import filter, map +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six import PY3 # vendor:skip +else: + from pex.third_party.setuptools.extern.six import PY3 + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import filter, map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import filter, map + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools.version # vendor:skip +else: + import pex.third_party.setuptools.version, pex.third_party.setuptools as setuptools + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extension import Extension # vendor:skip +else: + from pex.third_party.setuptools.extension import Extension + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.dist import Distribution, Feature # vendor:skip +else: + from pex.third_party.setuptools.dist import Distribution, Feature + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.depends import Require # vendor:skip +else: + from pex.third_party.setuptools.depends import Require -import pex.third_party.setuptools.version, pex.third_party.setuptools as setuptools -from pex.third_party.setuptools.extension import Extension -from pex.third_party.setuptools.dist import Distribution, Feature -from pex.third_party.setuptools.depends import Require from . import monkey __metaclass__ = type diff --git a/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/markers.py b/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/markers.py index 5892bd4ed..d86fb71d7 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/markers.py +++ b/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/markers.py @@ -8,9 +8,21 @@ import platform import sys -from pex.third_party.setuptools.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd -from pex.third_party.setuptools.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString -from pex.third_party.setuptools.extern.pyparsing import Literal as L # noqa +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd # vendor:skip +else: + from pex.third_party.setuptools.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString # vendor:skip +else: + from pex.third_party.setuptools.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.pyparsing import Literal as L # vendor:skip +else: + from pex.third_party.setuptools.extern.pyparsing import Literal as L + # noqa from ._compat import string_types from .specifiers import Specifier, InvalidSpecifier diff --git a/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/requirements.py b/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/requirements.py index e0b91ed9c..907fac057 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/requirements.py +++ b/pex/vendor/_vendored/setuptools/setuptools/_vendor/packaging/requirements.py @@ -6,10 +6,26 @@ import string import re -from pex.third_party.setuptools.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException -from pex.third_party.setuptools.extern.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine -from pex.third_party.setuptools.extern.pyparsing import Literal as L # noqa -from pex.third_party.setuptools.extern.six.moves.urllib import parse as urlparse +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException # vendor:skip +else: + from pex.third_party.setuptools.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine # vendor:skip +else: + from pex.third_party.setuptools.extern.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.pyparsing import Literal as L # vendor:skip +else: + from pex.third_party.setuptools.extern.pyparsing import Literal as L + # noqa +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves.urllib import parse as urlparse # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves.urllib import parse as urlparse + from .markers import MARKER_EXPR, Marker from .specifiers import LegacySpecifier, Specifier, SpecifierSet diff --git a/pex/vendor/_vendored/setuptools/setuptools/archive_util.py b/pex/vendor/_vendored/setuptools/setuptools/archive_util.py index 63f0608c2..3fccb4819 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/archive_util.py +++ b/pex/vendor/_vendored/setuptools/setuptools/archive_util.py @@ -8,7 +8,11 @@ import contextlib from distutils.errors import DistutilsError -from pex.third_party.pkg_resources import ensure_directory +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import ensure_directory # vendor:skip +else: + from pex.third_party.pkg_resources import ensure_directory + __all__ = [ "unpack_archive", "unpack_zipfile", "unpack_tarfile", "default_filter", diff --git a/pex/vendor/_vendored/setuptools/setuptools/build_meta.py b/pex/vendor/_vendored/setuptools/setuptools/build_meta.py index 93a572489..4f842cdde 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/build_meta.py +++ b/pex/vendor/_vendored/setuptools/setuptools/build_meta.py @@ -32,7 +32,11 @@ import shutil import contextlib -import pex.third_party.setuptools as setuptools +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools # vendor:skip +else: + import pex.third_party.setuptools as setuptools + import distutils diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/__init__.py b/pex/vendor/_vendored/setuptools/setuptools/command/__init__.py index 548a80f45..141ba62a3 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/__init__.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/__init__.py @@ -9,7 +9,11 @@ from distutils.command.bdist import bdist import sys -from pex.third_party.setuptools.command import install_scripts +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command import install_scripts # vendor:skip +else: + from pex.third_party.setuptools.command import install_scripts + if 'egg' not in bdist.format_commands: bdist.format_command['egg'] = ('bdist_egg', "Python .egg file") diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/alias.py b/pex/vendor/_vendored/setuptools/setuptools/command/alias.py index 98e5be6b3..cc5438d48 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/alias.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/alias.py @@ -1,8 +1,16 @@ from distutils.errors import DistutilsOptionError -from pex.third_party.setuptools.extern.six.moves import map +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import map + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.setopt import edit_config, option_base, config_file # vendor:skip +else: + from pex.third_party.setuptools.command.setopt import edit_config, option_base, config_file -from pex.third_party.setuptools.command.setopt import edit_config, option_base, config_file def shquote(arg): diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/bdist_egg.py b/pex/vendor/_vendored/setuptools/setuptools/command/bdist_egg.py index 2f8323fb1..78583b33c 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/bdist_egg.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/bdist_egg.py @@ -12,12 +12,32 @@ import textwrap import marshal -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import get_build_platform, Distribution, ensure_directory # vendor:skip +else: + from pex.third_party.pkg_resources import get_build_platform, Distribution, ensure_directory + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import EntryPoint # vendor:skip +else: + from pex.third_party.pkg_resources import EntryPoint + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extension import Library # vendor:skip +else: + from pex.third_party.setuptools.extension import Library + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Command # vendor:skip +else: + from pex.third_party.setuptools import Command -from pex.third_party.pkg_resources import get_build_platform, Distribution, ensure_directory -from pex.third_party.pkg_resources import EntryPoint -from pex.third_party.setuptools.extension import Library -from pex.third_party.setuptools import Command try: # Python 2.7 or >=3.2 diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/build_clib.py b/pex/vendor/_vendored/setuptools/setuptools/command/build_clib.py index db5fae281..d19c18f09 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/build_clib.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/build_clib.py @@ -1,7 +1,11 @@ import distutils.command.build_clib as orig from distutils.errors import DistutilsSetupError from distutils import log -from pex.third_party.setuptools.dep_util import newer_pairwise_group +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.dep_util import newer_pairwise_group # vendor:skip +else: + from pex.third_party.setuptools.dep_util import newer_pairwise_group + class build_clib(orig.build_clib): diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/build_ext.py b/pex/vendor/_vendored/setuptools/setuptools/command/build_ext.py index 365b43eca..6a43122ef 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/build_ext.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/build_ext.py @@ -9,8 +9,16 @@ from distutils.errors import DistutilsError from distutils import log -from pex.third_party.setuptools.extension import Library -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extension import Library # vendor:skip +else: + from pex.third_party.setuptools.extension import Library + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + try: # Attempt to use Cython for building extensions, if available diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/build_py.py b/pex/vendor/_vendored/setuptools/setuptools/command/build_py.py index 151476a55..86d5f4dae 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/build_py.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/build_py.py @@ -8,11 +8,23 @@ import distutils.errors import itertools -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import map, filter, filterfalse +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import map, filter, filterfalse # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import map, filter, filterfalse + try: - from pex.third_party.setuptools.lib2to3_ex import Mixin2to3 + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.lib2to3_ex import Mixin2to3 # vendor:skip + else: + from pex.third_party.setuptools.lib2to3_ex import Mixin2to3 + except ImportError: class Mixin2to3: diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/develop.py b/pex/vendor/_vendored/setuptools/setuptools/command/develop.py index 50dc10782..a71a494d6 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/develop.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/develop.py @@ -5,12 +5,32 @@ import glob import io -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import Distribution, PathMetadata, normalize_path # vendor:skip +else: + from pex.third_party.pkg_resources import Distribution, PathMetadata, normalize_path + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.easy_install import easy_install # vendor:skip +else: + from pex.third_party.setuptools.command.easy_install import easy_install + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import namespaces # vendor:skip +else: + from pex.third_party.setuptools import namespaces + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools # vendor:skip +else: + import pex.third_party.setuptools as setuptools -from pex.third_party.pkg_resources import Distribution, PathMetadata, normalize_path -from pex.third_party.setuptools.command.easy_install import easy_install -from pex.third_party.setuptools import namespaces -import pex.third_party.setuptools as setuptools __metaclass__ = type diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/easy_install.py b/pex/vendor/_vendored/setuptools/setuptools/command/easy_install.py index cfd61cfcc..365c4b4cf 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/easy_install.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/easy_install.py @@ -43,28 +43,87 @@ from sysconfig import get_config_vars, get_path -from pex.third_party.setuptools import SetuptoolsDeprecationWarning +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import SetuptoolsDeprecationWarning # vendor:skip +else: + from pex.third_party.setuptools import SetuptoolsDeprecationWarning + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import configparser, map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import configparser, map + -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import configparser, map +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Command # vendor:skip +else: + from pex.third_party.setuptools import Command + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.sandbox import run_setup # vendor:skip +else: + from pex.third_party.setuptools.sandbox import run_setup -from pex.third_party.setuptools import Command -from pex.third_party.setuptools.sandbox import run_setup -from pex.third_party.setuptools.py27compat import rmtree_safe -from pex.third_party.setuptools.command import setopt -from pex.third_party.setuptools.archive_util import unpack_archive -from pex.third_party.setuptools.package_index import ( +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.py27compat import rmtree_safe # vendor:skip +else: + from pex.third_party.setuptools.py27compat import rmtree_safe + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command import setopt # vendor:skip +else: + from pex.third_party.setuptools.command import setopt + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.archive_util import unpack_archive # vendor:skip +else: + from pex.third_party.setuptools.archive_util import unpack_archive + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.package_index import ( + PackageIndex, parse_requirement_arg, URL_SCHEME, +) # vendor:skip +else: + from pex.third_party.setuptools.package_index import ( PackageIndex, parse_requirement_arg, URL_SCHEME, ) -from pex.third_party.setuptools.command import bdist_egg, egg_info -from pex.third_party.setuptools.wheel import Wheel -from pex.third_party.pkg_resources import ( + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command import bdist_egg, egg_info # vendor:skip +else: + from pex.third_party.setuptools.command import bdist_egg, egg_info + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.wheel import Wheel # vendor:skip +else: + from pex.third_party.setuptools.wheel import Wheel + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import ( + yield_lines, normalize_path, resource_string, ensure_directory, + get_distribution, find_distributions, Environment, Requirement, + Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound, + VersionConflict, DEVELOP_DIST, +) # vendor:skip +else: + from pex.third_party.pkg_resources import ( yield_lines, normalize_path, resource_string, ensure_directory, get_distribution, find_distributions, Environment, Requirement, Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound, VersionConflict, DEVELOP_DIST, ) -import pex.third_party.pkg_resources.py31compat, pex.third_party.pkg_resources as pkg_resources + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources.py31compat # vendor:skip +else: + import pex.third_party.pkg_resources.py31compat, pex.third_party.pkg_resources as pkg_resources + __metaclass__ = type @@ -2286,7 +2345,11 @@ def current_umask(): def bootstrap(): # This function is called when setuptools*.egg is run using /bin/sh - import pex.third_party.setuptools as setuptools + if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools # vendor:skip + else: + import pex.third_party.setuptools as setuptools + argv0 = os.path.dirname(setuptools.__path__[0]) sys.argv[0] = argv0 @@ -2295,8 +2358,16 @@ def bootstrap(): def main(argv=None, **kw): - from pex.third_party.setuptools import setup - from pex.third_party.setuptools.dist import Distribution + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import setup # vendor:skip + else: + from pex.third_party.setuptools import setup + + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.dist import Distribution # vendor:skip + else: + from pex.third_party.setuptools.dist import Distribution + class DistributionWithoutHelpCommands(Distribution): common_usage = "" diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/egg_info.py b/pex/vendor/_vendored/setuptools/setuptools/command/egg_info.py index d762e3da6..61c756b08 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/egg_info.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/egg_info.py @@ -16,22 +16,72 @@ import time import collections -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import map - -from pex.third_party.setuptools import Command -from pex.third_party.setuptools.command.sdist import sdist -from pex.third_party.setuptools.command.sdist import walk_revctrl -from pex.third_party.setuptools.command.setopt import edit_config -from pex.third_party.setuptools.command import bdist_egg -from pex.third_party.pkg_resources import ( +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import map + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Command # vendor:skip +else: + from pex.third_party.setuptools import Command + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.sdist import sdist # vendor:skip +else: + from pex.third_party.setuptools.command.sdist import sdist + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.sdist import walk_revctrl # vendor:skip +else: + from pex.third_party.setuptools.command.sdist import walk_revctrl + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.setopt import edit_config # vendor:skip +else: + from pex.third_party.setuptools.command.setopt import edit_config + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command import bdist_egg # vendor:skip +else: + from pex.third_party.setuptools.command import bdist_egg + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import ( + parse_requirements, safe_name, parse_version, + safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) # vendor:skip +else: + from pex.third_party.pkg_resources import ( parse_requirements, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) -import pex.third_party.setuptools.unicode_utils as unicode_utils -from pex.third_party.setuptools.glob import glob -from pex.third_party.setuptools.extern import packaging -from pex.third_party.setuptools import SetuptoolsDeprecationWarning +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools.unicode_utils as unicode_utils # vendor:skip +else: + import pex.third_party.setuptools.unicode_utils as unicode_utils + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.glob import glob # vendor:skip +else: + from pex.third_party.setuptools.glob import glob + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import packaging # vendor:skip +else: + from pex.third_party.setuptools.extern import packaging + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import SetuptoolsDeprecationWarning # vendor:skip +else: + from pex.third_party.setuptools import SetuptoolsDeprecationWarning + def translate_pattern(glob): """ diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/install.py b/pex/vendor/_vendored/setuptools/setuptools/command/install.py index 2569b932f..acd1c52b7 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/install.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/install.py @@ -5,7 +5,11 @@ import platform import distutils.command.install as orig -import pex.third_party.setuptools as setuptools +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools # vendor:skip +else: + import pex.third_party.setuptools as setuptools + # Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for # now. See https://github.com/pypa/setuptools/issues/199/ diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/install_egg_info.py b/pex/vendor/_vendored/setuptools/setuptools/command/install_egg_info.py index 6358d733d..202d8276a 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/install_egg_info.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/install_egg_info.py @@ -1,10 +1,26 @@ from distutils import log, dir_util import os -from pex.third_party.setuptools import Command -from pex.third_party.setuptools import namespaces -from pex.third_party.setuptools.archive_util import unpack_archive -import pex.third_party.pkg_resources as pkg_resources +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Command # vendor:skip +else: + from pex.third_party.setuptools import Command + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import namespaces # vendor:skip +else: + from pex.third_party.setuptools import namespaces + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.archive_util import unpack_archive # vendor:skip +else: + from pex.third_party.setuptools.archive_util import unpack_archive + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip +else: + import pex.third_party.pkg_resources as pkg_resources + class install_egg_info(namespaces.Installer, Command): diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/install_lib.py b/pex/vendor/_vendored/setuptools/setuptools/command/install_lib.py index 962b0639a..89d7f1472 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/install_lib.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/install_lib.py @@ -95,7 +95,11 @@ def copy_tree( # Exclude namespace package __init__.py* files from the output - from pex.third_party.setuptools.archive_util import unpack_directory + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.archive_util import unpack_directory # vendor:skip + else: + from pex.third_party.setuptools.archive_util import unpack_directory + from distutils import log outfiles = [] diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/install_scripts.py b/pex/vendor/_vendored/setuptools/setuptools/command/install_scripts.py index 2b9f842bf..f42a8ff01 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/install_scripts.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/install_scripts.py @@ -3,7 +3,11 @@ import os import sys -from pex.third_party.pkg_resources import Distribution, PathMetadata, ensure_directory +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import Distribution, PathMetadata, ensure_directory # vendor:skip +else: + from pex.third_party.pkg_resources import Distribution, PathMetadata, ensure_directory + class install_scripts(orig.install_scripts): @@ -14,7 +18,11 @@ def initialize_options(self): self.no_ep = False def run(self): - import pex.third_party.setuptools.command.easy_install as ei + if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools.command.easy_install as ei # vendor:skip + else: + import pex.third_party.setuptools.command.easy_install as ei + self.run_command("egg_info") if self.distribution.scripts: @@ -50,7 +58,11 @@ def run(self): def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" - from pex.third_party.setuptools.command.easy_install import chmod, current_umask + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.easy_install import chmod, current_umask # vendor:skip + else: + from pex.third_party.setuptools.command.easy_install import chmod, current_umask + log.info("Installing %s script to %s", script_name, self.install_dir) target = os.path.join(self.install_dir, script_name) diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/py36compat.py b/pex/vendor/_vendored/setuptools/setuptools/command/py36compat.py index edc8c4d9d..33ff76e9e 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/py36compat.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/py36compat.py @@ -3,7 +3,11 @@ from distutils.util import convert_path from distutils.command import sdist -from pex.third_party.setuptools.extern.six.moves import filter +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import filter # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import filter + class sdist_add_defaults: diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/rotate.py b/pex/vendor/_vendored/setuptools/setuptools/command/rotate.py index dfa2a791d..b263acc27 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/rotate.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/rotate.py @@ -4,9 +4,17 @@ import os import shutil -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Command # vendor:skip +else: + from pex.third_party.setuptools import Command -from pex.third_party.setuptools import Command class rotate(Command): diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/saveopts.py b/pex/vendor/_vendored/setuptools/setuptools/command/saveopts.py index adedf8dea..59ac03db5 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/saveopts.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/saveopts.py @@ -1,4 +1,8 @@ -from pex.third_party.setuptools.command.setopt import edit_config, option_base +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.setopt import edit_config, option_base # vendor:skip +else: + from pex.third_party.setuptools.command.setopt import edit_config, option_base + class saveopts(option_base): diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/sdist.py b/pex/vendor/_vendored/setuptools/setuptools/command/sdist.py index 2fec7deae..d0abb6769 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/sdist.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/sdist.py @@ -5,11 +5,19 @@ import io import contextlib -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + from .py36compat import sdist_add_defaults -import pex.third_party.pkg_resources as pkg_resources +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip +else: + import pex.third_party.pkg_resources as pkg_resources + _default_revctrl = list diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/setopt.py b/pex/vendor/_vendored/setuptools/setuptools/command/setopt.py index 666ba02d4..dcef5b9d4 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/setopt.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/setopt.py @@ -4,9 +4,17 @@ import distutils import os -from pex.third_party.setuptools.extern.six.moves import configparser +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import configparser # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import configparser + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Command # vendor:skip +else: + from pex.third_party.setuptools import Command -from pex.third_party.setuptools import Command __all__ = ['config_file', 'edit_config', 'option_base', 'setopt'] diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/test.py b/pex/vendor/_vendored/setuptools/setuptools/command/test.py index 0150a94a1..191b38f24 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/test.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/test.py @@ -8,13 +8,31 @@ from distutils import log from unittest import TestLoader -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import map, filter +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six -from pex.third_party.pkg_resources import (resource_listdir, resource_exists, normalize_path, +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import map, filter # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import map, filter + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import (resource_listdir, resource_exists, normalize_path, + working_set, _namespace_packages, evaluate_marker, + add_activation_listener, require, EntryPoint) # vendor:skip +else: + from pex.third_party.pkg_resources import (resource_listdir, resource_exists, normalize_path, working_set, _namespace_packages, evaluate_marker, add_activation_listener, require, EntryPoint) -from pex.third_party.setuptools import Command + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Command # vendor:skip +else: + from pex.third_party.setuptools import Command + __metaclass__ = type diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/upload.py b/pex/vendor/_vendored/setuptools/setuptools/command/upload.py index 9358cf598..ff2370639 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/upload.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/upload.py @@ -12,9 +12,21 @@ from distutils.errors import DistutilsError -from pex.third_party.setuptools.extern.six.moves.urllib.request import urlopen, Request -from pex.third_party.setuptools.extern.six.moves.urllib.error import HTTPError -from pex.third_party.setuptools.extern.six.moves.urllib.parse import urlparse +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves.urllib.request import urlopen, Request # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves.urllib.request import urlopen, Request + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves.urllib.error import HTTPError # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves.urllib.error import HTTPError + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves.urllib.parse import urlparse # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves.urllib.parse import urlparse + class upload(orig.upload): """ diff --git a/pex/vendor/_vendored/setuptools/setuptools/command/upload_docs.py b/pex/vendor/_vendored/setuptools/setuptools/command/upload_docs.py index ffba7a893..d5dfd4931 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/command/upload_docs.py +++ b/pex/vendor/_vendored/setuptools/setuptools/command/upload_docs.py @@ -16,10 +16,22 @@ import itertools import functools -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import http_client, urllib +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import http_client, urllib # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import http_client, urllib + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import iter_entry_points # vendor:skip +else: + from pex.third_party.pkg_resources import iter_entry_points -from pex.third_party.pkg_resources import iter_entry_points from .upload import upload diff --git a/pex/vendor/_vendored/setuptools/setuptools/config.py b/pex/vendor/_vendored/setuptools/setuptools/config.py index 9cd5cd64e..f46588fee 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/config.py +++ b/pex/vendor/_vendored/setuptools/setuptools/config.py @@ -11,8 +11,16 @@ from importlib import import_module from distutils.errors import DistutilsOptionError, DistutilsFileError -from pex.third_party.setuptools.extern.packaging.version import LegacyVersion, parse -from pex.third_party.setuptools.extern.six import string_types, PY3 +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.packaging.version import LegacyVersion, parse # vendor:skip +else: + from pex.third_party.setuptools.extern.packaging.version import LegacyVersion, parse + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six import string_types, PY3 # vendor:skip +else: + from pex.third_party.setuptools.extern.six import string_types, PY3 + __metaclass__ = type @@ -35,7 +43,11 @@ def read_configuration( :rtype: dict """ - from pex.third_party.setuptools.dist import Distribution, _Distribution + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.dist import Distribution, _Distribution # vendor:skip + else: + from pex.third_party.setuptools.dist import Distribution, _Distribution + filepath = os.path.abspath(filepath) @@ -557,9 +569,17 @@ def _parse_packages(self, value): self.sections.get('packages.find', {})) if findns: - from pex.third_party.setuptools import find_namespace_packages as find_packages + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import find_namespace_packages as find_packages # vendor:skip + else: + from pex.third_party.setuptools import find_namespace_packages as find_packages + else: - from pex.third_party.setuptools import find_packages + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import find_packages # vendor:skip + else: + from pex.third_party.setuptools import find_packages + return find_packages(**find_kwargs) diff --git a/pex/vendor/_vendored/setuptools/setuptools/dist.py b/pex/vendor/_vendored/setuptools/setuptools/dist.py index ba649a2bd..1364c6c8e 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/dist.py +++ b/pex/vendor/_vendored/setuptools/setuptools/dist.py @@ -21,21 +21,61 @@ from distutils.util import rfc822_escape from distutils.version import StrictVersion -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern import packaging -from pex.third_party.setuptools.extern.six.moves import map, filter, filterfalse +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import packaging # vendor:skip +else: + from pex.third_party.setuptools.extern import packaging + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import map, filter, filterfalse # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import map, filter, filterfalse + from . import SetuptoolsDeprecationWarning -from pex.third_party.setuptools.depends import Require -from pex.third_party.setuptools import windows_support -from pex.third_party.setuptools.monkey import get_unpatched -from pex.third_party.setuptools.config import parse_configuration -import pex.third_party.pkg_resources as pkg_resources +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.depends import Require # vendor:skip +else: + from pex.third_party.setuptools.depends import Require + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import windows_support # vendor:skip +else: + from pex.third_party.setuptools import windows_support + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.monkey import get_unpatched # vendor:skip +else: + from pex.third_party.setuptools.monkey import get_unpatched + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.config import parse_configuration # vendor:skip +else: + from pex.third_party.setuptools.config import parse_configuration + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip +else: + import pex.third_party.pkg_resources as pkg_resources + from .py36compat import Distribution_parse_config_files -__import__('pex.third_party.setuptools.extern.packaging.specifiers') -__import__('pex.third_party.setuptools.extern.packaging.version') +if "__PEX_UNVENDORED__" in __import__("os").environ: + __import__('setuptools.extern.packaging.specifiers') # vendor:skip +else: + __import__('pex.third_party.setuptools.extern.packaging.specifiers') + +if "__PEX_UNVENDORED__" in __import__("os").environ: + __import__('setuptools.extern.packaging.version') # vendor:skip +else: + __import__('pex.third_party.setuptools.extern.packaging.version') + def _get_unpatched(cls): @@ -625,7 +665,11 @@ def get_egg_cache_dir(self): def fetch_build_egg(self, req): """Fetch an egg needed for building""" - from pex.third_party.setuptools.command.easy_install import easy_install + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.easy_install import easy_install # vendor:skip + else: + from pex.third_party.setuptools.command.easy_install import easy_install + dist = self.__class__({'script_args': ['easy_install']}) opts = dist.get_option_dict('easy_install') opts.clear() diff --git a/pex/vendor/_vendored/setuptools/setuptools/extension.py b/pex/vendor/_vendored/setuptools/setuptools/extension.py index 53cc9cf08..855348136 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/extension.py +++ b/pex/vendor/_vendored/setuptools/setuptools/extension.py @@ -4,7 +4,11 @@ import distutils.errors import distutils.extension -from pex.third_party.setuptools.extern.six.moves import map +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import map + from .monkey import get_unpatched diff --git a/pex/vendor/_vendored/setuptools/setuptools/lib2to3_ex.py b/pex/vendor/_vendored/setuptools/setuptools/lib2to3_ex.py index 6ddce4a6b..4292ac059 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/lib2to3_ex.py +++ b/pex/vendor/_vendored/setuptools/setuptools/lib2to3_ex.py @@ -11,7 +11,11 @@ from distutils import log from lib2to3.refactor import RefactoringTool, get_fixers_from_package -import pex.third_party.setuptools as setuptools +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools # vendor:skip +else: + import pex.third_party.setuptools as setuptools + class DistutilsRefactoringTool(RefactoringTool): diff --git a/pex/vendor/_vendored/setuptools/setuptools/monkey.py b/pex/vendor/_vendored/setuptools/setuptools/monkey.py index 54d511faf..07be46f33 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/monkey.py +++ b/pex/vendor/_vendored/setuptools/setuptools/monkey.py @@ -10,9 +10,17 @@ from importlib import import_module import inspect -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools # vendor:skip +else: + import pex.third_party.setuptools as setuptools -import pex.third_party.setuptools as setuptools __all__ = [] """ diff --git a/pex/vendor/_vendored/setuptools/setuptools/msvc.py b/pex/vendor/_vendored/setuptools/setuptools/msvc.py index eb81cab7b..7cb3d5d1f 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/msvc.py +++ b/pex/vendor/_vendored/setuptools/setuptools/msvc.py @@ -22,14 +22,26 @@ import platform import itertools import distutils.errors -from pex.third_party.setuptools.extern.packaging.version import LegacyVersion +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.packaging.version import LegacyVersion # vendor:skip +else: + from pex.third_party.setuptools.extern.packaging.version import LegacyVersion + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import filterfalse # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import filterfalse -from pex.third_party.setuptools.extern.six.moves import filterfalse from .monkey import get_unpatched if platform.system() == 'Windows': - from pex.third_party.setuptools.extern.six.moves import winreg + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import winreg # vendor:skip + else: + from pex.third_party.setuptools.extern.six.moves import winreg + safe_env = os.environ else: """ diff --git a/pex/vendor/_vendored/setuptools/setuptools/namespaces.py b/pex/vendor/_vendored/setuptools/setuptools/namespaces.py index 1dbbd5196..b37013cbf 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/namespaces.py +++ b/pex/vendor/_vendored/setuptools/setuptools/namespaces.py @@ -2,7 +2,11 @@ from distutils import log import itertools -from pex.third_party.setuptools.extern.six.moves import map +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import map + flatten = itertools.chain.from_iterable diff --git a/pex/vendor/_vendored/setuptools/setuptools/package_index.py b/pex/vendor/_vendored/setuptools/setuptools/package_index.py index 56ebbd41b..a823883e6 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/package_index.py +++ b/pex/vendor/_vendored/setuptools/setuptools/package_index.py @@ -10,22 +10,58 @@ import warnings from functools import wraps -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import urllib, http_client, configparser, map +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six -import pex.third_party.setuptools as setuptools -from pex.third_party.pkg_resources import ( +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import urllib, http_client, configparser, map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import urllib, http_client, configparser, map + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import setuptools # vendor:skip +else: + import pex.third_party.setuptools as setuptools + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import ( + CHECKOUT_DIST, Distribution, BINARY_DIST, normalize_path, SOURCE_DIST, + Environment, find_distributions, safe_name, safe_version, + to_filename, Requirement, DEVELOP_DIST, EGG_DIST, +) # vendor:skip +else: + from pex.third_party.pkg_resources import ( CHECKOUT_DIST, Distribution, BINARY_DIST, normalize_path, SOURCE_DIST, Environment, find_distributions, safe_name, safe_version, to_filename, Requirement, DEVELOP_DIST, EGG_DIST, ) -from pex.third_party.setuptools import ssl_support + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import ssl_support # vendor:skip +else: + from pex.third_party.setuptools import ssl_support + from distutils import log from distutils.errors import DistutilsError from fnmatch import translate -from pex.third_party.setuptools.py27compat import get_all_headers -from pex.third_party.setuptools.py33compat import unescape -from pex.third_party.setuptools.wheel import Wheel +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.py27compat import get_all_headers # vendor:skip +else: + from pex.third_party.setuptools.py27compat import get_all_headers + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.py33compat import unescape # vendor:skip +else: + from pex.third_party.setuptools.py33compat import unescape + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.wheel import Wheel # vendor:skip +else: + from pex.third_party.setuptools.wheel import Wheel + __metaclass__ = type @@ -690,7 +726,11 @@ def gen_setup(self, filename, fragment, tmpdir): # Make sure the file has been downloaded to the temp dir. if os.path.dirname(filename) != tmpdir: dst = os.path.join(tmpdir, basename) - from pex.third_party.setuptools.command.easy_install import samefile + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.easy_install import samefile # vendor:skip + else: + from pex.third_party.setuptools.command.easy_install import samefile + if not samefile(filename, dst): shutil.copy2(filename, dst) filename = dst diff --git a/pex/vendor/_vendored/setuptools/setuptools/py27compat.py b/pex/vendor/_vendored/setuptools/setuptools/py27compat.py index cf58dd312..ac9eedb1b 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/py27compat.py +++ b/pex/vendor/_vendored/setuptools/setuptools/py27compat.py @@ -4,7 +4,11 @@ import platform -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + def get_all_headers(message, key): diff --git a/pex/vendor/_vendored/setuptools/setuptools/py33compat.py b/pex/vendor/_vendored/setuptools/setuptools/py33compat.py index 83cf2b810..7af7a406c 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/py33compat.py +++ b/pex/vendor/_vendored/setuptools/setuptools/py33compat.py @@ -7,8 +7,16 @@ except ImportError: html = None -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import html_parser +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import html_parser # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import html_parser + __metaclass__ = type diff --git a/pex/vendor/_vendored/setuptools/setuptools/sandbox.py b/pex/vendor/_vendored/setuptools/setuptools/sandbox.py index 1480a3018..29dfde208 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/sandbox.py +++ b/pex/vendor/_vendored/setuptools/setuptools/sandbox.py @@ -9,10 +9,22 @@ import pickle import textwrap -from pex.third_party.setuptools.extern import six -from pex.third_party.setuptools.extern.six.moves import builtins, map +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import builtins, map # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import builtins, map + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources.py31compat # vendor:skip +else: + import pex.third_party.pkg_resources.py31compat, pex.third_party.pkg_resources as pkg_resources -import pex.third_party.pkg_resources.py31compat, pex.third_party.pkg_resources as pkg_resources if sys.platform.startswith('java'): import org.python.modules.posix.PosixModule as _os @@ -24,7 +36,11 @@ _file = None _open = open from distutils.errors import DistutilsError -from pex.third_party.pkg_resources import working_set +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import working_set # vendor:skip +else: + from pex.third_party.pkg_resources import working_set + __all__ = [ @@ -107,7 +123,11 @@ def dump(type, exc): return pickle.dumps(type), pickle.dumps(exc) except Exception: # get UnpickleableException inside the sandbox - from pex.third_party.setuptools.sandbox import UnpickleableException as cls + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.sandbox import UnpickleableException as cls # vendor:skip + else: + from pex.third_party.setuptools.sandbox import UnpickleableException as cls + return cls.dump(cls, cls(repr(exc))) @@ -191,7 +211,11 @@ def setup_context(setup_dir): with override_temp(temp_dir): with pushd(setup_dir): # ensure setuptools commands are available - __import__('pex.third_party.setuptools') + if "__PEX_UNVENDORED__" in __import__("os").environ: + __import__('setuptools') # vendor:skip + else: + __import__('pex.third_party.setuptools') + yield @@ -403,7 +427,11 @@ def __init__(self, sandbox, exceptions=_EXCEPTIONS): AbstractSandbox.__init__(self) def _violation(self, operation, *args, **kw): - from pex.third_party.setuptools.sandbox import SandboxViolation + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.sandbox import SandboxViolation # vendor:skip + else: + from pex.third_party.setuptools.sandbox import SandboxViolation + raise SandboxViolation(operation, args, kw) if _file: diff --git a/pex/vendor/_vendored/setuptools/setuptools/ssl_support.py b/pex/vendor/_vendored/setuptools/setuptools/ssl_support.py index a55f5bfdf..46a0150e5 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/ssl_support.py +++ b/pex/vendor/_vendored/setuptools/setuptools/ssl_support.py @@ -4,9 +4,17 @@ import re import functools -from pex.third_party.setuptools.extern.six.moves import urllib, http_client, map, filter +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six.moves import urllib, http_client, map, filter # vendor:skip +else: + from pex.third_party.setuptools.extern.six.moves import urllib, http_client, map, filter + + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import ResolutionError, ExtractionError # vendor:skip +else: + from pex.third_party.pkg_resources import ResolutionError, ExtractionError -from pex.third_party.pkg_resources import ResolutionError, ExtractionError try: import ssl diff --git a/pex/vendor/_vendored/setuptools/setuptools/unicode_utils.py b/pex/vendor/_vendored/setuptools/setuptools/unicode_utils.py index 11eef1c4a..8a33c4aff 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/unicode_utils.py +++ b/pex/vendor/_vendored/setuptools/setuptools/unicode_utils.py @@ -1,7 +1,11 @@ import unicodedata import sys -from pex.third_party.setuptools.extern import six +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern import six # vendor:skip +else: + from pex.third_party.setuptools.extern import six + # HFS Plus uses decomposed UTF-8 diff --git a/pex/vendor/_vendored/setuptools/setuptools/version.py b/pex/vendor/_vendored/setuptools/setuptools/version.py index 2456ab2c1..bead7cac9 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/version.py +++ b/pex/vendor/_vendored/setuptools/setuptools/version.py @@ -1,4 +1,8 @@ -import pex.third_party.pkg_resources as pkg_resources +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip +else: + import pex.third_party.pkg_resources as pkg_resources + try: __version__ = pkg_resources.get_distribution('setuptools').version diff --git a/pex/vendor/_vendored/setuptools/setuptools/wheel.py b/pex/vendor/_vendored/setuptools/setuptools/wheel.py index 6832f15c5..6b6c5591f 100644 --- a/pex/vendor/_vendored/setuptools/setuptools/wheel.py +++ b/pex/vendor/_vendored/setuptools/setuptools/wheel.py @@ -8,12 +8,36 @@ import re import zipfile -from pex.third_party.pkg_resources import Distribution, PathMetadata, parse_version -from pex.third_party.setuptools.extern.packaging.utils import canonicalize_name -from pex.third_party.setuptools.extern.six import PY3 -from pex.third_party.setuptools import Distribution as SetuptoolsDistribution -from pex.third_party.setuptools import pep425tags -from pex.third_party.setuptools.command.egg_info import write_requirements +if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import Distribution, PathMetadata, parse_version # vendor:skip +else: + from pex.third_party.pkg_resources import Distribution, PathMetadata, parse_version + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.packaging.utils import canonicalize_name # vendor:skip +else: + from pex.third_party.setuptools.extern.packaging.utils import canonicalize_name + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.extern.six import PY3 # vendor:skip +else: + from pex.third_party.setuptools.extern.six import PY3 + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import Distribution as SetuptoolsDistribution # vendor:skip +else: + from pex.third_party.setuptools import Distribution as SetuptoolsDistribution + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools import pep425tags # vendor:skip +else: + from pex.third_party.setuptools import pep425tags + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command.egg_info import write_requirements # vendor:skip +else: + from pex.third_party.setuptools.command.egg_info import write_requirements + __metaclass__ = type diff --git a/pex/vendor/_vendored/wheel/wheel/__main__.py b/pex/vendor/_vendored/wheel/wheel/__main__.py index df772e604..9035c6456 100644 --- a/pex/vendor/_vendored/wheel/wheel/__main__.py +++ b/pex/vendor/_vendored/wheel/wheel/__main__.py @@ -11,7 +11,11 @@ def main(): # needed for console script import os.path path = os.path.dirname(os.path.dirname(__file__)) sys.path[0:0] = [path] - import pex.third_party.wheel.tool, pex.third_party.wheel as wheel + if "__PEX_UNVENDORED__" in __import__("os").environ: + import wheel.tool # vendor:skip + else: + import pex.third_party.wheel.tool, pex.third_party.wheel as wheel + sys.exit(wheel.tool.main()) diff --git a/pex/vendor/_vendored/wheel/wheel/bdist_wheel.py b/pex/vendor/_vendored/wheel/wheel/bdist_wheel.py index b98844d24..51aab9595 100644 --- a/pex/vendor/_vendored/wheel/wheel/bdist_wheel.py +++ b/pex/vendor/_vendored/wheel/wheel/bdist_wheel.py @@ -17,7 +17,11 @@ from distutils import log as logger from shutil import rmtree -import pex.third_party.pkg_resources as pkg_resources +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip +else: + import pex.third_party.pkg_resources as pkg_resources + from .pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag, get_platform from .util import native, open_for_csv diff --git a/pex/vendor/_vendored/wheel/wheel/egg2wheel.py b/pex/vendor/_vendored/wheel/wheel/egg2wheel.py index 143cb68ea..765612495 100644 --- a/pex/vendor/_vendored/wheel/wheel/egg2wheel.py +++ b/pex/vendor/_vendored/wheel/wheel/egg2wheel.py @@ -10,9 +10,21 @@ from distutils.archive_util import make_archive from glob import iglob -import pex.third_party.wheel.bdist_wheel, pex.third_party.wheel as wheel -from pex.third_party.wheel.tool import WheelError -from pex.third_party.wheel.wininst2wheel import _bdist_wheel_tag +if "__PEX_UNVENDORED__" in __import__("os").environ: + import wheel.bdist_wheel # vendor:skip +else: + import pex.third_party.wheel.bdist_wheel, pex.third_party.wheel as wheel + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from wheel.tool import WheelError # vendor:skip +else: + from pex.third_party.wheel.tool import WheelError + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from wheel.wininst2wheel import _bdist_wheel_tag # vendor:skip +else: + from pex.third_party.wheel.wininst2wheel import _bdist_wheel_tag + egg_info_re = re.compile(r''' (?P.+?)-(?P.+?) diff --git a/pex/vendor/_vendored/wheel/wheel/install.py b/pex/vendor/_vendored/wheel/wheel/install.py index def783ab6..9203208dd 100644 --- a/pex/vendor/_vendored/wheel/wheel/install.py +++ b/pex/vendor/_vendored/wheel/wheel/install.py @@ -41,7 +41,11 @@ def parse_version(version): """Use parse_version from pkg_resources or distutils as available.""" global parse_version try: - from pex.third_party.pkg_resources import parse_version + if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import parse_version # vendor:skip + else: + from pex.third_party.pkg_resources import parse_version + except ImportError: from distutils.version import LooseVersion as parse_version return parse_version(version) diff --git a/pex/vendor/_vendored/wheel/wheel/metadata.py b/pex/vendor/_vendored/wheel/wheel/metadata.py index eca49bc09..afaab60a6 100644 --- a/pex/vendor/_vendored/wheel/wheel/metadata.py +++ b/pex/vendor/_vendored/wheel/wheel/metadata.py @@ -7,7 +7,11 @@ import textwrap from collections import namedtuple -import pex.third_party.pkg_resources as pkg_resources +if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip +else: + import pex.third_party.pkg_resources as pkg_resources + from .pkginfo import read_pkg_info diff --git a/pex/vendor/_vendored/wheel/wheel/tool/__init__.py b/pex/vendor/_vendored/wheel/wheel/tool/__init__.py index ceacb8e4f..66b5426cd 100644 --- a/pex/vendor/_vendored/wheel/wheel/tool/__init__.py +++ b/pex/vendor/_vendored/wheel/wheel/tool/__init__.py @@ -19,7 +19,11 @@ def require_pkgresources(name): try: - import pex.third_party.pkg_resources as pkg_resources # noqa: F401 + if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip + else: + import pex.third_party.pkg_resources as pkg_resources + # noqa: F401 except ImportError: raise RuntimeError("'{0}' needs pkg_resources (part of setuptools).".format(name)) @@ -249,8 +253,16 @@ def install_scripts(distributions): Regenerate the entry_points console_scripts for the named distribution. """ try: - from pex.third_party.setuptools.command import easy_install - import pex.third_party.pkg_resources as pkg_resources + if "__PEX_UNVENDORED__" in __import__("os").environ: + from setuptools.command import easy_install # vendor:skip + else: + from pex.third_party.setuptools.command import easy_install + + if "__PEX_UNVENDORED__" in __import__("os").environ: + import pkg_resources # vendor:skip + else: + import pex.third_party.pkg_resources as pkg_resources + except ImportError: raise RuntimeError("'wheel install_scripts' needs setuptools.") diff --git a/pex/vendor/_vendored/wheel/wheel/util.py b/pex/vendor/_vendored/wheel/wheel/util.py index 96bcbd47f..ad119bd72 100644 --- a/pex/vendor/_vendored/wheel/wheel/util.py +++ b/pex/vendor/_vendored/wheel/wheel/util.py @@ -141,7 +141,11 @@ def matches_requirement(req, wheels): :param wheels: List of wheels to search. """ try: - from pex.third_party.pkg_resources import Distribution, Requirement + if "__PEX_UNVENDORED__" in __import__("os").environ: + from pkg_resources import Distribution, Requirement # vendor:skip + else: + from pex.third_party.pkg_resources import Distribution, Requirement + except ImportError: raise RuntimeError("Cannot use requirements without pkg_resources") diff --git a/pex/vendor/_vendored/wheel/wheel/wininst2wheel.py b/pex/vendor/_vendored/wheel/wheel/wininst2wheel.py index 7a489c5f0..601cca5fa 100644 --- a/pex/vendor/_vendored/wheel/wheel/wininst2wheel.py +++ b/pex/vendor/_vendored/wheel/wheel/wininst2wheel.py @@ -9,8 +9,16 @@ from glob import iglob from shutil import rmtree -import pex.third_party.wheel.bdist_wheel, pex.third_party.wheel as wheel -from pex.third_party.wheel.archive import archive_wheelfile +if "__PEX_UNVENDORED__" in __import__("os").environ: + import wheel.bdist_wheel # vendor:skip +else: + import pex.third_party.wheel.bdist_wheel, pex.third_party.wheel as wheel + +if "__PEX_UNVENDORED__" in __import__("os").environ: + from wheel.archive import archive_wheelfile # vendor:skip +else: + from pex.third_party.wheel.archive import archive_wheelfile + egg_info_re = re.compile(r'''(^|/)(?P[^/]+?)-(?P.+?) (-(?P.+?))?(-(?P.+?))?.egg-info(/|$)''', re.VERBOSE) diff --git a/tests/test_bdist_pex.py b/tests/test_bdist_pex.py index e7449715a..35ede3bec 100644 --- a/tests/test_bdist_pex.py +++ b/tests/test_bdist_pex.py @@ -1,41 +1,15 @@ # Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). - import os import stat import subprocess +import sys +from contextlib import contextmanager from textwrap import dedent -import pex.third_party.pkg_resources as pkg_resources from pex.common import open_zip -from pex.installer import DistributionPackager, WheelInstaller, after_installation -from pex.interpreter import PythonInterpreter -from pex.testing import temporary_content - - -class BdistPexInstaller(DistributionPackager): - - def __init__(self, source_dir, interpreter, bdist_args=None): - self._bdist_args = list(bdist_args) if bdist_args else [] - super(BdistPexInstaller, self).__init__(source_dir=source_dir, interpreter=interpreter) - - @property - def mixins(self): - return ['setuptools', 'pex'] - - def _setup_command(self): - return ['bdist_pex', '--bdist-dir={}'.format(self._install_tmp)] + self._bdist_args - - @after_installation - def bdist(self): - return self.find_distribution() - - -def bdist_pex_installer(source_dir, bdist_args=None): - pex_dist = pkg_resources.working_set.find(pkg_resources.Requirement.parse('pex')) - interpreter = PythonInterpreter.get() - interpreter = interpreter.with_extra(pex_dist.key, pex_dist.version, pex_dist.location) - return BdistPexInstaller(source_dir=source_dir, interpreter=interpreter, bdist_args=bdist_args) +from pex.installer import WheelInstaller +from pex.testing import temporary_content, temporary_dir def bdist_pex_setup_py(**kwargs): @@ -47,6 +21,18 @@ def bdist_pex_setup_py(**kwargs): """.format(kwargs=kwargs)) +@contextmanager +def bdist_pex(project_dir, bdist_args=None): + with temporary_dir() as dist_dir: + cmd = [sys.executable, 'setup.py', 'bdist_pex', '--bdist-dir={}'.format(dist_dir)] + if bdist_args: + cmd.extend(bdist_args) + subprocess.check_call(cmd, cwd=project_dir) + dists = os.listdir(dist_dir) + assert len(dists) == 1 + yield os.path.join(dist_dir, dists[0]) + + def assert_entry_points(entry_points): setup_py = bdist_pex_setup_py(name='my_app', version='0.0.0', @@ -59,12 +45,12 @@ def do_something(): """) with temporary_content({'setup.py': setup_py, 'my_app.py': my_app}) as project_dir: - my_app_pex = bdist_pex_installer(project_dir).bdist() - process = subprocess.Popen([my_app_pex], stdout=subprocess.PIPE) - stdout, _ = process.communicate() - assert '{pex_root}' not in os.listdir(project_dir) - assert 0 == process.returncode - assert stdout == b'hello world!\n' + with bdist_pex(project_dir) as my_app_pex: + process = subprocess.Popen([my_app_pex], stdout=subprocess.PIPE) + stdout, _ = process.communicate() + assert '{pex_root}' not in os.listdir(project_dir) + assert 0 == process.returncode + assert stdout == b'hello world!\n' def assert_pex_args_shebang(shebang): @@ -75,9 +61,9 @@ def assert_pex_args_shebang(shebang): with temporary_content({'setup.py': setup_py}) as project_dir: pex_args = '--pex-args=--python-shebang="{}"'.format(shebang) - my_app_pex = bdist_pex_installer(project_dir, bdist_args=[pex_args]).bdist() - with open(my_app_pex, 'rb') as fp: - assert fp.readline().decode().rstrip() == shebang + with bdist_pex(project_dir, bdist_args=[pex_args]) as my_app_pex: + with open(my_app_pex, 'rb') as fp: + assert fp.readline().decode().rstrip() == shebang def test_entry_points_dict(): @@ -126,13 +112,12 @@ def test_unwriteable_contents(): install_requires=['my_app']) with temporary_content({'setup.py': uses_my_app_setup_py}) as uses_my_app_project_dir: pex_args = '--pex-args=--disable-cache --no-pypi -f {}'.format(os.path.dirname(my_app_whl)) - uses_my_app_pex = bdist_pex_installer(uses_my_app_project_dir, bdist_args=[pex_args]).bdist() - - with open_zip(uses_my_app_pex) as zf: - unwriteable_sos = [path for path in zf.namelist() - if path.endswith('my_app/unwriteable.so')] - assert 1 == len(unwriteable_sos) - unwriteable_so = unwriteable_sos.pop() - zf.extract(unwriteable_so, path=uses_my_app_project_dir) - extract_dest = os.path.join(uses_my_app_project_dir, unwriteable_so) - assert UNWRITEABLE_PERMS == stat.S_IMODE(os.stat(extract_dest).st_mode) + with bdist_pex(uses_my_app_project_dir, bdist_args=[pex_args]) as uses_my_app_pex: + with open_zip(uses_my_app_pex) as zf: + unwriteable_sos = [path for path in zf.namelist() + if path.endswith('my_app/unwriteable.so')] + assert 1 == len(unwriteable_sos) + unwriteable_so = unwriteable_sos.pop() + zf.extract(unwriteable_so, path=uses_my_app_project_dir) + extract_dest = os.path.join(uses_my_app_project_dir, unwriteable_so) + assert UNWRITEABLE_PERMS == stat.S_IMODE(os.stat(extract_dest).st_mode) diff --git a/tests/test_installer.py b/tests/test_installer.py deleted file mode 100644 index ee05ef682..000000000 --- a/tests/test_installer.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import contextlib - -import pytest - -from pex.installer import WheelInstaller -from pex.interpreter import PythonInterpreter -from pex.testing import PY36, ensure_python_interpreter, make_installer - - -class OrderableInstaller(WheelInstaller): - def __init__(self, source_dir, interpreter=None, install_dir=None, mixins=None): - self._mixins = mixins - super(OrderableInstaller, self).__init__(source_dir, interpreter, install_dir) - - @property - def mixins(self): - return self._mixins - - -@contextlib.contextmanager -def wheel_installer(*mixins): - bare_interpreter = PythonInterpreter.from_binary(ensure_python_interpreter(PY36)) - with make_installer(installer_impl=OrderableInstaller, - interpreter=bare_interpreter, - mixins=list(mixins)) as installer: - yield installer - - -def test_wheel_before_setuptools(): - with wheel_installer('wheel', 'setuptools') as installer: - installer.bdist() - - -def test_setuptools_before_wheel(): - with wheel_installer('setuptools', 'wheel') as installer: - installer.bdist() - - -def test_no_wheel(): - with wheel_installer('setuptools') as installer: - with pytest.raises(installer.InstallFailure): - installer.bdist() diff --git a/tests/test_integration.py b/tests/test_integration.py index f7e965fdb..91430b318 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1205,3 +1205,16 @@ def test_force_local_implicit_ns_packages_issues_598(): subprocess.check_call([tcl_pex, '-c', 'from twitter.common.lang import Singleton'], env=make_env(PEX_FORCE_LOCAL='1', PEX_PATH=tcl_pex)) + + +def test_issues_661_devendoring_required(): + # The cryptography distribution does not have a whl released for python3 on linux at version 2.5. + # As a result, we're forced to build it under python3 and, prior to the fix for + # https://github.com/pantsbuild/pex/issues/661, this would fail using the vendored setuptools + # inside pex. + with temporary_dir() as td: + cryptography_pex = os.path.join(td, 'cryptography.pex') + res = run_pex_command(['cryptography==2.5', '-o', cryptography_pex]) + res.assert_success() + + subprocess.check_call([cryptography_pex, '-c', 'import cryptography']) diff --git a/tox.ini b/tox.ini index bcc33cc9a..3db558683 100644 --- a/tox.ini +++ b/tox.ini @@ -22,6 +22,10 @@ deps = cachecontrol: lockfile coverage: coverage==4.5.1 subprocess: subprocess32 +passenv = + # These are to support directing test environments to the correct OpenSSL on OSX. + CPPFLAGS + LDFLAGS whitelist_externals = open bash