from pkg_resources.extern import VendorImporter

names = 'six',
VendorImporter(__name__, names, 'pkg_resources._vendor').install()

@@ -1,51 +1,2396 @@
-from pkg_resources.extern import VendorImporter
+import sys%0A%0A%0Aclass VendorImporter:%0A    %22%22%22%0A    A PEP 302 meta path importer for finding optionally-vendored%0A    or otherwise naturally-installed packages from root_name.%0A    %22%22%22%0A%0A    def __init__(self, root_name, vendored_names=(), vendor_pkg=None):%0A        self.root_name = root_name%0A        self.vendored_names = set(vendored_names)%0A        self.vendor_pkg = vendor_pkg or root_name.replace('extern', '_vendor')%0A%0A    @property%0A    def search_path(self):%0A        %22%22%22%0A        Search first the vendor package then as a natural package.%0A        %22%22%22%0A        yield self.vendor_pkg + '.'%0A        yield ''%0A%0A    def find_module(self, fullname, path=None):%0A        %22%22%22%0A        Return self when fullname starts with root_name and the%0A        target module is one vendored through this importer.%0A        %22%22%22%0A        root, base, target = fullname.partition(self.root_name + '.')%0A        if root:%0A            return%0A        if not any(map(target.startswith, self.vendored_names)):%0A            return%0A        return self%0A%0A    def load_module(self, fullname):%0A        %22%22%22%0A        Iterate over the search path to locate and load fullname.%0A        %22%22%22%0A        root, base, target = fullname.partition(self.root_name + '.')%0A        for prefix in self.search_path:%0A            try:%0A                extant = prefix + target%0A                __import__(extant)%0A                mod = sys.modules%5Bextant%5D%0A                sys.modules%5Bfullname%5D = mod%0A                # mysterious hack:%0A                # Remove the reference to the extant package/module%0A                # on later Python versions to cause relative imports%0A                # in the vendor package to resolve the same modules%0A                # as those going through this importer.%0A                if sys.version_info %3E (3, 3):%0A                    del sys.modules%5Bextant%5D%0A                return mod%0A            except ImportError:%0A                pass%0A        else:%0A            raise ImportError(%0A                %22The '%7Btarget%7D' package is required; %22%0A                %22normally this is bundled with this package so if you get %22%0A                %22this warning, consult the packager of your %22%0A                %22distribution.%22.format(**locals())%0A            )%0A%0A    def install(self):%0A        %22%22%22%0A        Install this importer into sys.meta_path if not already present.%0A        %22%22%22%0A        if self not in sys.meta_path:%0A            sys.meta_path.append(self)%0A
 %0A%0Ana

Copy VendorImporter. Ref #1296.