usr/bin/command000075500000000037147207316110007473 0ustar00#!/bin/sh builtin command "$@" install_lib.py000064400000007400147210141470007414 0ustar00import os import imp from itertools import product, starmap import distutils.command.install_lib as orig class install_lib(orig.install_lib): """Don't add compiled flags to filenames of non-Python files""" def run(self): self.build() outfiles = self.install() if outfiles is not None: # always compile, in case we have any extension stubs to deal with self.byte_compile(outfiles) def get_exclusions(self): """ Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations. """ all_packages = ( pkg for ns_pkg in self._get_SVEM_NSPs() for pkg in self._all_packages(ns_pkg) ) excl_specs = product(all_packages, self._gen_exclusion_paths()) return set(starmap(self._exclude_pkg_path, excl_specs)) def _exclude_pkg_path(self, pkg, exclusion_path): """ Given a package name and exclusion path within that package, compute the full exclusion path. """ parts = pkg.split('.') + [exclusion_path] return os.path.join(self.install_dir, *parts) @staticmethod def _all_packages(pkg_name): """ >>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo'] """ while pkg_name: yield pkg_name pkg_name, sep, child = pkg_name.rpartition('.') def _get_SVEM_NSPs(self): """ Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise. """ # TODO: is it necessary to short-circuit here? i.e. what's the cost # if get_finalized_command is called even when namespace_packages is # False? if not self.distribution.namespace_packages: return [] install_cmd = self.get_finalized_command('install') svem = install_cmd.single_version_externally_managed return self.distribution.namespace_packages if svem else [] @staticmethod def _gen_exclusion_paths(): """ Generate file paths to be excluded for namespace packages (bytecode cache files). """ # always exclude the package module itself yield '__init__.py' yield '__init__.pyc' yield '__init__.pyo' if not hasattr(imp, 'get_tag'): return base = os.path.join('__pycache__', '__init__.' + imp.get_tag()) yield base + '.pyc' yield base + '.pyo' yield base + '.opt-1.pyc' yield base + '.opt-2.pyc' def copy_tree( self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1 ): assert preserve_mode and preserve_times and not preserve_symlinks exclude = self.get_exclusions() if not exclude: return orig.install_lib.copy_tree(self, infile, outfile) # Exclude namespace package __init__.py* files from the output from setuptools.archive_util import unpack_directory from distutils import log outfiles = [] def pf(src, dst): if dst in exclude: log.warn("Skipping installation of %s (namespace package)", dst) return False log.info("copying %s -> %s", src, os.path.dirname(dst)) outfiles.append(dst) return dst unpack_directory(infile, outfile, pf) return outfiles def get_outputs(self): outputs = orig.install_lib.get_outputs(self) exclude = self.get_exclusions() if exclude: return [f for f in outputs if f not in exclude] return outputs __init__.py000064400000001122147210141470006652 0ustar00__all__ = [ 'alias', 'bdist_egg', 'bdist_rpm', 'build_ext', 'build_py', 'develop', 'easy_install', 'egg_info', 'install', 'install_lib', 'rotate', 'saveopts', 'sdist', 'setopt', 'test', 'install_egg_info', 'install_scripts', 'register', 'bdist_wininst', 'upload_docs', 'upload', 'build_clib', 'dist_info', ] from distutils.command.bdist import bdist import sys from setuptools.command import install_scripts if 'egg' not in bdist.format_commands: bdist.format_command['egg'] = ('bdist_egg', "Python .egg file") bdist.format_commands.append('egg') del bdist, sys setopt.py000064400000011735147210141470006444 0ustar00from distutils.util import convert_path from distutils import log from distutils.errors import DistutilsOptionError import distutils import os from setuptools.extern.six.moves import configparser from setuptools import Command __all__ = ['config_file', 'edit_config', 'option_base', 'setopt'] def config_file(kind="local"): """Get the filename of the distutils, local, global, or per-user config `kind` must be one of "local", "global", or "user" """ if kind == 'local': return 'setup.cfg' if kind == 'global': return os.path.join( os.path.dirname(distutils.__file__), 'distutils.cfg' ) if kind == 'user': dot = os.name == 'posix' and '.' or '' return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot)) raise ValueError( "config_file() type must be 'local', 'global', or 'user'", kind ) def edit_config(filename, settings, dry_run=False): """Edit a configuration file to include `settings` `settings` is a dictionary of dictionaries or ``None`` values, keyed by command/section name. A ``None`` value means to delete the entire section, while a dictionary lists settings to be changed or deleted in that section. A setting of ``None`` means to delete that setting. """ log.debug("Reading configuration from %s", filename) opts = configparser.RawConfigParser() opts.read([filename]) for section, options in settings.items(): if options is None: log.info("Deleting section [%s] from %s", section, filename) opts.remove_section(section) else: if not opts.has_section(section): log.debug("Adding new section [%s] to %s", section, filename) opts.add_section(section) for option, value in options.items(): if value is None: log.debug( "Deleting %s.%s from %s", section, option, filename ) opts.remove_option(section, option) if not opts.options(section): log.info("Deleting empty [%s] section from %s", section, filename) opts.remove_section(section) else: log.debug( "Setting %s.%s to %r in %s", section, option, value, filename ) opts.set(section, option, value) log.info("Writing %s", filename) if not dry_run: with open(filename, 'w') as f: opts.write(f) class option_base(Command): """Abstract base class for commands that mess with config files""" user_options = [ ('global-config', 'g', "save options to the site-wide distutils.cfg file"), ('user-config', 'u', "save options to the current user's pydistutils.cfg file"), ('filename=', 'f', "configuration file to use (default=setup.cfg)"), ] boolean_options = [ 'global-config', 'user-config', ] def initialize_options(self): self.global_config = None self.user_config = None self.filename = None def finalize_options(self): filenames = [] if self.global_config: filenames.append(config_file('global')) if self.user_config: filenames.append(config_file('user')) if self.filename is not None: filenames.append(self.filename) if not filenames: filenames.append(config_file('local')) if len(filenames) > 1: raise DistutilsOptionError( "Must specify only one configuration file option", filenames ) self.filename, = filenames class setopt(option_base): """Save command-line options to a file""" description = "set an option in setup.cfg or another config file" user_options = [ ('command=', 'c', 'command to set an option for'), ('option=', 'o', 'option to set'), ('set-value=', 's', 'value of the option'), ('remove', 'r', 'remove (unset) the value'), ] + option_base.user_options boolean_options = option_base.boolean_options + ['remove'] def initialize_options(self): option_base.initialize_options(self) self.command = None self.option = None self.set_value = None self.remove = None def finalize_options(self): option_base.finalize_options(self) if self.command is None or self.option is None: raise DistutilsOptionError("Must specify --command *and* --option") if self.set_value is None and not self.remove: raise DistutilsOptionError("Must specify --set-value or --remove") def run(self): edit_config( self.filename, { self.command: {self.option.replace('-', '_'): self.set_value} }, self.dry_run ) test.py000064400000021776147210141470006113 0ustar00import os import operator import sys import contextlib import itertools import unittest from distutils.errors import DistutilsError, DistutilsOptionError from distutils import log from unittest import TestLoader from setuptools.extern import six from setuptools.extern.six.moves import map, filter from pkg_resources import (resource_listdir, resource_exists, normalize_path, working_set, _namespace_packages, evaluate_marker, add_activation_listener, require, EntryPoint) from setuptools import Command class ScanningLoader(TestLoader): def __init__(self): TestLoader.__init__(self) self._visited = set() def loadTestsFromModule(self, module, pattern=None): """Return a suite of all tests cases contained in the given module If the module is a package, load tests from all the modules in it. If the module has an ``additional_tests`` function, call it and add the return value to the tests. """ if module in self._visited: return None self._visited.add(module) tests = [] tests.append(TestLoader.loadTestsFromModule(self, module)) if hasattr(module, "additional_tests"): tests.append(module.additional_tests()) if hasattr(module, '__path__'): for file in resource_listdir(module.__name__, ''): if file.endswith('.py') and file != '__init__.py': submodule = module.__name__ + '.' + file[:-3] else: if resource_exists(module.__name__, file + '/__init__.py'): submodule = module.__name__ + '.' + file else: continue tests.append(self.loadTestsFromName(submodule)) if len(tests) != 1: return self.suiteClass(tests) else: return tests[0] # don't create a nested suite for only one return # adapted from jaraco.classes.properties:NonDataProperty class NonDataProperty(object): def __init__(self, fget): self.fget = fget def __get__(self, obj, objtype=None): if obj is None: return self return self.fget(obj) class test(Command): """Command to run unit tests after in-place build""" description = "run unit tests after in-place build" user_options = [ ('test-module=', 'm', "Run 'test_suite' in specified module"), ('test-suite=', 's', "Run single test, case or suite (e.g. 'module.test_suite')"), ('test-runner=', 'r', "Test runner to use"), ] def initialize_options(self): self.test_suite = None self.test_module = None self.test_loader = None self.test_runner = None def finalize_options(self): if self.test_suite and self.test_module: msg = "You may specify a module or a suite, but not both" raise DistutilsOptionError(msg) if self.test_suite is None: if self.test_module is None: self.test_suite = self.distribution.test_suite else: self.test_suite = self.test_module + ".test_suite" if self.test_loader is None: self.test_loader = getattr(self.distribution, 'test_loader', None) if self.test_loader is None: self.test_loader = "setuptools.command.test:ScanningLoader" if self.test_runner is None: self.test_runner = getattr(self.distribution, 'test_runner', None) @NonDataProperty def test_args(self): return list(self._test_args()) def _test_args(self): if not self.test_suite and sys.version_info >= (2, 7): yield 'discover' if self.verbose: yield '--verbose' if self.test_suite: yield self.test_suite def with_project_on_sys_path(self, func): """ Backward compatibility for project_on_sys_path context. """ with self.project_on_sys_path(): func() @contextlib.contextmanager def project_on_sys_path(self, include_dists=[]): with_2to3 = six.PY3 and getattr(self.distribution, 'use_2to3', False) if with_2to3: # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date self.reinitialize_command('build_py', inplace=0) self.run_command('build_py') bpy_cmd = self.get_finalized_command("build_py") build_path = normalize_path(bpy_cmd.build_lib) # Build extensions self.reinitialize_command('egg_info', egg_base=build_path) self.run_command('egg_info') self.reinitialize_command('build_ext', inplace=0) self.run_command('build_ext') else: # Without 2to3 inplace works fine: self.run_command('egg_info') # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') ei_cmd = self.get_finalized_command("egg_info") old_path = sys.path[:] old_modules = sys.modules.copy() try: project_path = normalize_path(ei_cmd.egg_base) sys.path.insert(0, project_path) working_set.__init__() add_activation_listener(lambda dist: dist.activate()) require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version)) with self.paths_on_pythonpath([project_path]): yield finally: sys.path[:] = old_path sys.modules.clear() sys.modules.update(old_modules) working_set.__init__() @staticmethod @contextlib.contextmanager def paths_on_pythonpath(paths): """ Add the indicated paths to the head of the PYTHONPATH environment variable so that subprocesses will also see the packages at these paths. Do this in a context that restores the value on exit. """ nothing = object() orig_pythonpath = os.environ.get('PYTHONPATH', nothing) current_pythonpath = os.environ.get('PYTHONPATH', '') try: prefix = os.pathsep.join(paths) to_join = filter(None, [prefix, current_pythonpath]) new_path = os.pathsep.join(to_join) if new_path: os.environ['PYTHONPATH'] = new_path yield finally: if orig_pythonpath is nothing: os.environ.pop('PYTHONPATH', None) else: os.environ['PYTHONPATH'] = orig_pythonpath @staticmethod def install_dists(dist): """ Install the requirements indicated by self.distribution and return an iterable of the dists that were built. """ ir_d = dist.fetch_build_eggs(dist.install_requires) tr_d = dist.fetch_build_eggs(dist.tests_require or []) er_d = dist.fetch_build_eggs( v for k, v in dist.extras_require.items() if k.startswith(':') and evaluate_marker(k[1:]) ) return itertools.chain(ir_d, tr_d, er_d) def run(self): installed_dists = self.install_dists(self.distribution) cmd = ' '.join(self._argv) if self.dry_run: self.announce('skipping "%s" (dry run)' % cmd) return self.announce('running "%s"' % cmd) paths = map(operator.attrgetter('location'), installed_dists) with self.paths_on_pythonpath(paths): with self.project_on_sys_path(): self.run_tests() def run_tests(self): # Purge modules under test from sys.modules. The test loader will # re-import them from the build location. Required when 2to3 is used # with namespace packages. if six.PY3 and getattr(self.distribution, 'use_2to3', False): module = self.test_suite.split('.')[0] if module in _namespace_packages: del_modules = [] if module in sys.modules: del_modules.append(module) module += '.' for name in sys.modules: if name.startswith(module): del_modules.append(name) list(map(sys.modules.__delitem__, del_modules)) test = unittest.main( None, None, self._argv, testLoader=self._resolve_as_ep(self.test_loader), testRunner=self._resolve_as_ep(self.test_runner), exit=False, ) if not test.result.wasSuccessful(): msg = 'Test failed: %s' % test.result self.announce(msg, log.ERROR) raise DistutilsError(msg) @property def _argv(self): return ['unittest'] + self.test_args @staticmethod def _resolve_as_ep(val): """ Load the indicated attribute value, called, as a as if it were specified as an entry point. """ if val is None: return parsed = EntryPoint.parse("x=" + val) return parsed.resolve()() install_egg_info.py000064400000004233147210141470010424 0ustar00from distutils import log, dir_util import os from setuptools import Command from setuptools import namespaces from setuptools.archive_util import unpack_archive import pkg_resources class install_egg_info(namespaces.Installer, Command): """Install an .egg-info directory for the package""" description = "Install an .egg-info directory for the package" user_options = [ ('install-dir=', 'd', "directory to install to"), ] def initialize_options(self): self.install_dir = None def finalize_options(self): self.set_undefined_options('install_lib', ('install_dir', 'install_dir')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) self.outputs = [] def run(self): self.run_command('egg_info') if os.path.isdir(self.target) and not os.path.islink(self.target): dir_util.remove_tree(self.target, dry_run=self.dry_run) elif os.path.exists(self.target): self.execute(os.unlink, (self.target,), "Removing " + self.target) if not self.dry_run: pkg_resources.ensure_directory(self.target) self.execute( self.copytree, (), "Copying %s to %s" % (self.source, self.target) ) self.install_namespaces() def get_outputs(self): return self.outputs def copytree(self): # Copy the .egg-info tree to site-packages def skimmer(src, dst): # filter out source-control directories; note that 'src' is always # a '/'-separated path, regardless of platform. 'dst' is a # platform-specific path. for skip in '.svn/', 'CVS/': if src.startswith(skip) or '/' + skip in src: return None self.outputs.append(dst) log.debug("Copying %s to %s", src, dst) return dst unpack_archive(self.source, self.target, skimmer) upload.py000064400000002224147210141470006403 0ustar00import getpass from distutils.command import upload as orig class upload(orig.upload): """ Override default upload behavior to obtain password in a variety of different ways. """ def finalize_options(self): orig.upload.finalize_options(self) self.username = ( self.username or getpass.getuser() ) # Attempt to obtain password. Short circuit evaluation at the first # sign of success. self.password = ( self.password or self._load_password_from_keyring() or self._prompt_for_password() ) def _load_password_from_keyring(self): """ Attempt to load password from keyring. Suppress Exceptions. """ try: keyring = __import__('keyring') return keyring.get_password(self.repository, self.username) except Exception: pass def _prompt_for_password(self): """ Prompt for a password on the tty. Suppress Exceptions. """ try: return getpass.getpass() except (Exception, KeyboardInterrupt): pass build_ext.py000064400000031565147210141470007110 0ustar00import os import sys import itertools import imp from distutils.command.build_ext import build_ext as _du_build_ext from distutils.file_util import copy_file from distutils.ccompiler import new_compiler from distutils.sysconfig import customize_compiler, get_config_var from distutils.errors import DistutilsError from distutils import log from setuptools.extension import Library from setuptools.extern import six try: # Attempt to use Cython for building extensions, if available from Cython.Distutils.build_ext import build_ext as _build_ext # Additionally, assert that the compiler module will load # also. Ref #1229. __import__('Cython.Compiler.Main') except ImportError: _build_ext = _du_build_ext # make sure _config_vars is initialized get_config_var("LDSHARED") from distutils.sysconfig import _config_vars as _CONFIG_VARS def _customize_compiler_for_shlib(compiler): if sys.platform == "darwin": # building .dylib requires additional compiler flags on OSX; here we # temporarily substitute the pyconfig.h variables so that distutils' # 'customize_compiler' uses them before we build the shared libraries. tmp = _CONFIG_VARS.copy() try: # XXX Help! I don't have any idea whether these are right... _CONFIG_VARS['LDSHARED'] = ( "gcc -Wl,-x -dynamiclib -undefined dynamic_lookup") _CONFIG_VARS['CCSHARED'] = " -dynamiclib" _CONFIG_VARS['SO'] = ".dylib" customize_compiler(compiler) finally: _CONFIG_VARS.clear() _CONFIG_VARS.update(tmp) else: customize_compiler(compiler) have_rtld = False use_stubs = False libtype = 'shared' if sys.platform == "darwin": use_stubs = True elif os.name != 'nt': try: import dl use_stubs = have_rtld = hasattr(dl, 'RTLD_NOW') except ImportError: pass if_dl = lambda s: s if have_rtld else '' def get_abi3_suffix(): """Return the file extension for an abi3-compliant Extension()""" for suffix, _, _ in (s for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION): if '.abi3' in suffix: # Unix return suffix elif suffix == '.pyd': # Windows return suffix class build_ext(_build_ext): def run(self): """Build extensions in build directory, then copy if --inplace""" old_inplace, self.inplace = self.inplace, 0 _build_ext.run(self) self.inplace = old_inplace if old_inplace: self.copy_extensions_to_source() def copy_extensions_to_source(self): build_py = self.get_finalized_command('build_py') for ext in self.extensions: fullname = self.get_ext_fullname(ext.name) filename = self.get_ext_filename(fullname) modpath = fullname.split('.') package = '.'.join(modpath[:-1]) package_dir = build_py.get_package_dir(package) dest_filename = os.path.join(package_dir, os.path.basename(filename)) src_filename = os.path.join(self.build_lib, filename) # Always copy, even if source is older than destination, to ensure # that the right extensions for the current Python/platform are # used. copy_file( src_filename, dest_filename, verbose=self.verbose, dry_run=self.dry_run ) if ext._needs_stub: self.write_stub(package_dir or os.curdir, ext, True) def get_ext_filename(self, fullname): filename = _build_ext.get_ext_filename(self, fullname) if fullname in self.ext_map: ext = self.ext_map[fullname] use_abi3 = ( six.PY3 and getattr(ext, 'py_limited_api') and get_abi3_suffix() ) if use_abi3: so_ext = _get_config_var_837('EXT_SUFFIX') filename = filename[:-len(so_ext)] filename = filename + get_abi3_suffix() if isinstance(ext, Library): fn, ext = os.path.splitext(filename) return self.shlib_compiler.library_filename(fn, libtype) elif use_stubs and ext._links_to_dynamic: d, fn = os.path.split(filename) return os.path.join(d, 'dl-' + fn) return filename def initialize_options(self): _build_ext.initialize_options(self) self.shlib_compiler = None self.shlibs = [] self.ext_map = {} def finalize_options(self): _build_ext.finalize_options(self) self.extensions = self.extensions or [] self.check_extensions_list(self.extensions) self.shlibs = [ext for ext in self.extensions if isinstance(ext, Library)] if self.shlibs: self.setup_shlib_compiler() for ext in self.extensions: ext._full_name = self.get_ext_fullname(ext.name) for ext in self.extensions: fullname = ext._full_name self.ext_map[fullname] = ext # distutils 3.1 will also ask for module names # XXX what to do with conflicts? self.ext_map[fullname.split('.')[-1]] = ext ltd = self.shlibs and self.links_to_dynamic(ext) or False ns = ltd and use_stubs and not isinstance(ext, Library) ext._links_to_dynamic = ltd ext._needs_stub = ns filename = ext._file_name = self.get_ext_filename(fullname) libdir = os.path.dirname(os.path.join(self.build_lib, filename)) if ltd and libdir not in ext.library_dirs: ext.library_dirs.append(libdir) if ltd and use_stubs and os.curdir not in ext.runtime_library_dirs: ext.runtime_library_dirs.append(os.curdir) def setup_shlib_compiler(self): compiler = self.shlib_compiler = new_compiler( compiler=self.compiler, dry_run=self.dry_run, force=self.force ) _customize_compiler_for_shlib(compiler) if self.include_dirs is not None: compiler.set_include_dirs(self.include_dirs) if self.define is not None: # 'define' option is a list of (name,value) tuples for (name, value) in self.define: compiler.define_macro(name, value) if self.undef is not None: for macro in self.undef: compiler.undefine_macro(macro) if self.libraries is not None: compiler.set_libraries(self.libraries) if self.library_dirs is not None: compiler.set_library_dirs(self.library_dirs) if self.rpath is not None: compiler.set_runtime_library_dirs(self.rpath) if self.link_objects is not None: compiler.set_link_objects(self.link_objects) # hack so distutils' build_extension() builds a library instead compiler.link_shared_object = link_shared_object.__get__(compiler) def get_export_symbols(self, ext): if isinstance(ext, Library): return ext.export_symbols return _build_ext.get_export_symbols(self, ext) def build_extension(self, ext): ext._convert_pyx_sources_to_lang() _compiler = self.compiler try: if isinstance(ext, Library): self.compiler = self.shlib_compiler _build_ext.build_extension(self, ext) if ext._needs_stub: cmd = self.get_finalized_command('build_py').build_lib self.write_stub(cmd, ext) finally: self.compiler = _compiler def links_to_dynamic(self, ext): """Return true if 'ext' links to a dynamic lib in the same package""" # XXX this should check to ensure the lib is actually being built # XXX as dynamic, and not just using a locally-found version or a # XXX static-compiled version libnames = dict.fromkeys([lib._full_name for lib in self.shlibs]) pkg = '.'.join(ext._full_name.split('.')[:-1] + ['']) return any(pkg + libname in libnames for libname in ext.libraries) def get_outputs(self): return _build_ext.get_outputs(self) + self.__get_stubs_outputs() def __get_stubs_outputs(self): # assemble the base name for each extension that needs a stub ns_ext_bases = ( os.path.join(self.build_lib, *ext._full_name.split('.')) for ext in self.extensions if ext._needs_stub ) # pair each base with the extension pairs = itertools.product(ns_ext_bases, self.__get_output_extensions()) return list(base + fnext for base, fnext in pairs) def __get_output_extensions(self): yield '.py' yield '.pyc' if self.get_finalized_command('build_py').optimize: yield '.pyo' def write_stub(self, output_dir, ext, compile=False): log.info("writing stub loader for %s to %s", ext._full_name, output_dir) stub_file = (os.path.join(output_dir, *ext._full_name.split('.')) + '.py') if compile and os.path.exists(stub_file): raise DistutilsError(stub_file + " already exists! Please delete.") if not self.dry_run: f = open(stub_file, 'w') f.write( '\n'.join([ "def __bootstrap__():", " global __bootstrap__, __file__, __loader__", " import sys, os, pkg_resources, imp" + if_dl(", dl"), " __file__ = pkg_resources.resource_filename" "(__name__,%r)" % os.path.basename(ext._file_name), " del __bootstrap__", " if '__loader__' in globals():", " del __loader__", if_dl(" old_flags = sys.getdlopenflags()"), " old_dir = os.getcwd()", " try:", " os.chdir(os.path.dirname(__file__))", if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"), " imp.load_dynamic(__name__,__file__)", " finally:", if_dl(" sys.setdlopenflags(old_flags)"), " os.chdir(old_dir)", "__bootstrap__()", "" # terminal \n ]) ) f.close() if compile: from distutils.util import byte_compile byte_compile([stub_file], optimize=0, force=True, dry_run=self.dry_run) optimize = self.get_finalized_command('install_lib').optimize if optimize > 0: byte_compile([stub_file], optimize=optimize, force=True, dry_run=self.dry_run) if os.path.exists(stub_file) and not self.dry_run: os.unlink(stub_file) if use_stubs or os.name == 'nt': # Build shared libraries # def link_shared_object( self, objects, output_libname, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): self.link( self.SHARED_LIBRARY, objects, output_libname, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang ) else: # Build static libraries everywhere else libtype = 'static' def link_shared_object( self, objects, output_libname, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): # XXX we need to either disallow these attrs on Library instances, # or warn/abort here if set, or something... # libraries=None, library_dirs=None, runtime_library_dirs=None, # export_symbols=None, extra_preargs=None, extra_postargs=None, # build_temp=None assert output_dir is None # distutils build_ext doesn't pass this output_dir, filename = os.path.split(output_libname) basename, ext = os.path.splitext(filename) if self.library_filename("x").startswith('lib'): # strip 'lib' prefix; this is kludgy if some platform uses # a different prefix basename = basename[3:] self.create_static_lib( objects, basename, output_dir, debug, target_lang ) def _get_config_var_837(name): """ In https://github.com/pypa/setuptools/pull/837, we discovered Python 3.3.0 exposes the extension suffix under the name 'SO'. """ if sys.version_info < (3, 3, 1): name = 'SO' return get_config_var(name) egg_info.py000064400000060340147210141470006677 0ustar00"""setuptools.command.egg_info Create a distribution's .egg-info directory and contents""" from distutils.filelist import FileList as _FileList from distutils.errors import DistutilsInternalError from distutils.util import convert_path from distutils import log import distutils.errors import distutils.filelist import os import re import sys import io import warnings import time import collections from setuptools.extern import six from setuptools.extern.six.moves import map from setuptools import Command from setuptools.command.sdist import sdist from setuptools.command.sdist import walk_revctrl from setuptools.command.setopt import edit_config from setuptools.command import bdist_egg from pkg_resources import ( parse_requirements, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) import setuptools.unicode_utils as unicode_utils from setuptools.glob import glob from setuptools.extern import packaging def translate_pattern(glob): """ Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories. """ pat = '' # This will split on '/' within [character classes]. This is deliberate. chunks = glob.split(os.path.sep) sep = re.escape(os.sep) valid_char = '[^%s]' % (sep,) for c, chunk in enumerate(chunks): last_chunk = c == len(chunks) - 1 # Chunks that are a literal ** are globstars. They match anything. if chunk == '**': if last_chunk: # Match anything if this is the last component pat += '.*' else: # Match '(name/)*' pat += '(?:%s+%s)*' % (valid_char, sep) continue # Break here as the whole path component has been handled # Find any special characters in the remainder i = 0 chunk_len = len(chunk) while i < chunk_len: char = chunk[i] if char == '*': # Match any number of name characters pat += valid_char + '*' elif char == '?': # Match a name character pat += valid_char elif char == '[': # Character class inner_i = i + 1 # Skip initial !/] chars if inner_i < chunk_len and chunk[inner_i] == '!': inner_i = inner_i + 1 if inner_i < chunk_len and chunk[inner_i] == ']': inner_i = inner_i + 1 # Loop till the closing ] is found while inner_i < chunk_len and chunk[inner_i] != ']': inner_i = inner_i + 1 if inner_i >= chunk_len: # Got to the end of the string without finding a closing ] # Do not treat this as a matching group, but as a literal [ pat += re.escape(char) else: # Grab the insides of the [brackets] inner = chunk[i + 1:inner_i] char_class = '' # Class negation if inner[0] == '!': char_class = '^' inner = inner[1:] char_class += re.escape(inner) pat += '[%s]' % (char_class,) # Skip to the end ] i = inner_i else: pat += re.escape(char) i += 1 # Join each chunk with the dir separator if not last_chunk: pat += sep pat += r'\Z' return re.compile(pat, flags=re.MULTILINE|re.DOTALL) class egg_info(Command): description = "create a distribution's .egg-info directory" user_options = [ ('egg-base=', 'e', "directory containing .egg-info directories" " (default: top of the source tree)"), ('tag-date', 'd', "Add date stamp (e.g. 20050528) to version number"), ('tag-build=', 'b', "Specify explicit tag to add to version number"), ('no-date', 'D', "Don't include date stamp [default]"), ] boolean_options = ['tag-date'] negative_opt = { 'no-date': 'tag-date', } def initialize_options(self): self.egg_name = None self.egg_version = None self.egg_base = None self.egg_info = None self.tag_build = None self.tag_date = 0 self.broken_egg_info = False self.vtags = None #################################### # allow the 'tag_svn_revision' to be detected and # set, supporting sdists built on older Setuptools. @property def tag_svn_revision(self): pass @tag_svn_revision.setter def tag_svn_revision(self, value): pass #################################### def save_version_info(self, filename): """ Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. """ egg_info = collections.OrderedDict() # follow the order these keys would have been added # when PYTHONHASHSEED=0 egg_info['tag_build'] = self.tags() egg_info['tag_date'] = 0 edit_config(filename, dict(egg_info=egg_info)) def finalize_options(self): self.egg_name = safe_name(self.distribution.get_name()) self.vtags = self.tags() self.egg_version = self.tagged_version() parsed_version = parse_version(self.egg_version) try: is_version = isinstance(parsed_version, packaging.version.Version) spec = ( "%s==%s" if is_version else "%s===%s" ) list( parse_requirements(spec % (self.egg_name, self.egg_version)) ) except ValueError: raise distutils.errors.DistutilsOptionError( "Invalid distribution name or version syntax: %s-%s" % (self.egg_name, self.egg_version) ) if self.egg_base is None: dirs = self.distribution.package_dir self.egg_base = (dirs or {}).get('', os.curdir) self.ensure_dirname('egg_base') self.egg_info = to_filename(self.egg_name) + '.egg-info' if self.egg_base != os.curdir: self.egg_info = os.path.join(self.egg_base, self.egg_info) if '-' in self.egg_name: self.check_broken_egg_info() # Set package version for the benefit of dumber commands # (e.g. sdist, bdist_wininst, etc.) # self.distribution.metadata.version = self.egg_version # If we bootstrapped around the lack of a PKG-INFO, as might be the # case in a fresh checkout, make sure that any special tags get added # to the version info # pd = self.distribution._patched_dist if pd is not None and pd.key == self.egg_name.lower(): pd._version = self.egg_version pd._parsed_version = parse_version(self.egg_version) self.distribution._patched_dist = None def write_or_delete_file(self, what, filename, data, force=False): """Write `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data` is ``None``, then this is a no-op unless `filename` exists, in which case a warning is issued about the orphaned file (if `force` is false), or deleted (if `force` is true). """ if data: self.write_file(what, filename, data) elif os.path.exists(filename): if data is None and not force: log.warn( "%s not set in setup(), but %s exists", what, filename ) return else: self.delete_file(filename) def write_file(self, what, filename, data): """Write `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file. """ log.info("writing %s to %s", what, filename) if six.PY3: data = data.encode("utf-8") if not self.dry_run: f = open(filename, 'wb') f.write(data) f.close() def delete_file(self, filename): """Delete `filename` (if not a dry run) after announcing it""" log.info("deleting %s", filename) if not self.dry_run: os.unlink(filename) def tagged_version(self): version = self.distribution.get_version() # egg_info may be called more than once for a distribution, # in which case the version string already contains all tags. if self.vtags and version.endswith(self.vtags): return safe_version(version) return safe_version(version + self.vtags) def run(self): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg for ep in iter_entry_points('egg_info.writers'): ep.require(installer=installer) writer = ep.resolve() writer(self, ep.name, os.path.join(self.egg_info, ep.name)) # Get rid of native_libs.txt if it was put there by older bdist_egg nl = os.path.join(self.egg_info, "native_libs.txt") if os.path.exists(nl): self.delete_file(nl) self.find_sources() def tags(self): version = '' if self.tag_build: version += self.tag_build if self.tag_date: version += time.strftime("-%Y%m%d") return version def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") mm = manifest_maker(self.distribution) mm.manifest = manifest_filename mm.run() self.filelist = mm.filelist def check_broken_egg_info(self): bei = self.egg_name + '.egg-info' if self.egg_base != os.curdir: bei = os.path.join(self.egg_base, bei) if os.path.exists(bei): log.warn( "-" * 78 + '\n' "Note: Your current .egg-info directory has a '-' in its name;" '\nthis will not work correctly with "setup.py develop".\n\n' 'Please rename %s to %s to correct this problem.\n' + '-' * 78, bei, self.egg_info ) self.broken_egg_info = self.egg_info self.egg_info = bei # make it work for now class FileList(_FileList): # Implementations of the various MANIFEST.in commands def process_template_line(self, line): # Parse the line: split it up, make sure the right number of words # is there, and return the relevant words. 'action' is always # defined: it's the first word of the line. Which of the other # three are defined depends on the action; it'll be either # patterns, (dir and patterns), or (dir_pattern). (action, patterns, dir, dir_pattern) = self._parse_template_line(line) # OK, now we know that the action is valid and we have the # right number of words on the line for that action -- so we # can proceed with minimal error-checking. if action == 'include': self.debug_print("include " + ' '.join(patterns)) for pattern in patterns: if not self.include(pattern): log.warn("warning: no files found matching '%s'", pattern) elif action == 'exclude': self.debug_print("exclude " + ' '.join(patterns)) for pattern in patterns: if not self.exclude(pattern): log.warn(("warning: no previously-included files " "found matching '%s'"), pattern) elif action == 'global-include': self.debug_print("global-include " + ' '.join(patterns)) for pattern in patterns: if not self.global_include(pattern): log.warn(("warning: no files found matching '%s' " "anywhere in distribution"), pattern) elif action == 'global-exclude': self.debug_print("global-exclude " + ' '.join(patterns)) for pattern in patterns: if not self.global_exclude(pattern): log.warn(("warning: no previously-included files matching " "'%s' found anywhere in distribution"), pattern) elif action == 'recursive-include': self.debug_print("recursive-include %s %s" % (dir, ' '.join(patterns))) for pattern in patterns: if not self.recursive_include(dir, pattern): log.warn(("warning: no files found matching '%s' " "under directory '%s'"), pattern, dir) elif action == 'recursive-exclude': self.debug_print("recursive-exclude %s %s" % (dir, ' '.join(patterns))) for pattern in patterns: if not self.recursive_exclude(dir, pattern): log.warn(("warning: no previously-included files matching " "'%s' found under directory '%s'"), pattern, dir) elif action == 'graft': self.debug_print("graft " + dir_pattern) if not self.graft(dir_pattern): log.warn("warning: no directories found matching '%s'", dir_pattern) elif action == 'prune': self.debug_print("prune " + dir_pattern) if not self.prune(dir_pattern): log.warn(("no previously-included directories found " "matching '%s'"), dir_pattern) else: raise DistutilsInternalError( "this cannot happen: invalid action '%s'" % action) def _remove_files(self, predicate): """ Remove all files from the file list that match the predicate. Return True if any matching files were removed """ found = False for i in range(len(self.files) - 1, -1, -1): if predicate(self.files[i]): self.debug_print(" removing " + self.files[i]) del self.files[i] found = True return found def include(self, pattern): """Include files that match 'pattern'.""" found = [f for f in glob(pattern) if not os.path.isdir(f)] self.extend(found) return bool(found) def exclude(self, pattern): """Exclude files that match 'pattern'.""" match = translate_pattern(pattern) return self._remove_files(match.match) def recursive_include(self, dir, pattern): """ Include all files anywhere in 'dir/' that match the pattern. """ full_pattern = os.path.join(dir, '**', pattern) found = [f for f in glob(full_pattern, recursive=True) if not os.path.isdir(f)] self.extend(found) return bool(found) def recursive_exclude(self, dir, pattern): """ Exclude any file anywhere in 'dir/' that match the pattern. """ match = translate_pattern(os.path.join(dir, '**', pattern)) return self._remove_files(match.match) def graft(self, dir): """Include all files from 'dir/'.""" found = [ item for match_dir in glob(dir) for item in distutils.filelist.findall(match_dir) ] self.extend(found) return bool(found) def prune(self, dir): """Filter out files from 'dir/'.""" match = translate_pattern(os.path.join(dir, '**')) return self._remove_files(match.match) def global_include(self, pattern): """ Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. """ if self.allfiles is None: self.findall() match = translate_pattern(os.path.join('**', pattern)) found = [f for f in self.allfiles if match.match(f)] self.extend(found) return bool(found) def global_exclude(self, pattern): """ Exclude all files anywhere that match the pattern. """ match = translate_pattern(os.path.join('**', pattern)) return self._remove_files(match.match) def append(self, item): if item.endswith('\r'): # Fix older sdists built on Windows item = item[:-1] path = convert_path(item) if self._safe_path(path): self.files.append(path) def extend(self, paths): self.files.extend(filter(self._safe_path, paths)) def _repair(self): """ Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths. """ self.files = list(filter(self._safe_path, self.files)) def _safe_path(self, path): enc_warn = "'%s' not %s encodable -- skipping" # To avoid accidental trans-codings errors, first to unicode u_path = unicode_utils.filesys_decode(path) if u_path is None: log.warn("'%s' in unexpected encoding -- skipping" % path) return False # Must ensure utf-8 encodability utf8_path = unicode_utils.try_encode(u_path, "utf-8") if utf8_path is None: log.warn(enc_warn, path, 'utf-8') return False try: # accept is either way checks out if os.path.exists(u_path) or os.path.exists(utf8_path): return True # this will catch any encode errors decoding u_path except UnicodeEncodeError: log.warn(enc_warn, path, sys.getfilesystemencoding()) class manifest_maker(sdist): template = "MANIFEST.in" def initialize_options(self): self.use_defaults = 1 self.prune = 1 self.manifest_only = 1 self.force_manifest = 1 def finalize_options(self): pass def run(self): self.filelist = FileList() if not os.path.exists(self.manifest): self.write_manifest() # it must exist so it'll get in the list self.add_defaults() if os.path.exists(self.template): self.read_template() self.prune_file_list() self.filelist.sort() self.filelist.remove_duplicates() self.write_manifest() def _manifest_normalize(self, path): path = unicode_utils.filesys_decode(path) return path.replace(os.sep, '/') def write_manifest(self): """ Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. """ self.filelist._repair() # Now _repairs should encodability, but not unicode files = [self._manifest_normalize(f) for f in self.filelist.files] msg = "writing manifest file '%s'" % self.manifest self.execute(write_file, (self.manifest, files), msg) def warn(self, msg): if not self._should_suppress_warning(msg): sdist.warn(self, msg) @staticmethod def _should_suppress_warning(msg): """ suppress missing-file warnings from sdist """ return re.match(r"standard file .*not found", msg) def add_defaults(self): sdist.add_defaults(self) self.filelist.append(self.template) self.filelist.append(self.manifest) rcfiles = list(walk_revctrl()) if rcfiles: self.filelist.extend(rcfiles) elif os.path.exists(self.manifest): self.read_manifest() ei_cmd = self.get_finalized_command('egg_info') self.filelist.graft(ei_cmd.egg_info) def prune_file_list(self): build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() self.filelist.prune(build.build_base) self.filelist.prune(base_dir) sep = re.escape(os.sep) self.filelist.exclude_pattern(r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=1) def write_file(filename, contents): """Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. """ contents = "\n".join(contents) # assuming the contents has been vetted for utf-8 encoding contents = contents.encode("utf-8") with open(filename, "wb") as f: # always write POSIX-style manifest f.write(contents) def write_pkg_info(cmd, basename, filename): log.info("writing %s", filename) if not cmd.dry_run: metadata = cmd.distribution.metadata metadata.version, oldver = cmd.egg_version, metadata.version metadata.name, oldname = cmd.egg_name, metadata.name try: # write unescaped data to PKG-INFO, so older pkg_resources # can still parse it metadata.write_pkg_info(cmd.egg_info) finally: metadata.name, metadata.version = oldname, oldver safe = getattr(cmd.distribution, 'zip_safe', None) bdist_egg.write_safety_flag(cmd.egg_info, safe) def warn_depends_obsolete(cmd, basename, filename): if os.path.exists(filename): log.warn( "WARNING: 'depends.txt' is not used by setuptools 0.6!\n" "Use the install_requires/extras_require setup() args instead." ) def _write_requirements(stream, reqs): lines = yield_lines(reqs or ()) append_cr = lambda line: line + '\n' lines = map(append_cr, lines) stream.writelines(lines) def write_requirements(cmd, basename, filename): dist = cmd.distribution data = six.StringIO() _write_requirements(data, dist.install_requires) extras_require = dist.extras_require or {} for extra in sorted(extras_require): data.write('\n[{extra}]\n'.format(**vars())) _write_requirements(data, extras_require[extra]) cmd.write_or_delete_file("requirements", filename, data.getvalue()) def write_setup_requirements(cmd, basename, filename): data = io.StringIO() _write_requirements(data, cmd.distribution.setup_requires) cmd.write_or_delete_file("setup-requirements", filename, data.getvalue()) def write_toplevel_names(cmd, basename, filename): pkgs = dict.fromkeys( [ k.split('.', 1)[0] for k in cmd.distribution.iter_distribution_names() ] ) cmd.write_file("top-level names", filename, '\n'.join(sorted(pkgs)) + '\n') def overwrite_arg(cmd, basename, filename): write_arg(cmd, basename, filename, True) def write_arg(cmd, basename, filename, force=False): argname = os.path.splitext(basename)[0] value = getattr(cmd.distribution, argname, None) if value is not None: value = '\n'.join(value) + '\n' cmd.write_or_delete_file(argname, filename, value, force) def write_entries(cmd, basename, filename): ep = cmd.distribution.entry_points if isinstance(ep, six.string_types) or ep is None: data = ep elif ep is not None: data = [] for section, contents in sorted(ep.items()): if not isinstance(contents, six.string_types): contents = EntryPoint.parse_group(section, contents) contents = '\n'.join(sorted(map(str, contents.values()))) data.append('[%s]\n%s\n\n' % (section, contents)) data = ''.join(data) cmd.write_or_delete_file('entry points', filename, data, True) def get_pkg_info_revision(): """ Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision. """ warnings.warn("get_pkg_info_revision is deprecated.", DeprecationWarning) if os.path.exists('PKG-INFO'): with io.open('PKG-INFO') as f: for line in f: match = re.match(r"Version:.*-r(\d+)\s*$", line) if match: return int(match.group(1)) return 0 __pycache__/bdist_wininst.cpython-36.opt-1.pyc000064400000001605147210141470015224 0ustar003 K]}@s"ddljjZGdddejZdS)Nc@seZdZdddZddZdS) bdist_wininstrcCs |jj||}|dkrd|_|S)zj Supplement reinitialize_command to work around http://bugs.python.org/issue20819 install install_libN)rr)Z distributionreinitialize_commandr)selfcommandZreinit_subcommandscmdr #/usr/lib/python3.6/bdist_wininst.pyrs z"bdist_wininst.reinitialize_commandc Cs$d|_ztjj|Wdd|_XdS)NTF)Z _is_runningorigrrun)rr r r r szbdist_wininst.runN)r)__name__ __module__ __qualname__rr r r r r rs r)Zdistutils.command.bdist_wininstrrr r r r r s __pycache__/install_egg_info.cpython-36.opt-1.pyc000064400000004472147210141470015654 0ustar003 K]@s\ddlmZmZddlZddlmZddlmZddlmZddl Z Gdddej eZ dS))logdir_utilN)Command) namespaces)unpack_archivec@sBeZdZdZdZdgZddZddZd d Zd d Z d dZ dS)install_egg_infoz.Install an .egg-info directory for the package install-dir=ddirectory to install tocCs d|_dS)N) install_dir)selfr &/usr/lib/python3.6/install_egg_info.pyinitialize_optionssz#install_egg_info.initialize_optionscCsV|jdd|jd}tjdd|j|jjd}|j|_tj j |j ||_ g|_ dS)NZ install_libr egg_infoz .egg-info)r r )Zset_undefined_optionsZget_finalized_command pkg_resourcesZ DistributionZegg_nameZ egg_versionrsourceospathjoinr targetoutputs)r Zei_cmdbasenamer r rfinalize_optionss z!install_egg_info.finalize_optionscCs|jdtjj|jr.skimmer)rrr)r r+r )r rr1s zinstall_egg_info.copytreeN)rr r ) __name__ __module__ __qualname____doc__ descriptionZ user_optionsrrr r!rr r r rr s  r) Z distutilsrrrZ setuptoolsrrZsetuptools.archive_utilrrZ Installerrr r r rs    __pycache__/alias.cpython-36.opt-1.pyc000064400000004465147210141470013444 0ustar003 K]z @sPddlmZddlmZddlmZmZmZddZGdddeZ dd Z d S) )DistutilsOptionError)map) edit_config option_base config_filecCs8xdD]}||krt|SqW|j|gkr4t|S|S)z4Quote an argument for later parsing by shlex.split()"'\#)rrr r )reprsplit)argcr/usr/lib/python3.6/alias.pyshquotes   rc@sHeZdZdZdZdZdgejZejdgZddZ d d Z d d Z d S)aliasz3Define a shortcut that invokes one or more commandsz0define a shortcut to invoke one or more commandsTremoverremove (unset) the aliascCstj|d|_d|_dS)N)rinitialize_optionsargsr)selfrrrrs zalias.initialize_optionscCs*tj||jr&t|jdkr&tddS)NzFMust specify exactly one argument (the alias name) when using --remove)rfinalize_optionsrlenrr)rrrrr#s zalias.finalize_optionscCs|jjd}|jsDtdtdx|D]}tdt||q(WdSt|jdkr|j\}|jrfd}q||krtdt||dStd|dSn$|jd}djtt |jdd}t |j d||ii|j dS) NaliaseszCommand Aliasesz---------------zsetup.py aliasrz No alias definition found for %rr ) Z distributionZget_option_dictrprint format_aliasrrjoinrrrfilenameZdry_run)rrrcommandrrrrun+s&    z alias.runN)rrr) __name__ __module__ __qualname____doc__ descriptionZcommand_consumes_argumentsrZ user_optionsZboolean_optionsrrr#rrrrrs rcCsZ||\}}|tdkrd}n,|tdkr0d}n|tdkrBd}nd|}||d|S) Nglobalz--global-config userz--user-config Zlocalz --filename=%rr)r)namersourcer"rrrrFs    rN) Zdistutils.errorsrZsetuptools.extern.six.movesrZsetuptools.command.setoptrrrrrrrrrrs   4__pycache__/alias.cpython-36.pyc000064400000004465147210141470012505 0ustar003 K]z @sPddlmZddlmZddlmZmZmZddZGdddeZ dd Z d S) )DistutilsOptionError)map) edit_config option_base config_filecCs8xdD]}||krt|SqW|j|gkr4t|S|S)z4Quote an argument for later parsing by shlex.split()"'\#)rrr r )reprsplit)argcr/usr/lib/python3.6/alias.pyshquotes   rc@sHeZdZdZdZdZdgejZejdgZddZ d d Z d d Z d S)aliasz3Define a shortcut that invokes one or more commandsz0define a shortcut to invoke one or more commandsTremoverremove (unset) the aliascCstj|d|_d|_dS)N)rinitialize_optionsargsr)selfrrrrs zalias.initialize_optionscCs*tj||jr&t|jdkr&tddS)NzFMust specify exactly one argument (the alias name) when using --remove)rfinalize_optionsrlenrr)rrrrr#s zalias.finalize_optionscCs|jjd}|jsDtdtdx|D]}tdt||q(WdSt|jdkr|j\}|jrfd}q||krtdt||dStd|dSn$|jd}djtt |jdd}t |j d||ii|j dS) NaliaseszCommand Aliasesz---------------zsetup.py aliasrz No alias definition found for %rr ) Z distributionZget_option_dictrprint format_aliasrrjoinrrrfilenameZdry_run)rrrcommandrrrrun+s&    z alias.runN)rrr) __name__ __module__ __qualname____doc__ descriptionZcommand_consumes_argumentsrZ user_optionsZboolean_optionsrrr#rrrrrs rcCsZ||\}}|tdkrd}n,|tdkr0d}n|tdkrBd}nd|}||d|S) Nglobalz--global-config userz--user-config Zlocalz --filename=%rr)r)namersourcer"rrrrFs    rN) Zdistutils.errorsrZsetuptools.extern.six.movesrZsetuptools.command.setoptrrrrrrrrrrs   4__pycache__/py36compat.cpython-36.pyc000064400000010703147210141470013411 0ustar003 K]z@sdddlZddlmZddlmZddlmZddlmZGdddZe ejdr`Gd ddZdS) N)glob) convert_path)sdist)filterc@s\eZdZdZddZeddZddZdd Zd d Z d d Z ddZ ddZ ddZ dS)sdist_add_defaultsz Mix-in providing forward-compatibility for functionality as found in distutils on Python 3.7. Do not edit the code in this class except to update functionality as implemented in distutils. Instead, override in the subclass. cCs<|j|j|j|j|j|j|jdS)a9Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as scripts. - all C sources listed as part of extensions or C libraries in the setup script (doesn't catch C headers!) Warns if (README or README.txt) or setup.py are missing; everything else is optional. N)_add_defaults_standards_add_defaults_optional_add_defaults_python_add_defaults_data_files_add_defaults_ext_add_defaults_c_libs_add_defaults_scripts)selfr /usr/lib/python3.6/py36compat.py add_defaultsszsdist_add_defaults.add_defaultscCs:tjj|sdStjj|}tjj|\}}|tj|kS)z Case-sensitive path existence check >>> sdist_add_defaults._cs_path_exists(__file__) True >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False F)ospathexistsabspathsplitlistdir)fspathrZ directoryfilenamerrr_cs_path_exists(s  z"sdist_add_defaults._cs_path_existscCs|j|jjg}x|D]}t|trn|}d}x(|D] }|j|r0d}|jj|Pq0W|s|jddj |q|j|r|jj|q|jd|qWdS)NFTz,standard file not found: should have one of z, zstandard file '%s' not found) ZREADMES distributionZ script_name isinstancetuplerfilelistappendwarnjoin)rZ standardsfnZaltsZgot_itrrrr9s       z*sdist_add_defaults._add_defaults_standardscCs8ddg}x*|D]"}ttjjt|}|jj|qWdS)Nz test/test*.pyz setup.cfg)rrrisfilerrextend)rZoptionalpatternfilesrrrrNs z)sdist_add_defaults._add_defaults_optionalcCsd|jd}|jjr$|jj|jx:|jD]0\}}}}x"|D]}|jjtj j ||q>Wq,WdS)Nbuild_py) get_finalized_commandrZhas_pure_modulesrr$get_source_files data_filesrrrr!)rr'ZpkgZsrc_dirZ build_dir filenamesrrrrr Ts    z'sdist_add_defaults._add_defaults_pythoncCs|jjr~xr|jjD]f}t|trDt|}tjj|rz|j j |q|\}}x,|D]$}t|}tjj|rR|j j |qRWqWdS)N) rZhas_data_filesr*rstrrrrr#rr)ritemdirnamer+frrrr ds     z+sdist_add_defaults._add_defaults_data_filescCs(|jjr$|jd}|jj|jdS)N build_ext)rZhas_ext_modulesr(rr$r))rr0rrrr us  z$sdist_add_defaults._add_defaults_extcCs(|jjr$|jd}|jj|jdS)N build_clib)rZhas_c_librariesr(rr$r))rr1rrrr zs  z'sdist_add_defaults._add_defaults_c_libscCs(|jjr$|jd}|jj|jdS)N build_scripts)rZ has_scriptsr(rr$r))rr2rrrr s  z(sdist_add_defaults._add_defaults_scriptsN)__name__ __module__ __qualname____doc__r staticmethodrrrr r r r r rrrrr s rrc@s eZdZdS)rN)r3r4r5rrrrrs) rrZdistutils.utilrZdistutils.commandrZsetuptools.extern.six.movesrrhasattrrrrrs    | __pycache__/upload_docs.cpython-36.opt-1.pyc000064400000013560147210141470014643 0ustar003 K]@sdZddlmZddlmZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddlmZmZddlmZd d lmZd d ZGd ddeZdS)zpupload_docs Implements a Distutils 'upload_docs' subcommand (upload documentation to PyPI's pythonhosted.org). )standard_b64encode)log)DistutilsOptionErrorN)six) http_clienturllib)iter_entry_points)uploadcCstjr dnd}|jd|S)Nsurrogateescapestrictzutf-8)rPY3encode)serrorsr!/usr/lib/python3.6/upload_docs.py_encodesrc@seZdZdZdZdddejfddgZejZd d Zd efgZ ddZ ddZ ddZ ddZ eddZeddZddZdS) upload_docszhttps://pypi.python.org/pypi/zUpload documentation to PyPIz repository=rzurl of repository [default: %s] show-responseN&display full response text from server upload-dir=directory to uploadcCs$|jdkr xtddD]}dSWdS)Nzdistutils.commands build_sphinxT) upload_dirr)selfZeprrr has_sphinx/s zupload_docs.has_sphinxrcCstj|d|_d|_dS)N)r initialize_optionsr target_dir)rrrrr6s zupload_docs.initialize_optionscCstj||jdkrN|jr0|jd}|j|_q`|jd}tjj |j d|_n|j d|j|_d|j krtt jd|jd|jdS)NrbuildZdocsrzpypi.python.orgz3Upload_docs command is deprecated. Use RTD instead.zUsing upload directory %s)r finalize_optionsrrZget_finalized_commandZbuilder_target_dirrospathjoinZ build_baseZensure_dirname repositoryrwarnannounce)rrr rrrr!;s        zupload_docs.finalize_optionsc Cstj|d}z|j|jxtj|jD]~\}}}||jkrT| rTd}t||jxP|D]H}tjj||}|t |jdj tjj } tjj| |} |j || qZWq(WWd|j XdS)Nwz'no files found in upload directory '%s')zipfileZZipFileZmkpathrr"walkrr#r$lenlstripsepwriteclose) rfilenamezip_filerootdirsfilesZtmplnameZfullZrelativedestrrrcreate_zipfileKs   zupload_docs.create_zipfilec Cslx|jD]}|j|q Wtj}|jjj}tjj |d|}z|j ||j |Wdt j |XdS)Nz%s.zip)Zget_sub_commandsZ run_commandtempfileZmkdtemp distributionmetadataget_namer"r#r$r7 upload_fileshutilZrmtree)rZcmd_nameZtmp_dirr5r1rrrrun[s  zupload_docs.runccs|\}}d|}t|ts |g}xn|D]f}t|trN|d|d7}|d}nt|}|Vt|VdV|V|r&|dddkr&dVq&WdS) Nz* Content-Disposition: form-data; name="%s"z; filename="%s"rr s   ) isinstancelisttupler)item sep_boundarykeyvaluestitlevaluerrr _build_partis     zupload_docs._build_partc Csnd}d|}|d}|df}tj|j|d}t||j}tjj|}tj||} d|jd} dj | | fS) z= Build up the MIME payload for the POST data s3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --s--r@)rFz multipart/form-data; boundary=%sascii) functoolspartialrKmapitems itertoolschain from_iterabledecoder$) clsdataboundaryrFZ end_boundaryZ end_itemsZbuilderZ part_groupspartsZ body_items content_typerrr_build_multipart}s  zupload_docs._build_multipartcCs:t|d}|j}WdQRX|jj}d|jtjj||fd}t|j d|j }t |}t j rn|jd}d|}|j|\}} d|j} |j| tjtjj|j\} } } }}}| dkrtj| }n | d krtj| }n td | d }yZ|j|jd | | }|jd ||jdtt||jd||j |j!|Wn6t"j#k r~}z|jt|tj$dSd}~XnX|j%}|j&dkrd|j&|j'f} |j| tjnb|j&dkr|j(d}|dkrd|j}d|} |j| tjnd|j&|j'f} |j| tj$|j)r6t*dd|jdddS)NrbZ doc_upload)z:actionr5content:rLzBasic zSubmitting documentation to %sZhttpZhttpszunsupported schema ZPOSTz Content-typezContent-lengthZ AuthorizationzServer response (%s): %si-ZLocationzhttps://pythonhosted.org/%s/zUpload successful. Visit %szUpload failed (%s): %s-K)+openreadr9r:r;r"r#basenamerZusernameZpasswordrrr rUr[r%r'rINFOrparseZurlparserZHTTPConnectionZHTTPSConnectionAssertionErrorZconnectZ putrequestZ putheaderstrr+Z endheaderssendsocketerrorZERRORZ getresponseZstatusreasonZ getheaderZ show_responseprint)rr0fr]metarWZ credentialsZauthZbodyZctmsgZschemaZnetlocZurlZparamsZqueryZ fragmentsZconnrZerlocationrrrr<s^              zupload_docs.upload_file)rNr)rNr)__name__ __module__ __qualname__ZDEFAULT_REPOSITORY descriptionr Z user_optionsZboolean_optionsrZ sub_commandsrr!r7r> staticmethodrK classmethodr[r<rrrrrs"    r)__doc__base64rZ distutilsrZdistutils.errorsrr"rkr)r8r=rRrNZsetuptools.externrZsetuptools.extern.six.movesrrZ pkg_resourcesrr rrrrrrs       __pycache__/build_clib.cpython-36.pyc000064400000004504147210141470013476 0ustar003 K]@sFddljjZddlmZddlmZddlm Z GdddejZdS)N)DistutilsSetupError)log)newer_pairwise_groupc@seZdZdZddZdS) build_clibav Override the default build_clib behaviour to do the following: 1. Implement a rudimentary timestamp-based dependency system so 'compile()' doesn't run every time. 2. Add more keys to the 'build_info' dictionary: * obj_deps - specify dependencies for each object compiled. this should be a dictionary mapping a key with the source filename to a list of dependencies. Use an empty string for global dependencies. * cflags - specify a list of additional flags to pass to the compiler. c Cs~xv|D]l\}}|jd}|dks4t|ttf r@td|t|}tjd||jdt}t|tsxtd|g}|jdt}t|ttfstd|xX|D]P}|g} | j||j|t} t| ttfstd|| j| |j | qW|j j ||j d} t || ggfkr^|jd} |jd } |jd }|j j||j | | ||jd }|j j| ||j|jd qWdS) Nsourceszfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenameszbuilding '%s' libraryobj_depsz\in 'libraries' option (library '%s'), 'obj_deps' must be a dictionary of type 'source: list') output_dirmacros include_dirscflags)r r r Zextra_postargsdebug)r r )get isinstancelisttuplerrinfodictextendappendZcompilerZobject_filenamesZ build_temprcompiler Zcreate_static_libr)selfZ librariesZlib_nameZ build_inforrZ dependenciesZ global_depssourceZsrc_depsZ extra_depsZexpected_objectsr r r Zobjectsr /usr/lib/python3.6/build_clib.pybuild_librariess`           zbuild_clib.build_librariesN)__name__ __module__ __qualname____doc__rrrrrrsr) Zdistutils.command.build_clibZcommandrZorigZdistutils.errorsrZ distutilsrZsetuptools.dep_utilrrrrrs    __pycache__/egg_info.cpython-36.pyc000064400000050633147210141470013167 0ustar003 K]`@sdZddlmZddlmZddlmZddlm Z ddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'j(Z(ddl)m*Z*ddlm+Z+ddZ,GdddeZ-GdddeZGdddeZ.ddZ/ddZ0ddZ1dd Z2d!d"Z3d#d$Z4d%d&Z5d'd(Z6d0d*d+Z7d,d-Z8d.d/Z9dS)1zUsetuptools.command.egg_info Create a distribution's .egg-info directory and contents)FileList)DistutilsInternalError) convert_path)logN)six)map)Command)sdist) walk_revctrl) edit_config) bdist_egg)parse_requirements safe_name parse_version safe_version yield_lines EntryPointiter_entry_points to_filename)glob) packagingcCsd}|jtjj}tjtj}d|f}xt|D]\}}|t|dk}|dkrv|rd|d7}q4|d||f7}q4d}t|} x:|| kr||} | dkr||d7}n| d kr||7}n| d kr|d} | | kr|| d kr| d} | | kr|| d kr| d} x&| | kr6|| d kr6| d} qW| | krR|tj| 7}nR||d| } d} | dd krd } | dd} | tj| 7} |d| f7}| }n|tj| 7}|d7}qW|s4||7}q4W|d7}tj|tj tj BdS)z Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories. z[^%s]z**z.*z (?:%s+%s)*r*?[!]^Nz[%s]z\Z)flags) splitospathsepreescape enumeratelencompile MULTILINEDOTALL)rZpatZchunksr#Z valid_charcchunkZ last_chunkiZ chunk_lencharZinner_iinnerZ char_classr0/usr/lib/python3.6/egg_info.pytranslate_pattern$sV         r2c@seZdZdZd)d*d+d,gZdgZd diZddZeddZ e j ddZ ddZ ddZ d-ddZ ddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(S).egg_infoz+create a distribution's .egg-info directory egg-base=eLdirectory containing .egg-info directories (default: top of the source tree)tag-dated0Add date stamp (e.g. 20050528) to version number tag-build=b-Specify explicit tag to add to version numberno-dateD"Don't include date stamp [default]cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)NrF)egg_name egg_versionegg_baser3 tag_buildtag_datebroken_egg_infovtags)selfr0r0r1initialize_optionsszegg_info.initialize_optionscCsdS)Nr0)rGr0r0r1tag_svn_revisionszegg_info.tag_svn_revisioncCsdS)Nr0)rGvaluer0r0r1rIscCs0tj}|j|d<d|d<t|t|ddS)z Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. rCrrD)r3N) collections OrderedDicttagsr dict)rGfilenamer3r0r0r1save_version_infos zegg_info.save_version_infoc CsVt|jj|_|j|_|j|_t|j}y6t |t j j }|rFdnd}t t||j|jfWn,tk rtjjd|j|jfYnX|jdkr|jj}|pijdtj|_|jdt|jd|_|jtjkrtjj|j|j|_d|jkr|j|j|jj_ |jj}|dk rR|j |jj!krR|j|_"t|j|_#d|j_dS)Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrBz .egg-info-)$r distributionZget_namer@rMrFtagged_versionrAr isinstancerversionZVersionlistr ValueError distutilserrorsZDistutilsOptionErrorrBZ package_dirgetr!curdirZensure_dirnamerr3r"joincheck_broken_egg_infometadataZ _patched_distkeylowerZ_versionZ_parsed_version)rGZparsed_versionZ is_versionspecdirsZpdr0r0r1finalize_optionss8          zegg_info.finalize_optionsFcCsN|r|j|||n6tjj|rJ|dkr@| r@tjd||dS|j|dS)aWrite `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data` is ``None``, then this is a no-op unless `filename` exists, in which case a warning is issued about the orphaned file (if `force` is false), or deleted (if `force` is true). Nz$%s not set in setup(), but %s exists) write_filer!r"existsrwarn delete_file)rGwhatrOdataforcer0r0r1write_or_delete_files   zegg_info.write_or_delete_filecCsDtjd||tjr|jd}|js@t|d}|j||jdS)zWrite `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file. zwriting %s to %szutf-8wbN) rinforZPY3encodedry_runopenwriteclose)rGrhrOrifr0r0r1rds   zegg_info.write_filecCs tjd||jstj|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrmror!unlink)rGrOr0r0r1rgs zegg_info.delete_filecCs2|jj}|jr$|j|jr$t|St||jS)N)rRZ get_versionrFendswithr)rGrUr0r0r1rSs zegg_info.tagged_versioncCs|j|j|jj}x@tdD]4}|j|d|j}|||jtj j |j|jqWtj j |jd}tj j |r||j ||j dS)Nzegg_info.writers) installerznative_libs.txt)Zmkpathr3rRZfetch_build_eggrZrequireZresolvenamer!r"r\rerg find_sources)rGrvepwriternlr0r0r1run s     z egg_info.runcCs,d}|jr||j7}|jr(|tjd7}|S)Nrz-%Y%m%d)rCrDtimeZstrftime)rGrUr0r0r1rMs  z egg_info.tagscCs4tjj|jd}t|j}||_|j|j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r!r"r\r3manifest_makerrRmanifestr|filelist)rGZmanifest_filenameZmmr0r0r1rx s  zegg_info.find_sourcescCsd|jd}|jtjkr&tjj|j|}tjj|r`tjddddd||j |j |_ ||_ dS)Nz .egg-inforQNz Note: Your current .egg-info directory has a '-' in its name; this will not work correctly with "setup.py develop". Please rename %s to %s to correct this problem. ) r@rBr!r[r"r\rerrfr3rE)rGZbeir0r0r1r](s    zegg_info.check_broken_egg_infoN)r4r5r6)r7r8r9)r:r;r<)r=r>r?)F)__name__ __module__ __qualname__ descriptionZ user_optionsZboolean_optionsZ negative_optrHpropertyrIsetterrPrcrkrdrgrSr|rMrxr]r0r0r0r1r3ws(  / r3c@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)rcCs<|j|\}}}}|dkrV|jddj|x"|D]}|j|s4tjd|q4Wn|dkr|jddj|x"|D]}|j|sxtjd|qxWn|dkr|jd dj|x"|D]}|j|stjd |qWnZ|d kr(|jd dj|x&|D]}|j|stjd |qWn|dkrx|jd|dj|fx|D]"}|j ||sPtjd||qPWn|dkr|jd|dj|fx|D]"}|j ||stjd||qWnp|dkr|jd||j |s8tjd|n>|dkr,|jd||j |s8tjd|n t d|dS)Nincludezinclude  z%warning: no files found matching '%s'excludezexclude z9warning: no previously-included files found matching '%s'zglobal-includezglobal-include z>warning: no files found matching '%s' anywhere in distributionzglobal-excludezglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionzrecursive-includezrecursive-include %s %sz:warning: no files found matching '%s' under directory '%s'zrecursive-excludezrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'graftzgraft z+warning: no directories found matching '%s'prunezprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')Z_parse_template_line debug_printr\rrrfrglobal_includeglobal_excluderecursive_includerecursive_excluderrr)rGlineactionZpatternsdirZ dir_patternpatternr0r0r1process_template_line;sd                 zFileList.process_template_linecCsVd}xLtt|jdddD]2}||j|r|jd|j||j|=d}qW|S)z Remove all files from the file list that match the predicate. Return True if any matching files were removed Frz removing Tr)ranger'filesr)rGZ predicatefoundr-r0r0r1 _remove_filesszFileList._remove_filescCs$ddt|D}|j|t|S)z#Include files that match 'pattern'.cSsg|]}tjj|s|qSr0)r!r"isdir).0rsr0r0r1 sz$FileList.include..)rextendbool)rGrrr0r0r1rs zFileList.includecCst|}|j|jS)z#Exclude files that match 'pattern'.)r2rmatch)rGrrr0r0r1rszFileList.excludecCs8tjj|d|}ddt|ddD}|j|t|S)zN Include all files anywhere in 'dir/' that match the pattern. z**cSsg|]}tjj|s|qSr0)r!r"r)rrsr0r0r1rsz.FileList.recursive_include..T) recursive)r!r"r\rrr)rGrrZ full_patternrr0r0r1rs zFileList.recursive_includecCs ttjj|d|}|j|jS)zM Exclude any file anywhere in 'dir/' that match the pattern. z**)r2r!r"r\rr)rGrrrr0r0r1rszFileList.recursive_excludecCs$ddt|D}|j|t|S)zInclude all files from 'dir/'.cSs"g|]}tjj|D]}|qqSr0)rXrfindall)rZ match_diritemr0r0r1rsz"FileList.graft..)rrr)rGrrr0r0r1rs  zFileList.graftcCsttjj|d}|j|jS)zFilter out files from 'dir/'.z**)r2r!r"r\rr)rGrrr0r0r1rszFileList.prunecsJ|jdkr|jttjjd|fdd|jD}|j|t|S)z Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. Nz**csg|]}j|r|qSr0)r)rrs)rr0r1rsz+FileList.global_include..)Zallfilesrr2r!r"r\rr)rGrrr0)rr1rs   zFileList.global_includecCsttjjd|}|j|jS)zD Exclude all files anywhere that match the pattern. z**)r2r!r"r\rr)rGrrr0r0r1rszFileList.global_excludecCs8|jdr|dd}t|}|j|r4|jj|dS)N rr)rur _safe_pathrappend)rGrr"r0r0r1rs    zFileList.appendcCs|jjt|j|dS)N)rrfilterr)rGpathsr0r0r1rszFileList.extendcCstt|j|j|_dS)z Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths. N)rVrrr)rGr0r0r1_repairszFileList._repairc Csd}tj|}|dkr(tjd|dStj|d}|dkrNtj||ddSy tjj|shtjj|rldSWn&tk rtj||t j YnXdS)Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFzutf-8T) unicode_utilsfilesys_decoderrfZ try_encoder!r"reUnicodeEncodeErrorsysgetfilesystemencoding)rGr"Zenc_warnZu_pathZ utf8_pathr0r0r1rs  zFileList._safe_pathN)rrrrrrrrrrrrrrrrrr0r0r0r1r8sI     rc@s\eZdZdZddZddZddZdd Zd d Zd d Z e ddZ ddZ ddZ dS)r~z MANIFEST.incCsd|_d|_d|_d|_dS)Nr)Z use_defaultsrZ manifest_onlyZforce_manifest)rGr0r0r1rHsz!manifest_maker.initialize_optionscCsdS)Nr0)rGr0r0r1rcszmanifest_maker.finalize_optionscCsdt|_tjj|js|j|jtjj|jr<|j |j |jj |jj |jdS)N) rrr!r"rerwrite_manifest add_defaultstemplateZ read_templateprune_file_listsortZremove_duplicates)rGr0r0r1r|s  zmanifest_maker.runcCstj|}|jtjdS)N/)rrreplacer!r#)rGr"r0r0r1_manifest_normalizes z"manifest_maker._manifest_normalizecsBjjfddjjD}dj}jtj|f|dS)zo Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. csg|]}j|qSr0)r)rrs)rGr0r1r sz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrZexecuterd)rGrmsgr0)rGr1rs  zmanifest_maker.write_manifestcCs|j|stj||dS)N)_should_suppress_warningr rf)rGrr0r0r1rf$s zmanifest_maker.warncCs tjd|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r$r)rr0r0r1r(sz'manifest_maker._should_suppress_warningcCsttj||jj|j|jj|jtt}|rB|jj|nt j j |jrX|j |j d}|jj|jdS)Nr3)r rrrrrrVr rr!r"reZ read_manifestget_finalized_commandrr3)rGZrcfilesZei_cmdr0r0r1r/s   zmanifest_maker.add_defaultscCsZ|jd}|jj}|jj|j|jj|tjtj }|jj d|d|dddS)Nbuildz(^|z)(RCS|CVS|\.svn)r)Zis_regex) rrRZ get_fullnamerrZ build_baser$r%r!r#Zexclude_pattern)rGrZbase_dirr#r0r0r1r;s    zmanifest_maker.prune_file_listN)rrrrrHrcr|rrrf staticmethodrrrr0r0r0r1r~s    r~c Cs8dj|}|jd}t|d}|j|WdQRXdS)z{Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.  zutf-8rlN)r\rnrprq)rOcontentsrsr0r0r1rdEs   rdc Cs|tjd||jsx|jj}|j|j|_}|j|j|_}z|j |j Wd|||_|_Xt |jdd}t j |j |dS)Nz writing %sZzip_safe)rrmrorRr^rArUr@rwwrite_pkg_infor3getattrr Zwrite_safety_flag)cmdbasenamerOr^ZoldverZoldnameZsafer0r0r1rRs rcCstjj|rtjddS)NzsWARNING: 'depends.txt' is not used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)r!r"rerrf)rrrOr0r0r1warn_depends_obsoletees rcCs,t|pf}dd}t||}|j|dS)NcSs|dS)Nrr0)rr0r0r1osz%_write_requirements..)rr writelines)streamZreqslinesZ append_crr0r0r1_write_requirementsms  rcCsn|j}tj}t||j|jp"i}x2t|D]&}|jdjft t|||q.W|j d||j dS)Nz [{extra}] Z requirements) rRrStringIOrZinstall_requiresextras_requiresortedrqformatvarsrkgetvalue)rrrOZdistrirZextrar0r0r1write_requirementsts  rcCs,tj}t||jj|jd||jdS)Nzsetup-requirements)iorrrRZsetup_requiresrkr)rrrOrir0r0r1write_setup_requirementssrcCs:tjdd|jjD}|jd|djt|ddS)NcSsg|]}|jdddqS).rr)r )rkr0r0r1rsz(write_toplevel_names..ztop-level namesr)rNfromkeysrRZiter_distribution_namesrdr\r)rrrOZpkgsr0r0r1write_toplevel_namessrcCst|||ddS)NT) write_arg)rrrOr0r0r1 overwrite_argsrFcCsHtjj|d}t|j|d}|dk r4dj|d}|j||||dS)Nrr)r!r"splitextrrRr\rk)rrrOrjZargnamerJr0r0r1rs rcCs|jj}t|tjs|dkr"|}nr|dk rg}xZt|jD]J\}}t|tjsttj||}dj tt t |j }|j d||fqsR           (   SBEI    __pycache__/develop.cpython-36.pyc000064400000014316147210141470013046 0ustar003 K]n@sddlmZddlmZddlmZmZddlZddlZddl Z ddl m Z ddl m Z mZmZddlmZddlmZddlZGd d d ejeZGd d d eZdS) ) convert_path)log)DistutilsErrorDistutilsOptionErrorN)six) Distribution PathMetadatanormalize_path) easy_install) namespacesc@sveZdZdZdZejddgZejdgZd Zd d Z d d Z ddZ e ddZ ddZddZddZddZdS)developzSet up package for developmentz%install package in 'development mode' uninstalluUninstall this source package egg-path=N-Set the path to be used in the .egg-link fileFcCs2|jrd|_|j|jn|j|jdS)NT)r Z multi_versionuninstall_linkZuninstall_namespacesinstall_for_developmentZwarn_deprecated_options)selfr/usr/lib/python3.6/develop.pyruns  z develop.runcCs&d|_d|_tj|d|_d|_dS)N.)r egg_pathr initialize_options setup_pathZalways_copy_from)rrrrr's  zdevelop.initialize_optionscCs|jd}|jr,d}|j|jf}t|||jg|_tj||j|j |j j t j d|jd}t jj|j||_|j|_|jdkrt jj|j|_t|j}tt jj|j|j}||krtd|t|t|t jj|j|jd|_|j|j|j|j|_dS)Negg_infoz-Please rename %r to %r before using 'develop'z*.eggz .egg-linkzA--egg-path must be a relative path from the install directory to ) project_name)get_finalized_commandZbroken_egg_inforrZegg_nameargsr finalize_optionsZexpand_basedirsZ expand_dirsZ package_indexscanglobospathjoin install_diregg_linkegg_baserabspathr rrrdist_resolve_setup_pathr)rZeitemplaterZ egg_link_fntargetrrrrr .s<           zdevelop.finalize_optionscCsh|jtjdjd}|tjkr0d|jdd}ttjj|||}|ttjkrdt d|ttj|S)z Generate a path from egg_base back to '.' where the setup script resides and ensure that path points to the setup path from $install_dir/$egg_path. /z../zGCan't get a consistent path to setup script from installation directory) replacer#seprstripcurdircountr r$r%r)r(r&rZ path_to_setupZresolvedrrrr+Xs zdevelop._resolve_setup_pathc CsDtjrt|jddr|jddd|jd|jd}t|j}|jd|d|jd|jddd|jd|jd}||_ ||j _ t ||j |j _n"|jd|jdd d|jd|jtjr|jtjdt_|jtjd |j|j|js,t|jd }|j|j d |jWdQRX|jd|j |j dS) NZuse_2to3FZbuild_pyr)Zinplacer)r(Z build_extr/zCreating %s (link to %s)w )rZPY3getattr distributionZreinitialize_commandZ run_commandrr Z build_librr*locationrrZ _providerZinstall_site_py setuptoolsZbootstrap_install_fromr Zinstall_namespacesrinfor'r(dry_runopenwriterZprocess_distributionZno_deps)rZbpy_cmdZ build_pathZei_cmdfrrrrks4          zdevelop.install_for_developmentcCstjj|jrztjd|j|jt|j}dd|D}|j||j g|j |j gfkrhtj d|dS|j sztj |j|j s|j|j|jjrtj ddS)NzRemoving %s (link to %s)cSsg|] }|jqSr)r2).0linerrr sz*develop.uninstall_link..z$Link points to %s: uninstall abortedz5Note: you must uninstall or replace scripts manually!)r#r$existsr'rr;r(r=closerrwarnr<unlinkZ update_pthr*r8scripts)rZ egg_link_filecontentsrrrrs    zdevelop.uninstall_linkc Cs||jk rtj||S|j|x^|jjp,gD]N}tjjt |}tjj |}t j |}|j }WdQRX|j||||q.WdS)N)r*r install_egg_scriptsinstall_wrapper_scriptsr8rGr#r$r)rbasenameior=readZinstall_script)rr*Z script_nameZ script_pathZstrmZ script_textrrrrIs     zdevelop.install_egg_scriptscCst|}tj||S)N)VersionlessRequirementr rJ)rr*rrrrJszdevelop.install_wrapper_scripts)r rr)rNr)__name__ __module__ __qualname____doc__ descriptionr Z user_optionsZboolean_optionsZcommand_consumes_argumentsrrr staticmethodr+rrrIrJrrrrr s  * /r c@s(eZdZdZddZddZddZdS) rNaz Adapt a pkg_resources.Distribution to simply return the project name as the 'requirement' so that scripts will work across multiple versions. >>> dist = Distribution(project_name='foo', version='1.0') >>> str(dist.as_requirement()) 'foo==1.0' >>> adapted_dist = VersionlessRequirement(dist) >>> str(adapted_dist.as_requirement()) 'foo' cCs ||_dS)N)_VersionlessRequirement__dist)rr*rrr__init__szVersionlessRequirement.__init__cCs t|j|S)N)r7rU)rnamerrr __getattr__sz"VersionlessRequirement.__getattr__cCs|jS)N)r)rrrras_requirementsz%VersionlessRequirement.as_requirementN)rOrPrQrRrVrXrYrrrrrNs rN)Zdistutils.utilrZ distutilsrZdistutils.errorsrrr#r"rLZsetuptools.externrZ pkg_resourcesrrr Zsetuptools.command.easy_installr r:r ZDevelopInstallerr objectrNrrrrs     4__pycache__/build_py.cpython-36.pyc000064400000020460147210141470013214 0ustar003 K]|% @sddlmZddlmZddljjZddlZddlZddl Z ddl Z ddl Z ddl Z ddlmZddlmZmZmZyddlmZWn"ek rGdddZYnXGd d d ejeZdd d Zd dZdS))glob) convert_pathN)six)mapfilter filterfalse) Mixin2to3c@seZdZdddZdS)rTcCsdS)z do nothingN)selffilesZdoctestsr r /usr/lib/python3.6/build_py.pyrun_2to3szMixin2to3.run_2to3N)T)__name__ __module__ __qualname__r r r r r rsrc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZeddZd S)!build_pyaXEnhanced 'build_py' command that includes data files with packages The data files are specified via a 'package_data' argument to 'setup()'. See 'setuptools.dist.Distribution' for more details. Also, this version of the 'build_py' command allows you to specify both 'py_modules' and 'packages' in the same setup operation. cCsFtjj||jj|_|jjp i|_d|jkr6|jd=g|_g|_dS)N data_files) origrfinalize_options distribution package_dataexclude_package_data__dict___build_py__updated_files_build_py__doctests_2to3)r r r r r!s   zbuild_py.finalize_optionscCs||j r|j rdS|jr"|j|jr8|j|j|j|jd|j|jd|j|jd|jt j j |dddS)z?Build modules, packages, and copy data files to build directoryNFTr)Zinclude_bytecode) Z py_modulespackagesZ build_modulesZbuild_packagesbuild_package_datar rrZ byte_compilerrZ get_outputs)r r r r run+sz build_py.runcCs&|dkr|j|_|jStjj||S)zlazily compute data filesr)_get_data_filesrrr __getattr__)r attrr r r r?s zbuild_py.__getattr__cCsJtjrt|tjr|jd}tjj||||\}}|rB|jj |||fS)N.) rZPY2 isinstanceZ string_typessplitrr build_modulerappend)r moduleZ module_filepackageZoutfilecopiedr r r r$Fs    zbuild_py.build_modulecCs|jtt|j|jpfS)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples)analyze_manifestlistr_get_pkg_data_filesr)r r r r rPszbuild_py._get_data_filescsJ|j|tjj|jg|jd}fdd|j|D}|||fS)Nr!csg|]}tjj|qSr )ospathrelpath).0file)src_dirr r ^sz0build_py._get_pkg_data_files..)get_package_dirr,r-joinZ build_libr#find_data_files)r r' build_dir filenamesr )r1r r+Us   zbuild_py._get_pkg_data_filescCsX|j|j||}tt|}tjj|}ttj j |}tj|j j |g|}|j |||S)z6Return filenames for package's data files in 'src_dir')_get_platform_patternsrrr itertoolschain from_iterablerr,r-isfilemanifest_filesgetexclude_data_files)r r'r1patternsZglobs_expandedZ globs_matchesZ glob_filesr r r r r5cs   zbuild_py.find_data_filesc Csx|jD]\}}}}xr|D]j}tjj||}|jtjj|tjj||}|j||\}} tjj|}| r||jj kr|j j |qWqWdS)z$Copy data files into build directoryN) rr,r-r4ZmkpathdirnameZ copy_fileabspathrZconvert_2to3_doctestsrr%) r r'r1r6r7filenametargetZsrcfileZoutfr(r r r rts   zbuild_py.build_package_datac Csi|_}|jjsdSi}x$|jp$fD]}||t|j|<q&W|jd|jd}x|jj D]}t j j t|\}}d}|} x:|r||kr||kr|}t j j |\}} t j j | |}qW||kr^|jdr|| krq^|j||gj|q^WdS)NZegg_infoz.py)r=rZinclude_package_datarassert_relativer3Z run_commandZget_finalized_commandZfilelistr r,r-r#r4endswith setdefaultr%) r ZmfZsrc_dirsr'Zei_cmdr-dfprevZoldfZdfr r r r)s(   zbuild_py.analyze_manifestcCsdS)Nr )r r r r get_data_filesszbuild_py.get_data_filescCsy |j|Stk rYnXtjj|||}||j|<| sJ|jj rN|Sx,|jjD]}||ksr|j|drXPqXW|Stj |d}|j }WdQRXd|krt j j d|f|S)z8Check namespace packages' __init__ for declare_namespacer!rbNsdeclare_namespacezNamespace package problem: %s is a namespace package, but its __init__.py does not call declare_namespace()! Please fix it. (See the setuptools manual under "Namespace Packages" for details.) ")packages_checkedKeyErrorrr check_packagerZnamespace_packages startswithioopenread distutilserrorsZDistutilsError)r r'Z package_dirZinit_pyZpkgrIcontentsr r r rOs&   zbuild_py.check_packagecCsi|_tjj|dS)N)rMrrinitialize_options)r r r r rWszbuild_py.initialize_optionscCs0tjj||}|jjdk r,tjj|jj|S|S)N)rrr3rZsrc_rootr,r-r4)r r'resr r r r3s zbuild_py.get_package_dircs\t|j|j||}fdd|D}tjj|}t|fddD}tt|S)z6Filter filenames for package's data files in 'src_dir'c3s|]}tj|VqdS)N)fnmatchr)r/pattern)r r r sz.build_py.exclude_data_files..c3s|]}|kr|VqdS)Nr )r/fn)badr r r[s)r*r8rr9r:r;set_unique_everseen)r r'r1r r@Z match_groupsZmatchesZkeepersr )r]r r r?s   zbuild_py.exclude_data_filescs.tj|jdg|j|g}fdd|DS)z yield platform-specific path patterns (suitable for glob or fn_match) from a glob-based spec (such as self.package_data or self.exclude_package_data) matching package in src_dir. c3s |]}tjjt|VqdS)N)r,r-r4r)r/rZ)r1r r r[sz2build_py._get_platform_patterns..)r9r:r>)specr'r1Z raw_patternsr )r1r r8s   zbuild_py._get_platform_patternsN)rrr__doc__rrrr$rr+r5rr)rKrOrWr3r? staticmethodr8r r r r rs    rccsjt}|j}|dkr:xPt|j|D]}|||Vq"Wn,x*|D]"}||}||kr@|||Vq@WdS)zHList unique elements, preserving order. Remember all elements ever seen.N)r^addr __contains__)iterablekeyseenZseen_addelementkr r r r_s  r_cCs:tjj|s|Sddlm}tjdj|}||dS)Nr)DistutilsSetupErrorz Error: setup script specifies an absolute path: %s setup() arguments must *always* be /-separated paths relative to the setup.py directory, *never* absolute paths. )r,r-isabsdistutils.errorsrktextwrapdedentlstrip)r-rkmsgr r r rEs   rE)N)rZdistutils.utilrZdistutils.command.build_pyZcommandrrr,rYrnrQrmrTr9Zsetuptools.externrZsetuptools.extern.six.movesrrrZsetuptools.lib2to3_exr ImportErrorr_rEr r r r s$    Y __pycache__/install_lib.cpython-36.pyc000064400000007647147210141470013715 0ustar003 K]@sBddlZddlZddlmZmZddljjZGdddejZdS)N)productstarmapc@sZeZdZdZddZddZddZedd Zd d Z ed d Z dddZ ddZ dS) install_libz9Don't add compiled flags to filenames of non-Python filescCs&|j|j}|dk r"|j|dS)N)ZbuildinstallZ byte_compile)selfoutfilesr!/usr/lib/python3.6/install_lib.pyrun szinstall_lib.runcs4fddjD}t|j}ttj|S)z Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations. c3s"|]}j|D] }|VqqdS)N) _all_packages).0Zns_pkgpkg)rrr sz-install_lib.get_exclusions..)_get_SVEM_NSPsr_gen_exclusion_pathssetr_exclude_pkg_path)rZ all_packagesZ excl_specsr)rr get_exclusionss  zinstall_lib.get_exclusionscCs$|jd|g}tjj|jf|S)zw Given a package name and exclusion path within that package, compute the full exclusion path. .)splitospathjoinZ install_dir)rr Zexclusion_pathpartsrrr rszinstall_lib._exclude_pkg_pathccs$x|r|V|jd\}}}qWdS)zn >>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo'] rN) rpartition)Zpkg_namesepZchildrrr r 'szinstall_lib._all_packagescCs,|jjs gS|jd}|j}|r(|jjSgS)z Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise. r)Z distributionZnamespace_packagesZget_finalized_commandZ!single_version_externally_managed)rZ install_cmdZsvemrrr r1s  zinstall_lib._get_SVEM_NSPsccsbdVdVdVttds dStjjddtj}|dV|d V|d V|d VdS) zk Generate file paths to be excluded for namespace packages (bytecode cache files). z __init__.pyz __init__.pycz __init__.pyoget_tagN __pycache__z __init__.z.pycz.pyoz .opt-1.pycz .opt-2.pyc)hasattrimprrrr)baserrr rAs    z install_lib._gen_exclusion_pathsrc sj|r|r| st|js.tjj|||Sddlm}ddlmgfdd}||||S)Nr)unpack_directory)logcs<|krjd|dSjd|tjj|j||S)Nz/Skipping installation of %s (namespace package)Fzcopying %s -> %s)warninforrdirnameappend)srcdst)excluder#rrr pfgs z!install_lib.copy_tree..pf) AssertionErrorrorigr copy_treeZsetuptools.archive_utilr"Z distutilsr#) rZinfileZoutfileZ preserve_modeZpreserve_timesZpreserve_symlinkslevelr"r+r)r*r#rr r.Vs   zinstall_lib.copy_treecs.tjj|}|jr*fdd|DS|S)Ncsg|]}|kr|qSrr)r f)r*rr xsz+install_lib.get_outputs..)r-r get_outputsr)rZoutputsr)r*r r2ts  zinstall_lib.get_outputsN)r!r!rr!) __name__ __module__ __qualname____doc__r rr staticmethodr rrr.r2rrrr rs   r) rr itertoolsrrZdistutils.command.install_libZcommandrr-rrrr s __pycache__/upload_docs.cpython-36.pyc000064400000013610147210141470013700 0ustar003 K]@sdZddlmZddlmZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddlmZmZddlmZd d lmZd d ZGd ddeZdS)zpupload_docs Implements a Distutils 'upload_docs' subcommand (upload documentation to PyPI's pythonhosted.org). )standard_b64encode)log)DistutilsOptionErrorN)six) http_clienturllib)iter_entry_points)uploadcCstjr dnd}|jd|S)Nsurrogateescapestrictzutf-8)rPY3encode)serrorsr!/usr/lib/python3.6/upload_docs.py_encodesrc@seZdZdZdZdddejfddgZejZd d Zd efgZ ddZ ddZ ddZ ddZ eddZeddZddZdS) upload_docszhttps://pypi.python.org/pypi/zUpload documentation to PyPIz repository=rzurl of repository [default: %s] show-responseN&display full response text from server upload-dir=directory to uploadcCs$|jdkr xtddD]}dSWdS)Nzdistutils.commands build_sphinxT) upload_dirr)selfZeprrr has_sphinx/s zupload_docs.has_sphinxrcCstj|d|_d|_dS)N)r initialize_optionsr target_dir)rrrrr6s zupload_docs.initialize_optionscCstj||jdkrN|jr0|jd}|j|_q`|jd}tjj |j d|_n|j d|j|_d|j krtt jd|jd|jdS)NrbuildZdocsrzpypi.python.orgz3Upload_docs command is deprecated. Use RTD instead.zUsing upload directory %s)r finalize_optionsrrZget_finalized_commandZbuilder_target_dirrospathjoinZ build_baseZensure_dirname repositoryrwarnannounce)rrr rrrr!;s        zupload_docs.finalize_optionsc Cstj|d}z|j|jxtj|jD]~\}}}||jkrT| rTd}t||jxP|D]H}tjj||}|t |jdj tjj } tjj| |} |j || qZWq(WWd|j XdS)Nwz'no files found in upload directory '%s')zipfileZZipFileZmkpathrr"walkrr#r$lenlstripsepwriteclose) rfilenamezip_filerootdirsfilesZtmplnameZfullZrelativedestrrrcreate_zipfileKs   zupload_docs.create_zipfilec Cslx|jD]}|j|q Wtj}|jjj}tjj |d|}z|j ||j |Wdt j |XdS)Nz%s.zip)Zget_sub_commandsZ run_commandtempfileZmkdtemp distributionmetadataget_namer"r#r$r7 upload_fileshutilZrmtree)rZcmd_nameZtmp_dirr5r1rrrrun[s  zupload_docs.runccs|\}}d|}t|ts |g}xn|D]f}t|trN|d|d7}|d}nt|}|Vt|VdV|V|r&|dddkr&dVq&WdS) Nz* Content-Disposition: form-data; name="%s"z; filename="%s"rr s   ) isinstancelisttupler)item sep_boundarykeyvaluestitlevaluerrr _build_partis     zupload_docs._build_partc Csnd}d|}|d}|df}tj|j|d}t||j}tjj|}tj||} d|jd} dj | | fS) z= Build up the MIME payload for the POST data s3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --s--r@)rFz multipart/form-data; boundary=%sascii) functoolspartialrKmapitems itertoolschain from_iterabledecoder$) clsdataboundaryrFZ end_boundaryZ end_itemsZbuilderZ part_groupspartsZ body_items content_typerrr_build_multipart}s  zupload_docs._build_multipartcCsPt|d}|j}WdQRX|jj}d|jtjj||fd}t|j d|j }t |}t j rn|jd}d|}|j|\}} d|j} |j| tjtjj|j\} } } }}}| r| r| st| dkrtj| }n | d krtj| }n td | d }yZ|j|jd | | }|jd ||jdtt||jd||j |j!|Wn6t"j#k r}z|jt|tj$dSd}~XnX|j%}|j&dkrd|j&|j'f} |j| tjnb|j&dkr|j(d}|dkrd|j}d|} |j| tjnd|j&|j'f} |j| tj$|j)rLt*dd|jdddS)NrbZ doc_upload)z:actionr5content:rLzBasic zSubmitting documentation to %sZhttpZhttpszunsupported schema ZPOSTz Content-typezContent-lengthZ AuthorizationzServer response (%s): %si-ZLocationzhttps://pythonhosted.org/%s/zUpload successful. Visit %szUpload failed (%s): %s-K)+openreadr9r:r;r"r#basenamerZusernameZpasswordrrr rUr[r%r'rINFOrparseZurlparseAssertionErrorrZHTTPConnectionZHTTPSConnectionZconnectZ putrequestZ putheaderstrr+Z endheaderssendsocketerrorZERRORZ getresponseZstatusreasonZ getheaderZ show_responseprint)rr0fr]metarWZ credentialsZauthZbodyZctmsgZschemaZnetlocZurlZparamsZqueryZ fragmentsZconnrZerlocationrrrr<s`              zupload_docs.upload_file)rNr)rNr)__name__ __module__ __qualname__ZDEFAULT_REPOSITORY descriptionr Z user_optionsZboolean_optionsrZ sub_commandsrr!r7r> staticmethodrK classmethodr[r<rrrrrs"    r)__doc__base64rZ distutilsrZdistutils.errorsrr"rkr)r8r=rRrNZsetuptools.externrZsetuptools.extern.six.movesrrZ pkg_resourcesrr rrrrrrs       __pycache__/install.cpython-36.pyc000064400000007471147210141470013062 0ustar003 K]K@svddlmZddlZddlZddlZddlZddljjZ ddl Z e jZ Gddde jZdde jj Dej e_ dS))DistutilsArgErrorNc@seZdZdZejjddgZejjddgZddd fd d d fgZe eZ d d Z ddZ ddZ ddZeddZddZdS)installz7Use easy_install to install the package, w/dependenciesold-and-unmanageableNTry not to use this!!single-version-externally-managed5used by system package builders to create 'flat' eggsZinstall_egg_infocCsdS)NT)selfrr/usr/lib/python3.6/install.pyszinstall.Zinstall_scriptscCsdS)NTr)r rrr r scCstjj|d|_d|_dS)N)origrinitialize_optionsold_and_unmanageable!single_version_externally_managed)r rrr r s zinstall.initialize_optionscCs<tjj||jrd|_n|jr8|j r8|j r8tddS)NTzAYou must specify --record or --root when building system packages)r rfinalize_optionsrootrrecordr)r rrr r%s zinstall.finalize_optionscCs(|js |jrtjj|Sd|_d|_dS)N)rrr rhandle_extra_pathZ path_fileZ extra_dirs)r rrr r0s  zinstall.handle_extra_pathcCs@|js |jrtjj|S|jtjs4tjj|n|jdS)N) rrr rrun_called_from_setupinspectZ currentframedo_egg_install)r rrr r:s   z install.runcCsz|dkr4d}tj|tjdkr0d}tj|dStj|d}|dd\}tj|}|jjdd }|d kox|j d kS) a Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any other way, the immediate caller *might* be 'run_command', but it won't have been called by 'run_commands'. Return True in that case or if a call stack is unavailable. Return False otherwise. Nz4Call stack not available. bdist_* commands may fail.Z IronPythonz6For best results, pass -X:Frames to enable call stack.T__name__rzdistutils.distZ run_commands) warningswarnplatformZpython_implementationrZgetouterframesZ getframeinfo f_globalsgetZfunction)Z run_framemsgresZcallerinfoZ caller_modulerrr rEs     zinstall._called_from_setupcCs|jjd}||jd|j|jd}|jd|_|jjtjd|j d|jj dj g}t j rp|jdt j ||_|jdt _ dS)N easy_installx)argsrr.z*.eggZ bdist_eggr)Z distributionZget_command_classrrZensure_finalizedZalways_copy_fromZ package_indexscanglobZ run_commandZget_command_objZ egg_output setuptoolsZbootstrap_install_frominsertr&r)r r$cmdr&rrr r`s  zinstall.do_egg_install)rNr)rNr)r __module__ __qualname____doc__r rZ user_optionsZboolean_options new_commandsdict_ncr rrr staticmethodrrrrrr rs      rcCsg|]}|dtjkr|qS)r)rr2).0r,rrr {sr5)Zdistutils.errorsrrr)rrZdistutils.command.installZcommandrr r*_installZ sub_commandsr0rrrr s  l__pycache__/saveopts.cpython-36.opt-1.pyc000064400000001520147210141470014204 0ustar003 K]@s$ddlmZmZGdddeZdS)) edit_config option_basec@seZdZdZdZddZdS)saveoptsz#Save command-line options to a filez7save supplied options to setup.cfg or other config filecCsp|j}i}xP|jD]F}|dkr qx6|j|jD]$\}\}}|dkr0||j|i|<q0WqWt|j||jdS)Nrz command line)Z distributionZcommand_optionsZget_option_dictitems setdefaultrfilenameZdry_run)selfZdistZsettingscmdoptsrcvalr /usr/lib/python3.6/saveopts.pyrun s z saveopts.runN)__name__ __module__ __qualname____doc__ descriptionrr r r rrsrN)Zsetuptools.command.setoptrrrr r r rs__pycache__/upload.cpython-36.pyc000064400000002443147210141470012672 0ustar003 K]@s*ddlZddlmZGdddejZdS)N)uploadc@s(eZdZdZddZddZddZdS) rza Override default upload behavior to obtain password in a variety of different ways. cCs8tjj||jptj|_|jp0|jp0|j|_dS)N) origrfinalize_optionsusernamegetpassZgetuserZpassword_load_password_from_keyring_prompt_for_password)selfr /usr/lib/python3.6/upload.pyr s   zupload.finalize_optionsc Cs2ytd}|j|j|jStk r,YnXdS)zM Attempt to load password from keyring. Suppress Exceptions. keyringN) __import__Z get_passwordZ repositoryr Exception)r r r r r rs z"upload._load_password_from_keyringc Cs&ytjSttfk r YnXdS)zH Prompt for a password on the tty. Suppress Exceptions. N)rrKeyboardInterrupt)r r r r r#szupload._prompt_for_passwordN)__name__ __module__ __qualname____doc__rrrr r r r rs r)rZdistutils.commandrrr r r r s __pycache__/bdist_wininst.cpython-36.pyc000064400000001605147210141470014265 0ustar003 K]}@s"ddljjZGdddejZdS)Nc@seZdZdddZddZdS) bdist_wininstrcCs |jj||}|dkrd|_|S)zj Supplement reinitialize_command to work around http://bugs.python.org/issue20819 install install_libN)rr)Z distributionreinitialize_commandr)selfcommandZreinit_subcommandscmdr #/usr/lib/python3.6/bdist_wininst.pyrs z"bdist_wininst.reinitialize_commandc Cs$d|_ztjj|Wdd|_XdS)NTF)Z _is_runningorigrrun)rr r r r szbdist_wininst.runN)r)__name__ __module__ __qualname__rr r r r r rs r)Zdistutils.command.bdist_wininstrrr r r r r s __pycache__/rotate.cpython-36.opt-1.pyc000064400000004707147210141470013650 0ustar003 K]t@s`ddlmZddlmZddlmZddlZddlZddlm Z ddl m Z Gddde Z dS) ) convert_path)log)DistutilsOptionErrorN)six)Commandc@s:eZdZdZdZdddgZgZd d ZddZddZ dS)rotatezDelete older distributionsz2delete older distributions, keeping N newest filesmatch=mpatterns to match (required) dist-dir=d%directory where the distributions arekeep=k(number of matching distributions to keepcCsd|_d|_d|_dS)N)matchdist_dirkeep)selfr/usr/lib/python3.6/rotate.pyinitialize_optionsszrotate.initialize_optionsc Cs|jdkrtd|jdkr$tdyt|j|_Wntk rPtdYnXt|jtjrxdd|jjdD|_|j dd dS) NzQMust specify one or more (comma-separated) match patterns (e.g. '.zip' or '.egg')z$Must specify number of files to keepz--keep must be an integercSsg|]}t|jqSr)rstrip).0prrr +sz+rotate.finalize_options..,Zbdistr)rr) rrrint ValueError isinstancerZ string_typessplitZset_undefined_options)rrrrfinalize_optionss  zrotate.finalize_optionscCs|jdddlm}x|jD]}|jjd|}|tjj|j|}dd|D}|j |j t j dt ||||jd}xD|D]<\}}t j d||jstjj|rtj|qtj|qWqWdS) NZegg_infor)glob*cSsg|]}tjj||fqSr)ospathgetmtime)rfrrrr6szrotate.run..z%d file(s) matching %sz Deleting %s)Z run_commandr"rZ distributionZget_namer$r%joinrsortreverserinfolenrZdry_runisdirshutilZrmtreeunlink)rr"patternfilestr'rrrrun/s       z rotate.runN)rr r )r r r )rrr) __name__ __module__ __qualname____doc__ descriptionZ user_optionsZboolean_optionsrr!r3rrrrr sr) Zdistutils.utilrZ distutilsrZdistutils.errorsrr$r.Zsetuptools.externrZ setuptoolsrrrrrrs     __pycache__/test.cpython-36.opt-1.pyc000064400000017625147210141470013334 0ustar003 K]#@sddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z ddlmZmZddlmZmZmZmZmZmZmZmZmZddlmZGd d d e ZGd d d eZGd ddeZ dS)N)DistutilsErrorDistutilsOptionError)log) TestLoader)six)mapfilter) resource_listdirresource_existsnormalize_path working_set_namespace_packagesevaluate_markeradd_activation_listenerrequire EntryPoint)Commandc@seZdZddZdddZdS)ScanningLoadercCstj|t|_dS)N)r__init__set_visited)selfr/usr/lib/python3.6/test.pyrs zScanningLoader.__init__NcCs||jkrdS|jj|g}|jtj||t|drH|j|jt|drxpt|jdD]`}|j dr|dkr|jd|dd }n"t |j|d r`|jd|}nq`|j|j |q`Wt |d kr|j |S|d SdS) aReturn a suite of all tests cases contained in the given module If the module is a package, load tests from all the modules in it. If the module has an ``additional_tests`` function, call it and add the return value to the tests. Nadditional_tests__path__z.pyz __init__.py.z /__init__.pyr)raddappendrloadTestsFromModulehasattrrr __name__endswithr ZloadTestsFromNamelenZ suiteClass)rmodulepatternZtestsfileZ submodulerrrr#s$      z"ScanningLoader.loadTestsFromModule)N)r% __module__ __qualname__rr#rrrrrsrc@seZdZddZdddZdS)NonDataPropertycCs ||_dS)N)fget)rr.rrrr>szNonDataProperty.__init__NcCs|dkr |S|j|S)N)r.)robjZobjtyperrr__get__AszNonDataProperty.__get__)N)r%r+r,rr0rrrrr-=sr-c@seZdZdZdZd%d&d'gZd d ZddZeddZ ddZ ddZ e j gfddZee j ddZeddZddZddZed d!Zed"d#Zd$S)(testz.Command to run unit tests after in-place buildz#run unit tests after in-place build test-module=m$Run 'test_suite' in specified module test-suite=s9Run single test, case or suite (e.g. 'module.test_suite') test-runner=rTest runner to usecCsd|_d|_d|_d|_dS)N) test_suite test_module test_loader test_runner)rrrrinitialize_optionsSsztest.initialize_optionscCs|jr|jrd}t||jdkrD|jdkr8|jj|_n |jd|_|jdkr^t|jdd|_|jdkrnd|_|jdkrt|jdd|_dS)Nz1You may specify a module or a suite, but not bothz .test_suiter=z&setuptools.command.test:ScanningLoaderr>)r;r<r distributionr=getattrr>)rmsgrrrfinalize_optionsYs        ztest.finalize_optionscCs t|jS)N)list _test_args)rrrr test_argslsztest.test_argsccs6|j rtjdkrdV|jr$dV|jr2|jVdS)NZdiscoverz --verbose)rGrH)r;sys version_infoverbose)rrrrrEps ztest._test_argsc Cs|j |WdQRXdS)zI Backward compatibility for project_on_sys_path context. N)project_on_sys_path)rfuncrrrwith_project_on_sys_pathxs ztest.with_project_on_sys_pathc csPtjot|jdd}|rv|jddd|jd|jd}t|j}|jd|d|jd|jddd|jdn"|jd|jdd d|jd|jd}t j dd}t j j }zbt|j }t j jd|tjtd d td |j|jf|j|g dVWdQRXWd|t j dd<t j jt j j|tjXdS) Nuse_2to3FZbuild_pyr)ZinplaceZegg_info)egg_baseZ build_extrcSs|jS)N)Zactivate)distrrrsz*test.project_on_sys_path..z%s==%s)rPY3rAr@Zreinitialize_commandZ run_commandZget_finalized_commandr Z build_librIpathmodulescopyrPinsertr rrrZegg_nameZ egg_versionpaths_on_pythonpathclearupdate) rZ include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdZold_pathZ old_modulesZ project_pathrrrrLs8             ztest.project_on_sys_pathc cst}tjjd|}tjjdd}z>tjj|}td||g}tjj|}|rX|tjd<dVWd||krztjjddn |tjd<XdS)z Add the indicated paths to the head of the PYTHONPATH environment variable so that subprocesses will also see the packages at these paths. Do this in a context that restores the value on exit. PYTHONPATHrN)objectosenvirongetpathsepjoinrpop)pathsZnothingZorig_pythonpathZcurrent_pythonpathprefixZto_joinnew_pathrrrrXs     ztest.paths_on_pythonpathcCsD|j|j}|j|jpg}|jdd|jjD}tj|||S)z Install the requirements indicated by self.distribution and return an iterable of the dists that were built. css0|](\}}|jdrt|ddr|VqdS):rN) startswithr).0kvrrr sz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rQZir_dZtr_dZer_drrr install_distss  ztest.install_distscCs|j|j}dj|j}|jr0|jd|dS|jd|ttjd|}|j |"|j |j WdQRXWdQRXdS)N zskipping "%s" (dry run)z running "%s"location) ror@ra_argvZdry_runannounceroperator attrgetterrXrL run_tests)rZinstalled_distscmdrcrrrruns    ztest.runcCstjrt|jddr|jjdd}|tkrg}|tjkrD|j ||d7}x"tjD]}|j |rT|j |qTWt t tjj |tjdd|j|j|j|j|jdd}|jjsd|j}|j|tjt|dS)NrOFrr)Z testLoaderZ testRunnerexitzTest failed: %s)rrSrAr@r;splitr rIrUr"rgrDr __delitem__unittestmainrr_resolve_as_epr=r>resultZ wasSuccessfulrsrZERRORr)rr(Z del_modulesnamer1rBrrrrvs(        ztest.run_testscCs dg|jS)Nr|)rF)rrrrrrsz test._argvcCs$|dkr dStjd|}|jS)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)rparseZresolve)valZparsedrrrr~sztest._resolve_as_epN)r2r3r4)r5r6r7)r8r9r:)r%r+r,__doc__ descriptionZ user_optionsr?rCr-rFrErN contextlibcontextmanagerrL staticmethodrXrorxrvpropertyrrr~rrrrr1Gs( -  r1)!r]rtrIrrmr|Zdistutils.errorsrrZ distutilsrrZsetuptools.externrZsetuptools.extern.six.movesrrZ pkg_resourcesr r r r r rrrrZ setuptoolsrrr\r-r1rrrrs   , ) __pycache__/register.cpython-36.opt-1.pyc000064400000001005147210141470014162 0ustar003 K]@s"ddljjZGdddejZdS)Nc@seZdZejjZddZdS)registercCs|jdtjj|dS)NZegg_info)Z run_commandorigrrun)selfr/usr/lib/python3.6/register.pyrs z register.runN)__name__ __module__ __qualname__rr__doc__rrrrrrsr)Zdistutils.command.registerZcommandrrrrrrs __pycache__/bdist_rpm.cpython-36.opt-1.pyc000064400000003244147210141470014330 0ustar003 K]@s"ddljjZGdddejZdS)Nc@s eZdZdZddZddZdS) bdist_rpmaf Override the default bdist_rpm behavior to do the following: 1. Run egg_info to ensure the name and version are properly calculated. 2. Always run 'install' using --single-version-externally-managed to disable eggs in RPM distributions. 3. Replace dash with underscore in the version numbers for better RPM compatibility. cCs|jdtjj|dS)NZegg_info)Z run_commandorigrrun)selfr/usr/lib/python3.6/bdist_rpm.pyrs z bdist_rpm.runcsl|jj}|jdd}tjj|}d|d|fdd|D}|jd}d|}|j|||S)N-_z%define version cs0g|](}|jddjddjddjqS)zSource0: %{name}-%{version}.tarz)Source0: %{name}-%{unmangled_version}.tarzsetup.py install z5setup.py install --single-version-externally-managed z%setupz&%setup -n %{name}-%{unmangled_version})replace).0line)line23line24rr s z-bdist_rpm._make_spec_file..z%define unmangled_version )Z distributionZ get_versionr rr_make_spec_fileindexinsert)rversionZ rpmversionspecZ insert_locZunmangled_versionr)r rrrs     zbdist_rpm._make_spec_fileN)__name__ __module__ __qualname____doc__rrrrrrrs r)Zdistutils.command.bdist_rpmZcommandrrrrrrs __pycache__/build_ext.cpython-36.pyc000064400000023363147210141470013371 0ustar003 K]u3@sddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZddlmZddlmZdd lmZyddlmZed Wnek reZYnXe d dd l mZd dZdZdZdZej dkrdZn>ej!dkr,yddl"Z"e#e"dZZWnek r*YnXddZ$ddZ%GdddeZes^ej!dkrjd!ddZ&ndZd"ddZ&dd Z'dS)#N) build_ext) copy_file) new_compiler)customize_compilerget_config_var)DistutilsError)log)Library)sixzCython.Compiler.MainLDSHARED) _config_varsc CsZtjdkrNtj}z$dtd<dtd<dtd<t|Wdtjtj|Xnt|dS)Ndarwinz0gcc -Wl,-x -dynamiclib -undefined dynamic_lookupr z -dynamiclibCCSHAREDz.dylibSO)sysplatform _CONFIG_VARScopyrclearupdate)compilerZtmpr/usr/lib/python3.6/build_ext.py_customize_compiler_for_shlibs  rFZsharedr TntRTLD_NOWcCs tr|SdS)N) have_rtld)srrr>srcCs>x8ddtjDD]"\}}}d|kr*|S|dkr|SqWdS)z;Return the file extension for an abi3-compliant Extension()css |]}|dtjkr|VqdS)N)impZ C_EXTENSION).0rrrr Csz"get_abi3_suffix..z.abi3z.pydN)r!Z get_suffixes)suffix_rrrget_abi3_suffixAs r&c@sveZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdddZdS)rcCs.|jd}|_tj|||_|r*|jdS)z;Build extensions in build directory, then copy if --inplacerN)Zinplace _build_extruncopy_extensions_to_source)selfZ old_inplacerrrr(Ks  z build_ext.runc Cs|jd}x|jD]}|j|j}|j|}|jd}dj|dd}|j|}tj j|tj j |}tj j|j |} t | ||j |jd|jr|j|ptj|dqWdS)Nbuild_py.)verbosedry_runT)get_finalized_command extensionsget_ext_fullnamenameget_ext_filenamesplitjoinZget_package_dirospathbasename build_librr.r/ _needs_stub write_stubcurdir) r*r+extfullnamefilenameZmodpathpackageZ package_dirZ dest_filenameZ src_filenamerrrr)Ss       z#build_ext.copy_extensions_to_sourcecCstj||}||jkr|j|}tjo4t|do4t}|r^td}|dt| }|t}t |t rt j j |\}}|jj|tStr|jrt j j|\}}t j j|d|S|S)NZpy_limited_api EXT_SUFFIXzdl-)r'r5ext_mapr ZPY3getattrr&_get_config_var_837len isinstancer r8r9splitextshlib_compilerlibrary_filenamelibtype use_stubs_links_to_dynamicr6r7)r*r@rAr?Zuse_abi3Zso_extfndrrrr5is"       zbuild_ext.get_ext_filenamecCs tj|d|_g|_i|_dS)N)r'initialize_optionsrJshlibsrD)r*rrrrQ~s zbuild_ext.initialize_optionscCs2tj||jpg|_|j|jdd|jD|_|jrB|jx|jD]}|j|j|_qJWx|jD]}|j}||j |<||j |j dd<|jr|j |pd}|ot ot |t }||_||_|j|}|_tjjtjj|j|}|o||jkr|jj||rht rhtj|jkrh|jjtjqhWdS)NcSsg|]}t|tr|qSr)rHr )r"r?rrr sz.build_ext.finalize_options..r,r-Fr0)r'finalize_optionsr2Zcheck_extensions_listrRsetup_shlib_compilerr3r4 _full_namerDr6links_to_dynamicrMrHr rNr<r5 _file_namer8r9dirnamer7r; library_dirsappendr>runtime_library_dirs)r*r?r@ZltdnsrAZlibdirrrrrTs,       zbuild_ext.finalize_optionscCst|j|j|jd}|_t||jdk r8|j|j|jdk rbx|jD]\}}|j ||qJW|j dk rx|j D]}|j |qtW|j dk r|j |j |jdk r|j|j|jdk r|j|j|jdk r|j|jtj||_dS)N)rr/force)rrr/r^rJrZ include_dirsZset_include_dirsZdefineZ define_macroZundefZundefine_macro librariesZ set_librariesrZZset_library_dirsZrpathZset_runtime_library_dirsZ link_objectsZset_link_objectslink_shared_object__get__)r*rr4valueZmacrorrrrUs(             zbuild_ext.setup_shlib_compilercCst|tr|jStj||S)N)rHr export_symbolsr'get_export_symbols)r*r?rrrrds zbuild_ext.get_export_symbolsc Cs\|j|j}z@t|tr"|j|_tj|||jrL|jdj }|j ||Wd||_XdS)Nr+) Z_convert_pyx_sources_to_langrrHr rJr'build_extensionr<r1r;r=)r*r?Z _compilercmdrrrres   zbuild_ext.build_extensioncsPtjdd|jDdj|jjddd dgtfdd|jDS) z?Return true if 'ext' links to a dynamic lib in the same packagecSsg|] }|jqSr)rV)r"librrrrSsz.build_ext.links_to_dynamic..r,Nr-rc3s|]}|kVqdS)Nr)r"Zlibname)libnamespkgrrr#sz-build_ext.links_to_dynamic..r0)dictfromkeysrRr7rVr6anyr_)r*r?r)rhrirrWs zbuild_ext.links_to_dynamiccCstj||jS)N)r' get_outputs_build_ext__get_stubs_outputs)r*rrrrmszbuild_ext.get_outputscs6fddjD}tj|j}tdd|DS)Nc3s0|](}|jrtjjjf|jjdVqdS)r,N)r<r8r9r7r;rVr6)r"r?)r*rrr#sz0build_ext.__get_stubs_outputs..css|]\}}||VqdS)Nr)r"baseZfnextrrrr#s)r2 itertoolsproduct!_build_ext__get_output_extensionslist)r*Z ns_ext_basesZpairsr)r*rZ__get_stubs_outputss  zbuild_ext.__get_stubs_outputsccs"dVdV|jdjrdVdS)Nz.pyz.pycr+z.pyo)r1optimize)r*rrrZ__get_output_extensionss z!build_ext.__get_output_extensionsFcCs.tjd|j|tjj|f|jjdd}|rJtjj|rJt|d|j st |d}|j djddd t d d tjj |jd d dt ddddt dddt ddddg|j|r*ddlm}||gdd|j d|jdj}|dkr||g|d|j dtjj|r*|j r*tj|dS)Nz writing stub loader for %s to %sr,z.pyz already exists! Please delete.w zdef __bootstrap__():z- global __bootstrap__, __file__, __loader__z% import sys, os, pkg_resources, impz, dlz: __file__ = pkg_resources.resource_filename(__name__,%r)z del __bootstrap__z if '__loader__' in globals():z del __loader__z# old_flags = sys.getdlopenflags()z old_dir = os.getcwd()z try:z( os.chdir(os.path.dirname(__file__))z$ sys.setdlopenflags(dl.RTLD_NOW)z( imp.load_dynamic(__name__,__file__)z finally:z" sys.setdlopenflags(old_flags)z os.chdir(old_dir)z__bootstrap__()rr) byte_compileT)rtr^r/Z install_lib)rinforVr8r9r7r6existsrr/openwriteif_dlr:rXcloseZdistutils.utilrwr1rtunlink)r* output_dirr?compileZ stub_filefrwrtrrrr=sP          zbuild_ext.write_stubN)F)__name__ __module__ __qualname__r(r)r5rQrTrUrdrerWrmrnrrr=rrrrrJs   rc Cs(|j|j||||||||| | | | dS)N)linkZSHARED_LIBRARY) r*objectsoutput_libnamerr_rZr\rcdebug extra_preargsextra_postargs build_temp target_langrrrr`s r`Zstaticc Cs^|dks ttjj|\}} tjj| \}}|jdjdrH|dd}|j||||| dS)Nxrg)AssertionErrorr8r9r6rIrK startswithZcreate_static_lib)r*rrrr_rZr\rcrrrrrrAr:r?rrrr`,s  cCstjdkrd}t|S)z In https://github.com/pypa/setuptools/pull/837, we discovered Python 3.3.0 exposes the extension suffix under the name 'SO'. rr-r)rrr-)r version_infor)r4rrrrFDs rF) NNNNNrNNNN) NNNNNrNNNN)(r8rrpr!Zdistutils.command.build_extrZ _du_build_extZdistutils.file_utilrZdistutils.ccompilerrZdistutils.sysconfigrrZdistutils.errorsrZ distutilsrZsetuptools.extensionr Zsetuptools.externr ZCython.Distutils.build_extr' __import__ ImportErrorr rrrrMrLrr4Zdlhasattrr|r&r`rFrrrrsZ              Q  __pycache__/sdist.cpython-36.pyc000064400000014250147210141470012533 0ustar003 K]7@s~ddlmZddljjZddlZddlZddlZddl Z ddl m Z ddl m Z ddlZeZd ddZGd d d e ejZdS) )logN)six)sdist_add_defaultsccs4x.tjdD] }x|j|D] }|VqWq WdS)z%Find all files under revision controlzsetuptools.file_findersN) pkg_resourcesZiter_entry_pointsload)dirnameZepitemr /usr/lib/python3.6/sdist.py walk_revctrlsr cseZdZdZd0d2d3gZiZd d ddgZeddeDZddZ ddZ ddZ ddZ e ejddZddZejd4kpd5ejkod6knpd7ejkod8knZereZd$d%Zfd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZZS)9sdistz=Smart sdist that finds anything supported by revision controlformats=N6formats for source distribution (comma-separated list) keep-tempkz1keep the distribution tree around after creating zarchive file(s) dist-dir=dFdirectory to put the source distribution archive(s) in [default: dist]rz.rstz.txtz.mdccs|]}dj|VqdS)z README{0}N)format).0Zextr r r )szsdist.cCs|jd|jd}|j|_|jjtjj|jd|jx|j D]}|j|qFW|j t |j dg}x*|j D] }dd|f}||krv|j|qvWdS)Negg_infoz SOURCES.txt dist_filesrr)Z run_commandget_finalized_commandfilelistappendospathjoinr check_readmeZget_sub_commandsmake_distributiongetattr distributionZ archive_files)selfZei_cmdZcmd_namerfiledatar r r run+s    z sdist.runcCstjj||jdS)N)origrinitialize_options_default_to_gztar)r%r r r r*>s zsdist.initialize_optionscCstjdkrdSdg|_dS)NrbetarZgztar)r,r-rr.r)sys version_infoZformats)r%r r r r+Cs zsdist._default_to_gztarc Cs$|jtjj|WdQRXdS)z% Workaround for #516 N)_remove_os_linkr)rr")r%r r r r"Is zsdist.make_distributionccs^Gddd}ttd|}yt`Wntk r6YnXz dVWd||k rXttd|XdS)zG In a context, remove and restore os.link if it exists c@s eZdZdS)z&sdist._remove_os_link..NoValueN)__name__ __module__ __qualname__r r r r NoValueWsr5linkN)r#rr6 Exceptionsetattr)r5Zorig_valr r r r1Ps  zsdist._remove_os_linkc CsLytjj|Wn6tk rFtj\}}}|jjjdj YnXdS)Ntemplate) r)r read_templater7r/exc_infotb_nexttb_framef_localsclose)r%_tbr r r Z__read_template_hackes zsdist.__read_template_hackr,rrcsb|jjr^|jd}|jj|j|jjs^x0|jD]&\}}}|jjfdd|Dq4WdS)zgetting python filesbuild_pycsg|]}tjj|qSr )rrr )rfilename)src_dirr r sz.sdist._add_defaults_python..N)r$Zhas_pure_modulesrrextendZget_source_filesZinclude_package_dataZ data_files)r%rEr@ filenamesr )rGr _add_defaults_python|s  zsdist._add_defaults_pythonc sDy tjrtj|n tjWntk r>tjdYnXdS)Nz&data_files contains unexpected objects)rZPY2r_add_defaults_data_filessuper TypeErrorrwarn)r%) __class__r r rLs  zsdist._add_defaults_data_filescCs:x4|jD]}tjj|rdSqW|jddj|jdS)Nz,standard file not found: should have one of z, )READMESrrexistsrOr )r%fr r r r!s   zsdist.check_readmecCs^tjj|||tjj|d}ttdrJtjj|rJtj||j d||j dj |dS)Nz setup.cfgr6r) r)rmake_release_treerrr hasattrrRunlinkZ copy_filerZsave_version_info)r%Zbase_dirfilesdestr r r rTs   zsdist.make_release_treec Cs@tjj|jsdStj|jd}|j}WdQRX|djkS)NFrbz+# file GENERATED by distutils, do NOT edit )rrisfilemanifestioopenreadlineencode)r%fpZ first_liner r r _manifest_is_not_generateds z sdist._manifest_is_not_generatedc Cstjd|jt|jd}xl|D]d}tjr^y|jd}Wn$tk r\tjd|w YnX|j }|j ds | rxq |j j |q W|j dS)zRead the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source distribution. zreading manifest file '%s'rYzUTF-8z"%r not UTF-8 decodable -- skipping#N)rinfor[r]rZPY3decodeUnicodeDecodeErrorrOstrip startswithrrr?)r%r[liner r r read_manifests  zsdist.read_manifest)rNr@keep the distribution tree around after creating archive file(s))rrrj)rrr)rBrCrB)r,r)r,rrD)r,rB)r,rBr)r2r3r4__doc__Z user_optionsZ negative_optZREADME_EXTENSIONStuplerQr(r*r+r" staticmethod contextlibcontextmanagerr1Z_sdist__read_template_hackr/r0Zhas_leaky_handler:rKrLr!rTrari __classcell__r r )rPr rs:      r)r)Z distutilsrZdistutils.command.sdistZcommandrr)rr/r\rnZsetuptools.externrZ py36compatrrlistZ_default_revctrlr r r r r s     __pycache__/sdist.cpython-36.opt-1.pyc000064400000014250147210141470013472 0ustar003 K]7@s~ddlmZddljjZddlZddlZddlZddl Z ddl m Z ddl m Z ddlZeZd ddZGd d d e ejZdS) )logN)six)sdist_add_defaultsccs4x.tjdD] }x|j|D] }|VqWq WdS)z%Find all files under revision controlzsetuptools.file_findersN) pkg_resourcesZiter_entry_pointsload)dirnameZepitemr /usr/lib/python3.6/sdist.py walk_revctrlsr cseZdZdZd0d2d3gZiZd d ddgZeddeDZddZ ddZ ddZ ddZ e ejddZddZejd4kpd5ejkod6knpd7ejkod8knZereZd$d%Zfd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZZS)9sdistz=Smart sdist that finds anything supported by revision controlformats=N6formats for source distribution (comma-separated list) keep-tempkz1keep the distribution tree around after creating zarchive file(s) dist-dir=dFdirectory to put the source distribution archive(s) in [default: dist]rz.rstz.txtz.mdccs|]}dj|VqdS)z README{0}N)format).0Zextr r r )szsdist.cCs|jd|jd}|j|_|jjtjj|jd|jx|j D]}|j|qFW|j t |j dg}x*|j D] }dd|f}||krv|j|qvWdS)Negg_infoz SOURCES.txt dist_filesrr)Z run_commandget_finalized_commandfilelistappendospathjoinr check_readmeZget_sub_commandsmake_distributiongetattr distributionZ archive_files)selfZei_cmdZcmd_namerfiledatar r r run+s    z sdist.runcCstjj||jdS)N)origrinitialize_options_default_to_gztar)r%r r r r*>s zsdist.initialize_optionscCstjdkrdSdg|_dS)NrbetarZgztar)r,r-rr.r)sys version_infoZformats)r%r r r r+Cs zsdist._default_to_gztarc Cs$|jtjj|WdQRXdS)z% Workaround for #516 N)_remove_os_linkr)rr")r%r r r r"Is zsdist.make_distributionccs^Gddd}ttd|}yt`Wntk r6YnXz dVWd||k rXttd|XdS)zG In a context, remove and restore os.link if it exists c@s eZdZdS)z&sdist._remove_os_link..NoValueN)__name__ __module__ __qualname__r r r r NoValueWsr5linkN)r#rr6 Exceptionsetattr)r5Zorig_valr r r r1Ps  zsdist._remove_os_linkc CsLytjj|Wn6tk rFtj\}}}|jjjdj YnXdS)Ntemplate) r)r read_templater7r/exc_infotb_nexttb_framef_localsclose)r%_tbr r r Z__read_template_hackes zsdist.__read_template_hackr,rrcsb|jjr^|jd}|jj|j|jjs^x0|jD]&\}}}|jjfdd|Dq4WdS)zgetting python filesbuild_pycsg|]}tjj|qSr )rrr )rfilename)src_dirr r sz.sdist._add_defaults_python..N)r$Zhas_pure_modulesrrextendZget_source_filesZinclude_package_dataZ data_files)r%rEr@ filenamesr )rGr _add_defaults_python|s  zsdist._add_defaults_pythonc sDy tjrtj|n tjWntk r>tjdYnXdS)Nz&data_files contains unexpected objects)rZPY2r_add_defaults_data_filessuper TypeErrorrwarn)r%) __class__r r rLs  zsdist._add_defaults_data_filescCs:x4|jD]}tjj|rdSqW|jddj|jdS)Nz,standard file not found: should have one of z, )READMESrrexistsrOr )r%fr r r r!s   zsdist.check_readmecCs^tjj|||tjj|d}ttdrJtjj|rJtj||j d||j dj |dS)Nz setup.cfgr6r) r)rmake_release_treerrr hasattrrRunlinkZ copy_filerZsave_version_info)r%Zbase_dirfilesdestr r r rTs   zsdist.make_release_treec Cs@tjj|jsdStj|jd}|j}WdQRX|djkS)NFrbz+# file GENERATED by distutils, do NOT edit )rrisfilemanifestioopenreadlineencode)r%fpZ first_liner r r _manifest_is_not_generateds z sdist._manifest_is_not_generatedc Cstjd|jt|jd}xl|D]d}tjr^y|jd}Wn$tk r\tjd|w YnX|j }|j ds | rxq |j j |q W|j dS)zRead the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source distribution. zreading manifest file '%s'rYzUTF-8z"%r not UTF-8 decodable -- skipping#N)rinfor[r]rZPY3decodeUnicodeDecodeErrorrOstrip startswithrrr?)r%r[liner r r read_manifests  zsdist.read_manifest)rNr@keep the distribution tree around after creating archive file(s))rrrj)rrr)rBrCrB)r,r)r,rrD)r,rB)r,rBr)r2r3r4__doc__Z user_optionsZ negative_optZREADME_EXTENSIONStuplerQr(r*r+r" staticmethod contextlibcontextmanagerr1Z_sdist__read_template_hackr/r0Zhas_leaky_handler:rKrLr!rTrari __classcell__r r )rPr rs:      r)r)Z distutilsrZdistutils.command.sdistZcommandrr)rr/r\rnZsetuptools.externrZ py36compatrrlistZ_default_revctrlr r r r r s     __pycache__/test.cpython-36.pyc000064400000017625147210141470012375 0ustar003 K]#@sddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z ddlmZmZddlmZmZmZmZmZmZmZmZmZddlmZGd d d e ZGd d d eZGd ddeZ dS)N)DistutilsErrorDistutilsOptionError)log) TestLoader)six)mapfilter) resource_listdirresource_existsnormalize_path working_set_namespace_packagesevaluate_markeradd_activation_listenerrequire EntryPoint)Commandc@seZdZddZdddZdS)ScanningLoadercCstj|t|_dS)N)r__init__set_visited)selfr/usr/lib/python3.6/test.pyrs zScanningLoader.__init__NcCs||jkrdS|jj|g}|jtj||t|drH|j|jt|drxpt|jdD]`}|j dr|dkr|jd|dd }n"t |j|d r`|jd|}nq`|j|j |q`Wt |d kr|j |S|d SdS) aReturn a suite of all tests cases contained in the given module If the module is a package, load tests from all the modules in it. If the module has an ``additional_tests`` function, call it and add the return value to the tests. Nadditional_tests__path__z.pyz __init__.py.z /__init__.pyr)raddappendrloadTestsFromModulehasattrrr __name__endswithr ZloadTestsFromNamelenZ suiteClass)rmodulepatternZtestsfileZ submodulerrrr#s$      z"ScanningLoader.loadTestsFromModule)N)r% __module__ __qualname__rr#rrrrrsrc@seZdZddZdddZdS)NonDataPropertycCs ||_dS)N)fget)rr.rrrr>szNonDataProperty.__init__NcCs|dkr |S|j|S)N)r.)robjZobjtyperrr__get__AszNonDataProperty.__get__)N)r%r+r,rr0rrrrr-=sr-c@seZdZdZdZd%d&d'gZd d ZddZeddZ ddZ ddZ e j gfddZee j ddZeddZddZddZed d!Zed"d#Zd$S)(testz.Command to run unit tests after in-place buildz#run unit tests after in-place build test-module=m$Run 'test_suite' in specified module test-suite=s9Run single test, case or suite (e.g. 'module.test_suite') test-runner=rTest runner to usecCsd|_d|_d|_d|_dS)N) test_suite test_module test_loader test_runner)rrrrinitialize_optionsSsztest.initialize_optionscCs|jr|jrd}t||jdkrD|jdkr8|jj|_n |jd|_|jdkr^t|jdd|_|jdkrnd|_|jdkrt|jdd|_dS)Nz1You may specify a module or a suite, but not bothz .test_suiter=z&setuptools.command.test:ScanningLoaderr>)r;r<r distributionr=getattrr>)rmsgrrrfinalize_optionsYs        ztest.finalize_optionscCs t|jS)N)list _test_args)rrrr test_argslsztest.test_argsccs6|j rtjdkrdV|jr$dV|jr2|jVdS)NZdiscoverz --verbose)rGrH)r;sys version_infoverbose)rrrrrEps ztest._test_argsc Cs|j |WdQRXdS)zI Backward compatibility for project_on_sys_path context. N)project_on_sys_path)rfuncrrrwith_project_on_sys_pathxs ztest.with_project_on_sys_pathc csPtjot|jdd}|rv|jddd|jd|jd}t|j}|jd|d|jd|jddd|jdn"|jd|jdd d|jd|jd}t j dd}t j j }zbt|j }t j jd|tjtd d td |j|jf|j|g dVWdQRXWd|t j dd<t j jt j j|tjXdS) Nuse_2to3FZbuild_pyr)ZinplaceZegg_info)egg_baseZ build_extrcSs|jS)N)Zactivate)distrrrsz*test.project_on_sys_path..z%s==%s)rPY3rAr@Zreinitialize_commandZ run_commandZget_finalized_commandr Z build_librIpathmodulescopyrPinsertr rrrZegg_nameZ egg_versionpaths_on_pythonpathclearupdate) rZ include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdZold_pathZ old_modulesZ project_pathrrrrLs8             ztest.project_on_sys_pathc cst}tjjd|}tjjdd}z>tjj|}td||g}tjj|}|rX|tjd<dVWd||krztjjddn |tjd<XdS)z Add the indicated paths to the head of the PYTHONPATH environment variable so that subprocesses will also see the packages at these paths. Do this in a context that restores the value on exit. PYTHONPATHrN)objectosenvirongetpathsepjoinrpop)pathsZnothingZorig_pythonpathZcurrent_pythonpathprefixZto_joinnew_pathrrrrXs     ztest.paths_on_pythonpathcCsD|j|j}|j|jpg}|jdd|jjD}tj|||S)z Install the requirements indicated by self.distribution and return an iterable of the dists that were built. css0|](\}}|jdrt|ddr|VqdS):rN) startswithr).0kvrrr sz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rQZir_dZtr_dZer_drrr install_distss  ztest.install_distscCs|j|j}dj|j}|jr0|jd|dS|jd|ttjd|}|j |"|j |j WdQRXWdQRXdS)N zskipping "%s" (dry run)z running "%s"location) ror@ra_argvZdry_runannounceroperator attrgetterrXrL run_tests)rZinstalled_distscmdrcrrrruns    ztest.runcCstjrt|jddr|jjdd}|tkrg}|tjkrD|j ||d7}x"tjD]}|j |rT|j |qTWt t tjj |tjdd|j|j|j|j|jdd}|jjsd|j}|j|tjt|dS)NrOFrr)Z testLoaderZ testRunnerexitzTest failed: %s)rrSrAr@r;splitr rIrUr"rgrDr __delitem__unittestmainrr_resolve_as_epr=r>resultZ wasSuccessfulrsrZERRORr)rr(Z del_modulesnamer1rBrrrrvs(        ztest.run_testscCs dg|jS)Nr|)rF)rrrrrrsz test._argvcCs$|dkr dStjd|}|jS)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)rparseZresolve)valZparsedrrrr~sztest._resolve_as_epN)r2r3r4)r5r6r7)r8r9r:)r%r+r,__doc__ descriptionZ user_optionsr?rCr-rFrErN contextlibcontextmanagerrL staticmethodrXrorxrvpropertyrrr~rrrrr1Gs( -  r1)!r]rtrIrrmr|Zdistutils.errorsrrZ distutilsrrZsetuptools.externrZsetuptools.extern.six.movesrrZ pkg_resourcesr r r r r rrrrZ setuptoolsrrr\r-r1rrrrs   , ) __pycache__/install_egg_info.cpython-36.pyc000064400000004472147210141470014715 0ustar003 K]@s\ddlmZmZddlZddlmZddlmZddlmZddl Z Gdddej eZ dS))logdir_utilN)Command) namespaces)unpack_archivec@sBeZdZdZdZdgZddZddZd d Zd d Z d dZ dS)install_egg_infoz.Install an .egg-info directory for the package install-dir=ddirectory to install tocCs d|_dS)N) install_dir)selfr &/usr/lib/python3.6/install_egg_info.pyinitialize_optionssz#install_egg_info.initialize_optionscCsV|jdd|jd}tjdd|j|jjd}|j|_tj j |j ||_ g|_ dS)NZ install_libr egg_infoz .egg-info)r r )Zset_undefined_optionsZget_finalized_command pkg_resourcesZ DistributionZegg_nameZ egg_versionrsourceospathjoinr targetoutputs)r Zei_cmdbasenamer r rfinalize_optionss z!install_egg_info.finalize_optionscCs|jdtjj|jr.skimmer)rrr)r r+r )r rr1s zinstall_egg_info.copytreeN)rr r ) __name__ __module__ __qualname____doc__ descriptionZ user_optionsrrr r!rr r r rr s  r) Z distutilsrrrZ setuptoolsrrZsetuptools.archive_utilrrZ Installerrr r r rs    __pycache__/easy_install.cpython-36.opt-1.pyc000064400000176606147210141470015051 0ustar003 K]T @sdZddlmZddlmZddlmZmZddlmZmZm Z m Z ddl m Z m Z ddlmZmZddlmZdd lmZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd l Z dd l!Z!dd l"Z"dd l#Z#dd l$Z$dd l%Z%dd l&m'Z'dd l(m)Z)m*Z*dd l+m,Z,ddl-m.Z.ddl/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:m;Z;ddl4mm?Z?ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOdd lPZ@ejQde@jRdddddddgZSdd ZTd!dZUe'jVr2d"d#ZWd$d%ZXnd&d#ZWd'd%ZXd(d)ZYGd*dde,ZZd+d,Z[d-d.Z\d/d0Z]d1dZ^d2dZ_Gd3ddeGZ`Gd4d5d5e`Zaejbjcd6d7d8kreaZ`d9d:Zdd;d<Zed=d>Zfd?d@ZgdpdAdBZhdCdDZidEdFZjdGejkkrejZlndHdIZldqdKdLZmdMdNZndOdPZodQdRZpyddSlmqZrWnesk r^dTdUZrYnXdVdWZqGdXdYdYetZueujvZwGdZd[d[euZxGd\d]d]eyZzGd^d_d_ezZ{Gd`dadae{Z|ezj}Z}ezj~Z~dbdcZdddeZdfeefdgdhZdidjZdkdlZdrdmdZe"jdndoZd S)sa% Easy Install ------------ A tool for doing automatic download/extract/build of distutils-based Python packages. For detailed documentation, see the accompanying EasyInstall.txt file, or visit the `EasyInstall home page`__. __ https://setuptools.readthedocs.io/en/latest/easy_install.html )glob) get_platform) convert_path subst_vars)DistutilsArgErrorDistutilsOptionErrorDistutilsErrorDistutilsPlatformError)INSTALL_SCHEMES SCHEME_KEYS)logdir_util) first_line_re)find_executableN)six) configparsermap)Command) run_setup)get_pathget_config_vars) rmtree_safe)setopt)unpack_archive) PackageIndexparse_requirement_arg URL_SCHEME) bdist_eggegg_info)Wheel) yield_linesnormalize_pathresource_stringensure_directoryget_distributionfind_distributions Environment Requirement Distribution PathMetadata EggMetadata WorkingSetDistributionNotFoundVersionConflict DEVELOP_DISTdefault)categorysamefile easy_installPthDistributionsextract_wininst_cfgmainget_exe_prefixescCstjddkS)NP)structcalcsizer;r;"/usr/lib/python3.6/easy_install.pyis_64bitIsr=cCsjtjj|otjj|}ttjdo&|}|r:tjj||Stjjtjj|}tjjtjj|}||kS)z Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. r1)ospathexistshasattrr1normpathnormcase)Zp1Zp2Z both_existZ use_samefileZnorm_p1Znorm_p2r;r;r<r1MscCs|S)Nr;)sr;r;r< _to_ascii_srEc Cs*ytj|ddStk r$dSXdS)NasciiTF)rZ text_type UnicodeError)rDr;r;r<isasciibs  rHcCs |jdS)NrF)encode)rDr;r;r<rEjsc Cs(y|jddStk r"dSXdS)NrFTF)rIrG)rDr;r;r<rHms  cCstj|jjddS)N z; )textwrapdedentstripreplace)textr;r;r<usrPc@seZdZdZdZdZdddddddddddddddddddddgZdd dd dd0d3d9ddddZ?ejdj Z@ddZAddZBddZCddZDddZEddZFddZGddZHejdj ZIddZJddZKddZLeMeMddddZNeMdddZOddZPdS)r2z'Manage a download/build/install processz Find/get/install Python packagesTprefix=Ninstallation prefixzip-okzinstall package as a zipfile multi-versionm%make apps have to require() a versionupgradeU1force upgrade (searches PyPI for latest versions) install-dir=dinstall package to DIR script-dir=rDinstall scripts to DIRexclude-scriptsxDon't install scripts always-copya'Copy all needed packages to install dir index-url=i base URL of Python Package Index find-links=f(additional URL(s) to search for packagesbuild-directory=b/download/extract/build in DIR; keep the results optimize=Olalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]record=3filename in which to record list of installed files always-unzipZ*don't install as a zipfile, no matter what site-dirs=S)list of directories where .pth files workeditablee+Install specified packages in editable formno-depsNdon't install dependencies allow-hosts=H$pattern(s) that hostnames must matchlocal-snapshots-okl(allow building eggs from local checkoutsversion"print version information and exit no-find-links9Don't load find-links defined in packages being installedz!install in user site-package '%s'usercCs,d|_d|_|_d|_|_|_d|_d|_d|_d|_ d|_ |_ d|_ |_ |_d|_|_|_d|_|_|_d|_d|_d|_d|_d|_d|_d|_d|_d|_tjrtj |_!tj"|_#n d|_!d|_#d|_$d|_%d|_&|_'d|_(i|_)d|_*d|_+|j,j-|_-|j,j.||j,j/ddS)NrFr2)0rzip_oklocal_snapshots_ok install_dir script_direxclude_scripts index_url find_linksbuild_directoryargsoptimizerecordrY always_copy multi_versionr{no_deps allow_hostsrootprefix no_reportrinstall_purelibinstall_platlibinstall_headers install_libinstall_scripts install_data install_baseinstall_platbasesiteENABLE_USER_SITE USER_BASEinstall_userbase USER_SITEinstall_usersite no_find_links package_indexpth_filealways_copy_from site_dirsinstalled_projectssitepy_installedZ_dry_run distributionverboseZ_set_command_optionsget_option_dict)selfr;r;r<initialize_optionssF     zeasy_install.initialize_optionscCs"dd|D}tt|j|dS)Ncss*|]"}tjj|stjj|r|VqdS)N)r>r?r@islink).0filenamer;r;r< sz/easy_install.delete_blockers..)listr _delete_path)rblockersZextant_blockersr;r;r<delete_blockersszeasy_install.delete_blockerscCsJtjd||jrdStjj|o.tjj| }|r8tntj}||dS)Nz Deleting %s) r infodry_runr>r?isdirrrmtreeunlink)rr?Zis_treeZremoverr;r;r<rs  zeasy_install._delete_pathcCs6tjdd}td}d}t|jfttdS)zT Render the Setuptools version and installation details, then exit. N setuptoolsz=setuptools {dist.version} from {dist.location} (Python {ver}))sysrr$printformatlocals SystemExit)Zverdisttmplr;r;r<_render_versions zeasy_install._render_versionc Cst|jo |jtjjd}tdd\}}|jj|jj|jj||dd|d|d||||t tddd |_ t j r|j |j d <|j|j d <|j|j|j|jd d d d|jdkr|j|_|jdkrd|_|jdd!|jdd"|jr|jr|j|_|j|_|jdd#tttj}t|_|jdk rdd|jjdD}xV|D]N}t jj!|s~t"j#d|n,t||krt$|dn|jj%t|q^W|j&s|j'|j(pd|_(|jdd|_)x4|jt|jfD] }||j)kr|j)j*d|qW|j+dk r8dd|j+jdD}ndg}|j,dkr`|j-|j(|j)|d|_,t.|j)tj|_/|j0dk rt1|j0t2j3r|j0j|_0ng|_0|j4r|j,j5|j)tj|js|j,j6|j0|jdd$t1|j7t8s@y2t8|j7|_7d|j7kodknst9Wnt9k r>t$dYnX|j&rZ|j: rZt;d|j<sjt;d g|_=dS)%Nrr exec_prefixrabiflags) Z dist_nameZ dist_versionZ dist_fullname py_versionpy_version_shortpy_version_nodotZ sys_prefixrZsys_exec_prefixrruserbaseZusersiterrrrFrrinstallrcSsg|]}tjj|jqSr;)r>r? expanduserrM)rrDr;r;r< 3sz1easy_install.finalize_options..,z"%s (in --site-dirs) does not existz$ (in --site-dirs) is not on sys.pathzhttps://pypi.org/simple/cSsg|] }|jqSr;)rM)rrDr;r;r<rHs*)Z search_pathhostsrz--optimize must be 0, 1, or 2z9Must specify a build directory (-b) when using --editablez:No urls, filenames, or requirements specified (see --help))rr)rr)rr)rr)>rrrsplitrrZget_nameZ get_versionZ get_fullnamegetattr config_varsrrrr_fix_install_dir_for_user_siteexpand_basedirs expand_dirs_expandrrrZset_undefined_optionsrrrrr!r? get_site_dirs all_site_dirsrr>rr warnrappendr{check_site_dirr shadow_pathinsertrr create_indexr& local_indexr isinstancerZ string_typesrZscan_egg_linksadd_find_linksrint ValueErrorrrroutputs) rrrrrBrr]Z path_itemrr;r;r<finalize_optionss                zeasy_install.finalize_optionscCs`|j stj rdS|j|jdkr2d}t||j|_|_tj j ddd}|j |dS)z; Fix the install_dir if "--user" was used. Nz$User base directory is not specifiedposixZunixZ_user) rrrcreate_home_pathrr rrr>namerN select_scheme)rmsgZ scheme_namer;r;r<rms z+easy_install._fix_install_dir_for_user_sitecCs\xV|D]N}t||}|dk rtjdks0tjdkrrr?rrrsetattr)rattrsattrvalr;r;r< _expand_attrs|s    zeasy_install._expand_attrscCs|jdddgdS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.rrrN)r)rr;r;r<rszeasy_install.expand_basedirscCsddddddg}|j|dS)z+Calls `os.path.expanduser` on install dirs.rrrrrrN)r)rdirsr;r;r<rszeasy_install.expand_dirsc Cs|j|jjkrtj|jzx|jD]}|j||j q$W|jr|j}|j rt |j }x(t t |D]}|||d||<qfWddl m }|j|j|j|fd|j|jWdtj|jjXdS)Nr) file_utilz'writing list of installed files to '%s')rrr set_verbosityrr2rrrrlenrange distutilsrexecuteZ write_filewarn_deprecated_options)rspecrZroot_lenZcounterrr;r;r<runs$       zeasy_install.runc CsDy tj}Wn"tk r.tjdtj}YnXtjj|j d|S)zReturn a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo. rztest-easy-install-%s) r>getpid ExceptionrandomZrandintrmaxsizer?joinr)rpidr;r;r<pseudo_tempnames  zeasy_install.pseudo_tempnamecCsdS)Nr;)rr;r;r<rsz$easy_install.warn_deprecated_optionscCsdt|j}tjj|d}tjj|sTytj|Wn ttfk rR|j YnX||j k}| rv|j rv|j }nd|j d}tjj|}y*|rtj|t|djtj|Wn ttfk r|j YnX| r|j rt|j|r|jdkrt||j |_nd|_|tttkr6d|_n$|j rZtjj| rZd|_d|_||_dS)z;Verify that self.install_dir is .pth-capable dir, if neededzeasy-install.pthz .write-testwNT)r!rr>r?r r@makedirsOSErrorIOErrorcant_write_to_targetrrcheck_pth_processingrropencloserno_default_version_msgrr3r _pythonpathr)rinstdirrZ is_site_dirZtestfileZ test_existsr;r;r<rs>         zeasy_install.check_site_diraS can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: %s The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s z This directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install-dir option). a Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://setuptools.readthedocs.io/en/latest/easy_install.html Please make the appropriate changes for your system and try again. cCsP|jtjd|jf}tjj|js6|d|j7}n|d|j7}t |dS)NrJ) _easy_install__cant_write_msgrexc_inforr>r?r@_easy_install__not_exists_id_easy_install__access_msgr)rrr;r;r<rs z!easy_install.cant_write_to_targetc Cs|j}tjd||jd}|d}tjj|}tdd}y8|rNtj|tjj |}t j j |ddt |d}Wn ttfk r|jYnXz|j|jft|jd }tj}tjd krtjj|\}} tjj|d } | jd kotjj| } | r| }d dlm} | |dddgd tjj|rJtjd|dSWd |r\|jtjj|rttj|tjj|rtj|X|jstjd|dS)z@Empirically verify whether .pth files are supported in inst. dirz Checking .pth file support in %sz.pthz.okzz import os f = open({ok_file!r}, 'w') f.write('OK') f.close() rJT)exist_okrNrz pythonw.exez python.exer)spawnz-Ez-cpassz-TEST PASSED: %s appears to support .pth filesz+TEST FAILED: %s does NOT support .pth filesF)rr rrr>r?r@ _one_linerrdirname pkg_resourcesZ py31compatrrrrrwriterrrr executablerrr lowerdistutils.spawnr rr) rrrZok_fileZ ok_existsrr#rkr&basenameZaltZuse_altr r;r;r<rsV            z!easy_install.check_pth_processingcCs\|j rN|jdrNx:|jdD],}|jd|r2q|j|||jd|qW|j|dS)z=Write all the scripts for `dist`, unless scripts are excludedscriptszscripts/N)rZmetadata_isdirZmetadata_listdirinstall_scriptZ get_metadatainstall_wrapper_scripts)rr script_namer;r;r<install_egg_scriptsSsz easy_install.install_egg_scriptscCs\tjj|rLxJtj|D].\}}}x"|D]}|jjtjj||q(WqWn |jj|dS)N)r>r?rwalkrrr )rr?baserfilesrr;r;r< add_outputas    zeasy_install.add_outputcCs|jrtd|fdS)NzjInvalid argument %r: you can't use filenames or URLs with --editable (except via the --find-links option).)r{r)rrr;r;r< not_editableiszeasy_install.not_editablecCs<|js dStjjtjj|j|jr8td|j|jfdS)Nz2%r already exists in %s; can't do a checkout there)r{r>r?r@r rkeyr)rrr;r;r<check_editableqs zeasy_install.check_editablec cs@tjtjdd}zt|VWdtjj|o8tt |XdS)Nz easy_install-)r) tempfilemkdtemprustrr>r?r@rr)rtmpdirr;r;r<_tmpdir{szeasy_install._tmpdirFcCs|js|j|j}t|tst|rT|j||jj||}|j d|||dSt j j |r||j||j d|||dSt |}|j||jj|||j|j|j |j}|dkrd|}|jr|d7}t|n0|jtkr|j|||d|S|j ||j||SWdQRXdS)NTz+Could not find suitable distribution for %rz2 (--always-copy skips system and development eggs)Using)r{install_site_pyr;rr'rr3rdownload install_itemr>r?r@rr5Zfetch_distributionrYrrrZ precedencer.process_distributionlocation)rrdepsr:dlrrr;r;r<r2s2         zeasy_install.easy_installcCs|p|j}|ptjj||k}|p,|jd }|pT|jdk oTtjjt|t|jk}|r| rx$|j|jD]}|j |krnPqnWd}t j dtjj ||r|j |||}x<|D]}|j|||qWn |j|g}|j||d|d|dk rx|D]}||kr|SqWdS)Nz.eggTz Processing %srr<)rr>r?r#endswithrr!r project_namerAr rr) install_eggsr@egg_distribution)rrr>r:rBZinstall_neededrZdistsr;r;r<r?s.         zeasy_install.install_itemcCs@t|}x2tD]*}d|}t||dkrt||||qWdS)z=Sets the install directories by applying the install schemes.Zinstall_N)r r rr)rrschemer4Zattrnamer;r;r<rs  zeasy_install.select_schemecGs|j||jj|||j|jkr2|jj||jj||j|||j|j<tj |j ||f||j dr|j r|jj |jd| r|j rdS|dk r|j|jkrtjd|dS|dks||kr|j}tt|}tj d|ytgj|g|j|j}Wn^tk rB}ztt|WYdd}~Xn0tk rp}zt|jWYdd}~XnX|js|jrx*|D]"}|j|jkr|j|jqWtj d|dS)Nzdependency_links.txtzSkipping dependencies for %szProcessing dependencies for %sz'Finished processing dependencies for %s) update_pthraddrr4remover.rr rinstallation_report has_metadatarrZget_metadata_linesrras_requirementr'r9r+Zresolver2r,rr-Zreportr)rZ requirementrrBrZdistreqZdistrosr|r;r;r<r@sB            z!easy_install.process_distributioncCs2|jdk r|j S|jdr dS|jds.dSdS)Nz not-zip-safeTzzip-safeF)rrM)rrr;r;r< should_unzips   zeasy_install.should_unzipcCstjj|j|j}tjj|r:d}tj||j|j||Stjj|rL|}nRtjj ||krftj |tj |}t |dkrtjj||d}tjj|r|}t |tj|||S)Nz<%r already exists in %s; build directory %s will not be keptrr)r>r?r rr4r@r rrr#rlistdirrr#shutilmove)rr dist_filename setup_basedstrcontentsr;r;r< maybe_moves"       zeasy_install.maybe_movecCs0|jr dSx tjj|D]}|j|qWdS)N)r ScriptWriterbestget_args write_script)rrrr;r;r<r,sz$easy_install.install_wrapper_scriptscCsNt|j}t||}|r8|j|t}tj||}|j|t|ddS)z/Generate a legacy script wrapper and install itrnN) r9rNis_python_script_load_templaterrX get_headerr[rE)rrr- script_textdev_pathrZ is_scriptZbodyr;r;r<r+"s   zeasy_install.install_scriptcCs(d}|r|jdd}td|}|jdS)z There are a couple of template scripts in the package. This function loads one of them and prepares it for use. z script.tmplz.tmplz (dev).tmplrzutf-8)rNr"decode)r`rZ raw_bytesr;r;r<r],s   zeasy_install._load_templatetc sjfdd|Dtjd|jtjjj|}j|jrLdSt }t |tjj |rptj |t |d|}|j|WdQRXt|d|dS)z1Write an executable file to the scripts directorycsg|]}tjjj|qSr;)r>r?r r)rrb)rr;r<r>sz-easy_install.write_script..zInstalling %s script to %sNri)rr rrr>r?r r2r current_umaskr#r@rrr%chmod)rr-rVmodertargetmaskrkr;)rr<r[;s   zeasy_install.write_scriptcCs`|jjdr|j||gS|jjdr8|j||gS|jjdrT|j||gS|}tjj|r|jd rt|||j ntjj |rtjj |}|j |r|j r|dk r|j|||}tjj|d}tjj|s2ttjj|dd}|stdtjj |t|dkr*td tjj ||d }|jrPtj|j||gS|j||SdS) Nz.eggz.exez.whlz.pyzsetup.pyrz"Couldn't find a setup script in %srzMultiple setup scripts in %sr)r'rD install_egg install_exe install_wheelr>r?isfilerunpack_progressrabspath startswithrrWr r@rrrr{r rreport_editablebuild_and_install)rrrSr:rT setup_scriptZsetupsr;r;r<rFOs<   zeasy_install.install_eggscCs>tjj|r"t|tjj|d}nttj|}tj ||dS)NzEGG-INFO)metadata) r>r?rr)r r* zipimport zipimporterr(Z from_filename)regg_pathrrr;r;r<rG{s    zeasy_install.egg_distributionc Cstjj|jtjj|}tjj|}|js2t||j|}t ||s|tjj |rttjj | rtt j ||jdn"tjj|r|jtj|fd|yd}tjj |r|j|rtjd}}n tjd}}nL|j|r|j||jd}}n*d}|j|rtjd}}n tjd}}|j|||f|dtjj|tjj|ft||d Wn$tk rzt|dd YnX|j||j|S) N)rz Removing FZMovingZCopyingZ ExtractingTz %s to %s)fix_zipimporter_caches)r>r?r rr)rmrr#rGr1rrr remove_treer@rrrnrQrRZcopytreerOZmkpathunpack_and_compileZcopy2r#update_dist_cachesr r2)rrur: destinationrZnew_dist_is_zippedrkrWr;r;r<rhsT               zeasy_install.install_eggc sTt|}|dkrtd|td|jdd|jddtd}tjj||jd}||_ |d}tjj|d}tjj|d }t |t |||_ |j ||tjj|st|d } | jd x<|jdD].\} } | d kr| jd | jddj| fqW| jtjj|d|jfddtj|Dtj|||j|jd|j||S)Nz(%s is not a valid distutils Windows .exerrrr)rErplatformz.eggz.tmpzEGG-INFOzPKG-INFOrzMetadata-Version: 1.0 target_versionz%s: %s _-r*csg|]}tjj|dqS)r)r>r?r )rr)rr;r<rsz,easy_install.install_exe..)rr)r4rr(getrr>r?r egg_namerAr#r)Z _provider exe_to_eggr@rr%itemsrNtitlerrrXrZrZ make_zipfilerrrh) rrSr:cfgrruegg_tmpZ _egg_infoZpkg_infrkkvr;)rr<ris<      " zeasy_install.install_exec s>t|ggifdd}t||g}xtD]l}|jjdr>|jd}|d}tj|dd|d<tjj f|}j ||j |tj ||q>W|j tj tjj dtj|xbdD]Z} t| rtjj d| d } tjj| st| d } | jd j t| d | jqWd S)z;Extract a bdist_wininst to the directories an egg would usecs|j}xԈD]\}}|j|r||t|d}|jd}tjjf|}|j}|jdsl|jdrtj |d |d <dtjj |dd<j |n4|jdr|dkrdtjj |dd<j ||SqW|jdst j d |dS) N/z.pydz.dllrrz.pyzSCRIPTS/z.pthzWARNING: can't process %sr)r'rnrrr>r?r rDr strip_modulesplitextrr r)srcrUrDoldnewpartsrC)r native_libsprefixes to_compile top_levelr;r<processs$      z(easy_install.exe_to_egg..processz.pydrrz.pyzEGG-INFOrrz.txtrrJNrrr)rr)r6rr'rDrrrr>r?r rZ write_stub byte_compileZwrite_safety_flagZ analyze_eggrr@rr%r) rrSrrZstubsresrZresourceZpyfilerZtxtrkr;)rrrrrr<rs6           zeasy_install.exe_to_eggc Cst|}tjj|j|j}tjj|}|js6t|tjj |rbtjj | rbt j ||jdn"tjj |r|jtj|fd|z.|j|j|fdtjj|tjj|fWdt|ddX|j||j|S)N)rz Removing zInstalling %s to %sF)rv)rr>r?r rrrmrr#rrr rwr@rrZinstall_as_eggr)r#ryr2rG)rZ wheel_pathr:Zwheelrzr;r;r<rjs,     zeasy_install.install_wheela( Because this distribution was installed --multi-version, before you can import modules from this package in an application, you will need to 'import pkg_resources' and then use a 'require()' call similar to one of these examples, in order to select the desired version: pkg_resources.require("%(name)s") # latest installed version pkg_resources.require("%(name)s==%(version)s") # this exact version pkg_resources.require("%(name)s>=%(version)s") # this version or higher z Note also that the installation directory must be on sys.path at runtime for this to work. (e.g. by being the application's script directory, by being on PYTHONPATH, or by being added to sys.path by your code.) Installedc Cs`d}|jr@|j r@|d|j7}|jtttjkr@|d|j7}|j }|j }|j }d}|t S)z9Helpful installation message for display to package usersz %(what)s %(eggloc)s%(extras)srJr) rr_easy_install__mv_warningrrr!rr?_easy_install__id_warningrArErr) rZreqrZwhatrZegglocrrZextrasr;r;r<rLIsz easy_install.installation_reportaR Extracted editable version of %(spec)s to %(dirname)s If it uses setuptools in its setup script, you can activate it in "development" mode by going to that directory and running:: %(python)s setup.py develop See the setuptools documentation for the "develop" command for more info. cCs"tjj|}tj}d|jtS)NrJ)r>r?r#rr&_easy_install__editable_msgr)rrrqr#pythonr;r;r<robs zeasy_install.report_editablecCstjjdttjjdtt|}|jdkrNd|jd}|jdd|n|jdkrd|jdd|jrv|jdd t j d |t |ddd j |yt ||Wn6tk r}ztd |jdfWYdd}~XnXdS) Nzdistutils.command.bdist_eggzdistutils.command.egg_inforrrrr~z-qz-nz Running %s %s zSetup script exited with %s)rmodules setdefaultrrrrrrr rrr rrrr)rrqrTrrr;r;r<rgs      zeasy_install.run_setupc Csddg}tjdtjj|d}z|jtjj||j||j|||t|g}g}x2|D]*}x$||D]}|j|j |j |qlWq^W| r|j rt j d||St|t j|jXdS)Nrz --dist-dirz egg-dist-tmp-)rdirz+No eggs found in %s (setup script problem?))r6r7r>r?r#_set_fetcher_optionsrrr&rhrArr rrrr) rrqrTrZdist_dirZall_eggsZeggsr4rr;r;r<rp{s$   zeasy_install.build_and_installc Cst|jjdj}d }i}x2|jD]&\}}||kr4q"|d||jdd <q"Wt|d }tjj|d }t j ||d S)a When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well. r2rrrrrrr}r~)r2z setup.cfgN)rrrrrr) rrcopyrrNdictr>r?r rZ edit_config) rr0Zei_optsZfetch_directivesZ fetch_optionsr4rZsettingsZ cfg_filenamer;r;r<rs  z!easy_install._set_fetcher_optionscCs0|jdkrdSxX|j|jD]H}|js2|j|jkrtjd||jj||j|jkr|jj|jqW|js|j|jjkrtjd|n2tjd||jj ||j|jkr|jj |j|j s,|jj |jdkr,t jj|jd}t jj|rt j|t|d}|j|jj|jd|jdS)Nz&Removing %s from easy-install.pth filez4%s is already the active version in easy-install.pthz"Adding %s to easy-install.pth filerzsetuptools.pthwtrJ)rr4rrAr rrKrpathsrJrrsaver>r?r rrrrr% make_relativer)rrr]rrkr;r;r<rIs4           zeasy_install.update_pthcCstjd|||S)NzUnpacking %s to %s)r debug)rrrUr;r;r<rlszeasy_install.unpack_progresscshggfdd}t|||jjsdx.D]&}tj|tjdBd@}t||q:WdS)Ncs\|jdr"|jd r"j|n|jds6|jdr@j|j||j rX|pZdS)Nz.pyz EGG-INFO/z.dllz.so)rDrnrrlr)rrU)rto_chmodrr;r<pfs    z+easy_install.unpack_and_compile..pfimi)rrrr>statST_MODErd)rrurzrrkrer;)rrrr<rxs   zeasy_install.unpack_and_compilec Csjtjr dSddlm}z@tj|jd||dd|jd|jrT|||jd|jdWdtj|jXdS)Nr)rr)rforcer) rdont_write_bytecodedistutils.utilrr rrrr)rrrr;r;r<rs zeasy_install.byte_compilea bad install directory or PYTHONPATH You are attempting to install a package to a directory that is not on PYTHONPATH and which Python does not read ".pth" files from. The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s and your PYTHONPATH environment variable currently contains: %r Here are some of your options for correcting the problem: * You can choose a different installation directory, i.e., one that is on PYTHONPATH or supports .pth files * You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python and want to use the package(s) you are installing.) * You can set up the installation directory to support ".pth" files by using one of the approaches described here: https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again.cCs|j}||jtjjddfS)N PYTHONPATHr)_easy_install__no_default_msgrr>environr)rtemplater;r;r<rsz#easy_install.no_default_version_msgcCs|jr dStjj|jd}tdd}|jd}d}tjj|rtj d|jt j |}|j }WdQRX|j dstd |||krtjd ||jst|t j |d dd }|j|WdQRX|j|gd |_dS)z8Make sure there's a site.py in the target dir, if neededNzsite.pyrz site-patch.pyzutf-8rzChecking existing site.py in %sz def __boot():z;%s is not a setuptools-generated site.py; please remove it.z Creating %sr)encodingT)rr>r?r rr"rar@r riorreadrnrrrr#r%r)rZsitepysourceZcurrentZstrmr;r;r<r=s,       zeasy_install.install_site_pycCsj|js dSttjjd}xJtj|jD]:\}}|j|r(tjj | r(|j d|tj |dq(WdS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) rrr>r?rrZ iteritemsrrnrZ debug_printr)rhomerr?r;r;r<r>szeasy_install.create_home_pathz/$base/lib/python$py_version_short/site-packagesz $base/bin)rr)rz$base/Lib/site-packagesz $base/ScriptscGs|jdj}|jrh|j}|j|d<|jjtj|j}x0|j D]$\}}t ||ddkr@t |||q@Wddl m }xJ|D]B}t ||}|dk rz|||}tjdkrtjj|}t |||qzWdS)Nrr0r)rr)Zget_finalized_commandrrrr rr>rDEFAULT_SCHEMErrrrrr?r)rrrrHrrrr;r;r<rTs         zeasy_install._expand)rQNrR)rSrTrU)rVrWrX)rYrZr[)r\r]r^)r_rDr`)rarbrc)rdrerf)rgrhri)rjrkrl)rmrnro)rprqrr)rsNrt)rurvrw)rxryrz)r{r|r})r~rr)rrr)rrr)rNr)rNr)F)F)T)N)r)Q__name__ __module__ __qualname____doc__ descriptionZcommand_consumes_argumentsZ user_optionsZboolean_optionsrrrZhelp_msgrZ negative_optrrrrr staticmethodrrrrrrrrrrrKrLlstriprrrrrr.r2r3r5 contextlibcontextmanagerr;r2r?rr@rOrWr,r+r]r[rFrGrhrirrjrrrLrrorrprrIrlrxrrrr=rrr rrr;r;r;r<r2xs    0 z   0    ;  $ $ '  ,6-5   %    cCs tjjddjtj}td|S)Nrr)r>rrrpathsepfilter)rr;r;r<rksrc Csg}|jttjg}tjtjkr0|jtjx|D]}|r6tjdkr`|jtjj |ddn\tj dkr|jtjj |ddtj dd dtjj |dd gn|j|tjj |ddgtjd kr6d |kr6tj j d }|r6tjj |ddtj dd d}|j|q6Wtdtdf}x"|D]}||kr |j|q WtjrR|jtjy|jtjWntk rzYnXttt|}|S)z& Return a list of 'site' dirs os2emxriscosZLibz site-packagesrlibrNrz site-pythondarwinzPython.frameworkHOMELibraryPythonpurelibplatlib)rr)extendrrrrrr{r>r?r seprrrrrrrgetsitepackagesAttributeErrorrrr!)sitedirsrrrZhome_spZ lib_pathsZsite_libr;r;r<rpsV            rccsi}x|D]}t|}||kr q d||<tjj|s6q tj|}||fVx|D]}|jds`qP|dkrjqPttjj||}tt |}|j xP|D]H}|j dst|j }||krd||<tjj|sq|tj|fVqWqPWq WdS)zBYield sys.path directories that might contain "old-style" packagesrz.ptheasy-install.pthsetuptools.pthimportN)rr) r!r>r?rrPrDrr rr rrnrstrip)Zinputsseenr#r1rrklinesliner;r;r< expand_pathss4           rc Cs&t|d}z tj|}|dkr$dS|d|d|d}|dkrHdS|j|dtjd|jd\}}}|dkrzdS|j|d|d d d }tj|}y<|j|} | j d d d} | j t j } |j tj| Wntjk rdSX|jd s|jd rdS|S|jXdS)znExtract configuration data from a bdist_wininst .exe Returns a configparser.RawConfigParser, or None rbN  zegg path translations for a given .exe filePURELIB/rPLATLIB/pywin32_system32PLATLIB/SCRIPTS/EGG-INFO/scripts/DATA/lib/site-packagesrrrzPKG-INFOrz .egg-inforNz EGG-INFO/z.pthz -nspkg.pthPURELIBPLATLIB\rz%s/%s/cSsg|]\}}|j|fqSr;)r')rrbyr;r;r<r$sz$get_exe_prefixes..)rr)rr)rr)rr)rr)rr)rZZipFileZinfolistrrrrDrr upperrrZPY3rar rMrNrnrrsortreverse)Z exe_filenamerrTrrrrVZpthr;r;r<r6s>     & c@sTeZdZdZdZffddZddZddZed d Z d d Z d dZ ddZ dS)r3z)A .pth file with Distribution paths in itFcCsp||_ttt||_ttjj|j|_|j t j |gddx(t |j D]}tt|jt|dqNWdS)NT)rrrr!rr>r?r#basedir_loadr&__init__r rrJr%)rrrr?r;r;r<r/szPthDistributions.__init__cCsg|_d}tj|j}tjj|jrt|jd}x|D]}|j drJd}q6|j }|jj ||j s6|j j drxq6t tjj|j|}|jd<tjj| s||kr|jjd|_q6d||<q6W|j|jr| rd|_x&|jo|jdj r |jjqWdS) NFZrtrT#rrr)rrfromkeysrr>r?rkrrrnrrrMr!r rr@popdirtyr)rZ saw_importrrkrr?r;r;r<r8s2        zPthDistributions._loadc Cs|js dStt|j|j}|rtjd|j|j|}dj |d}t j j |jr`t j |jt|jd}|j|WdQRXn(t j j|jrtjd|jt j |jd|_dS)z$Write changed .pth file back to diskNz Saving %srJrzDeleting empty %sF)rrrrrr rr _wrap_linesr r>r?rrrr%r@)rZ rel_pathsrdatarkr;r;r<rWs   zPthDistributions.savecCs|S)Nr;)rr;r;r<rmszPthDistributions._wrap_linescCsN|j|jko$|j|jkp$|jtjk}|r>|jj|jd|_tj||dS)z"Add `dist` to the distribution mapTN) rArrr>getcwdrrr&rJ)rrnew_pathr;r;r<rJqs  zPthDistributions.addcCs6x$|j|jkr$|jj|jd|_qWtj||dS)z'Remove `dist` from the distribution mapTN)rArrKrr&)rrr;r;r<rKs zPthDistributions.removecCstjjt|\}}t|j}|g}tjdkr2dp6tj}xVt||kr||jkrn|jtj |j |j |Stjj|\}}|j|q:W|SdS)Nr) r>r?rr!rraltseprrcurdirrr )rr?ZnpathZlastZbaselenrrr;r;r<rs    zPthDistributions.make_relativeN) rrrrrrrrrrrJrKrr;r;r;r<r3*s  c@s(eZdZeddZedZedZdS)RewritePthDistributionsccs(|jVx|D] }|VqW|jVdS)N)preludepostlude)clsrrr;r;r<rs  z#RewritePthDistributions._wrap_linesz? import sys sys.__plen = len(sys.path) z import sys new = sys.path[sys.__plen:] del sys.path[sys.__plen:] p = getattr(sys, '__egginsert', 0) sys.path[p:p] = new sys.__egginsert = p + len(new) N)rrr classmethodrr"rrr;r;r;r<rs  rZSETUPTOOLS_SYS_PATH_TECHNIQUErawZrewritecCs ttjtrtStjtjjS)z_ Return a regular expression based on first_line_re suitable for matching strings. )rrpatternr9recompilerar;r;r;r<_first_line_res rcCsd|tjtjgkr.tjdkr.t|tj||Stj\}}}t j ||d|dd||ffdS)Nrrrz %s %s) r>rrKrrdrS_IWRITErrrZreraise)funcargexcZetZevr}r;r;r< auto_chmods  rcCs.t|}t|tj|r"t|nt|dS)aa Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data from the original distribution. Any such finders need to be cleared since the replacement distribution might be packaged differently, e.g. a zipped egg distribution might get replaced with an unzipped egg folder or vice versa. Having the old finders cached may then cause Python to attempt loading modules from the replacement distribution using an incorrect loader. zipimport.zipimporter objects are Python loaders charged with importing data packaged inside zip archives. If stale loaders referencing the original distribution, are left behind, they can fail to load modules from the replacement distribution. E.g. if an old zipimport.zipimporter instance is used to load data from a new zipped egg archive, it may cause the operation to attempt to locate the requested data in the wrong location - one indicated by the original distribution's zip archive directory information. Such an operation may then fail outright, e.g. report having read a 'bad local file header', or even worse, it may fail silently & return invalid data. zipimport._zip_directory_cache contains cached zip archive directory information for all existing zipimport.zipimporter instances and all such instances connected to the same archive share the same cached directory information. If asked, and the underlying Python implementation allows it, we can fix all existing zipimport.zipimporter instances instead of having to track them down and remove them one by one, by updating their shared cached zip archive directory information. This, of course, assumes that the replacement distribution is packaged as a zipped egg. If not asked to fix existing zipimport.zipimporter instances, we still do our best to clear any remaining zipimport.zipimporter related cached data that might somehow later get used when attempting to load data from the new distribution and thus cause such load operations to fail. Note that when tracking down such remaining stale data, we can not catch every conceivable usage from here, and we clear only those that we know of and have found to cause problems if left alive. Any remaining caches should be updated by whomever is in charge of maintaining them, i.e. they should be ready to handle us replacing their zip archives with new distributions at runtime. N)r!_uncacherpath_importer_cache!_replace_zip_directory_cache_data*_remove_and_clear_zip_directory_cache_data)Z dist_pathrvnormalized_pathr;r;r<rys <  rycCsTg}t|}xB|D]:}t|}|j|r|||dtjdfkr|j|qW|S)ap Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any sub-path entries are included as well, i.e. those corresponding to zip archives embedded in other zip archives. rr)rr!rnr>rr)rcacheresultZ prefix_lenpZnpr;r;r<"_collect_zipimporter_cache_entriess   rcCsDx>t||D]0}||}||=|o*|||}|dk r |||<q WdS)a Update zipimporter cache data for a given normalized path. Any sub-path entries are processed as well, i.e. those corresponding to zip archives embedded in other zip archives. Given updater is a callable taking a cache entry key and the original entry (after already removing the entry from the cache), and expected to update the entry and possibly return a new one to be inserted in its place. Returning None indicates that the entry should not be replaced with a new one. If no updater is given, the cache entries are simply removed without any additional processing, the same as if the updater simply returned None. N)r)rrupdaterr old_entryZ new_entryr;r;r<_update_zipimporter_cache*s  r cCst||dS)N)r )rrr;r;r<rJsrcCsdd}t|tj|ddS)NcSs |jdS)N)clear)r?rr;r;r<2clear_and_remove_cached_zip_archive_directory_dataOszf_remove_and_clear_zip_directory_cache_data..clear_and_remove_cached_zip_archive_directory_data)r)r rs_zip_directory_cache)rr"r;r;r<rNsrZ__pypy__cCsdd}t|tj|ddS)NcSs&|jtj||jtj||S)N)r!rsrtupdater#)r?rr;r;r<)replace_cached_zip_archive_directory_dataes zT_replace_zip_directory_cache_data..replace_cached_zip_archive_directory_data)r)r rsr#)rr%r;r;r<rds rc Cs2yt||dWnttfk r(dSXdSdS)z%Is this string a valid Python script?execFTN)r SyntaxError TypeError)rOrr;r;r< is_pythonws r*cCsJy(tj|dd}|jd}WdQRXWnttfk r@|SX|dkS)zCDetermine if the specified executable is a .sh (contains a #! line)zlatin-1)rrNz#!)rrrrr)r&fpmagicr;r;r<is_shs r-cCs tj|gS)z@Quote a command line argument according to Windows parsing rules) subprocess list2cmdline)rr;r;r< nt_quote_argsr0cCsH|jds|jdrdSt||r&dS|jdrDd|jdjkSdS)zMIs this text, as a whole, a Python script? (as opposed to shell/bat/etc. z.pyz.pywTz#!rrF)rDr*rn splitlinesr')r_rr;r;r<r\s  r\)rdcGsdS)Nr;)rr;r;r<_chmodsr2cCsRtjd||yt||Wn0tjk rL}ztjd|WYdd}~XnXdS)Nzchanging mode of %s to %ozchmod failed: %s)r rr2r>error)r?rer|r;r;r<rds rdc@seZdZdZgZeZeddZeddZ eddZ edd Z ed d Z d d Z eddZddZeddZeddZdS) CommandSpeczm A command spec for a #! header, specified as a list of arguments akin to those passed to Popen. cCs|S)zV Choose the best CommandSpec class based on environmental conditions. r;)r r;r;r<rYszCommandSpec.bestcCstjjtj}tjjd|S)N__PYVENV_LAUNCHER__)r>r?rBrr&rr)r Z_defaultr;r;r<_sys_executableszCommandSpec._sys_executablecCs:t||r|St|tr ||S|dkr0|jS|j|S)zg Construct a CommandSpec from a parameter to build_scripts, which may be None. N)rrfrom_environment from_string)r Zparamr;r;r< from_params  zCommandSpec.from_paramcCs||jgS)N)r6)r r;r;r<r7szCommandSpec.from_environmentcCstj|f|j}||S)z} Construct a command spec from a simple string representing a command line parseable by shlex.split. )shlexr split_args)r stringrr;r;r<r8szCommandSpec.from_stringcCs8tj|j||_tj|}t|s4dg|jdd<dS)Nz-xr)r:r_extract_optionsoptionsr.r/rH)rr_cmdliner;r;r<install_optionss zCommandSpec.install_optionscCs:|djd}tj|}|r.|jdp0dnd}|jS)zH Extract any options from the first line of the script. rJrrr)r1rmatchgrouprM)Z orig_scriptfirstrAr>r;r;r<r=s zCommandSpec._extract_optionscCs|j|t|jS)N)_renderrr>)rr;r;r< as_headerszCommandSpec.as_headercCs6d}x,|D]$}|j|r |j|r |ddSq W|S)Nz"'rr)rnrD)itemZ_QUOTESqr;r;r< _strip_quotess  zCommandSpec._strip_quotescCs tjdd|D}d|dS)Ncss|]}tj|jVqdS)N)r4rHrM)rrFr;r;r<rsz&CommandSpec._render..z#!rJ)r.r/)rr?r;r;r<rDszCommandSpec._renderN)rrrrr>rr;r rYr6r9r7r8r@rr=rErHrDr;r;r;r<r4s       r4c@seZdZeddZdS)WindowsCommandSpecF)rN)rrrrr;r;r;r;r<rIsrIc@seZdZdZejdjZeZ e dddZ e dddZ e dd d Z ed d Ze d dZe ddZe ddZe dddZdS)rXz` Encapsulates behavior around writing entry point scripts for console and gui apps. a # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r __requires__ = %(spec)r import re import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit( load_entry_point(%(spec)r, %(group)r, %(name)r)() ) NFcCs6tjdt|rtntj}|jd||}|j||S)Nz Use get_argsr)warningsrDeprecationWarningWindowsScriptWriterrXrYget_script_headerrZ)r rr&wininstwriterheaderr;r;r<get_script_argss zScriptWriter.get_script_argscCs6tjdt|rd}|jjj|}|j||jS)NzUse get_headerz python.exe)rJrrKcommand_spec_classrYr9r@rE)r r_r&rNcmdr;r;r<rM's   zScriptWriter.get_script_headerc cs|dkr|j}t|j}xjdD]b}|d}xT|j|jD]B\}}|j||jt}|j||||} x| D] } | VqrWq>Wq"WdS)z Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. NconsoleguiZ_scripts)rTrU) r^r9rNZ get_entry_mapr_ensure_safe_namerr_get_script_args) r rrPrtype_rBrZepr_rrr;r;r<rZ1s     zScriptWriter.get_argscCstjd|}|rtddS)z? Prevent paths in *_scripts entry point names. z[\\/]z+Path separators not allowed in script namesN)r searchr)rZ has_path_sepr;r;r<rVCs zScriptWriter._ensure_safe_namecCs tjdt|rtjS|jS)NzUse best)rJrrKrLrY)r Z force_windowsr;r;r< get_writerLs zScriptWriter.get_writercCs.tjdkstjdkr&tjdkr&tjS|SdS)zD Select the best ScriptWriter for this environment. win32javarN)rr{r>r_namerLrY)r r;r;r<rYRszScriptWriter.bestccs|||fVdS)Nr;)r rXrrPr_r;r;r<rW\szScriptWriter._get_script_argsrcCs"|jjj|}|j||jS)z;Create a #! line, getting options (if any) from script_text)rRrYr9r@rE)r r_r&rSr;r;r<r^as zScriptWriter.get_header)NF)NF)N)rN)rrrrrKrLrrr4rRr rQrMrZrrVrZrYrWr^r;r;r;r<rX s       rXc@sLeZdZeZeddZeddZeddZeddZ e d d Z d S) rLcCstjdt|jS)NzUse best)rJrrKrY)r r;r;r<rZls zWindowsScriptWriter.get_writercCs"tt|d}tjjdd}||S)zC Select the best ScriptWriter suitable for Windows )r&ZnaturalZSETUPTOOLS_LAUNCHERr&)rWindowsExecutableLauncherWriterr>rr)r Z writer_lookupZlauncherr;r;r<rYrs zWindowsScriptWriter.bestc #stddd|}|tjdjjdkrBdjft}tj|t dddd d dd g}|j ||j ||}fd d |D}|||d|fVdS)z For Windows, add a .py extensionz.pyaz.pyw)rTrUZPATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.z.pyz -script.pyz.pycz.pyoz.execsg|] }|qSr;r;)rrb)rr;r<rsz8WindowsScriptWriter._get_script_args..rbN) rr>rr'rrrrJr UserWarningrK_adjust_header) r rXrrPr_extrrrr;)rr<rWs   z$WindowsScriptWriter._get_script_argscCsNd}d}|dkr||}}tjtj|tj}|j||d}|j|rJ|S|S)z Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is). z pythonw.exez python.exerU)r<repl)r rescape IGNORECASEsub _use_header)r rXZ orig_headerr rcZ pattern_ob new_headerr;r;r<ras z"WindowsScriptWriter._adjust_headercCs$|ddjd}tjdkp"t|S)z Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system. rr"r[r)rMrr{r)rhZ clean_headerr;r;r<rgs zWindowsScriptWriter._use_headerN) rrrrIrRr rZrYrWrarrgr;r;r;r<rLis    rLc@seZdZeddZdS)r^c #s|dkrd}d}dg}nd}d}dddg}|j||}fd d |D} |||d | fVd t|d fVtsd} | td fVdS)zG For Windows, add a .py extension and an .exe launcher rUz -script.pywz.pywZcliz -script.pyz.pyz.pycz.pyocsg|] }|qSr;r;)rrb)rr;r<rszDWindowsExecutableLauncherWriter._get_script_args..rbz.exernz .exe.manifestN)raget_win_launcherr=load_launcher_manifest) r rXrrPr_Z launcher_typerbrZhdrrZm_namer;)rr<rWs   z0WindowsExecutableLauncherWriter._get_script_argsN)rrrr rWr;r;r;r<r^sr^cCs2d|}tr|jdd}n |jdd}td|S)z Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. z%s.exe.z-64.z-32.r)r=rNr")typeZ launcher_fnr;r;r<rjs  rjcCs0tjtd}tjr|tS|jdtSdS)Nzlauncher manifest.xmlzutf-8)r$r"rrPY2varsra)rZmanifestr;r;r<rks  rkFcCstj|||S)N)rQr)r? ignore_errorsonerrorr;r;r<rsrcCstjd}tj||S)N)r>umask)Ztmpr;r;r<rcs  rccCs:ddl}tjj|jd}|tjd<tjj|tdS)Nr) rr>r?r#__path__rargvrr5)rZargv0r;r;r< bootstraps   rvc sddlm}ddlmGfddd}|dkrBtjdd}t0|fddd g|tjdpfd|d |WdQRXdS) Nr)setup)r(cseZdZdZfddZdS)z-main..DistributionWithoutHelpCommandsrc s(tj|f||WdQRXdS)N) _patch_usage _show_help)rrkw)r(r;r<ry sz8main..DistributionWithoutHelpCommands._show_helpN)rrrZ common_usageryr;)r(r;r<DistributionWithoutHelpCommandssr{rz-qr2z-v)Z script_argsr-Z distclass)rrwZsetuptools.distr(rrurx)rurzrwr{r;)r(r<r5s    c #sLddl}tjdjfdd}|jj}||j_z dVWd||j_XdS)Nrze usage: %(script)s [options] requirement_or_url ... or: %(script)s --help csttjj|dS)N)Zscript)rr>r?r))r-)USAGEr;r< gen_usage sz_patch_usage..gen_usage)Zdistutils.corerKrLrZcorer})rr}Zsavedr;)r|r<rx s   rx)N)r&)N)rrrrrrZdistutils.errorsrrrr Zdistutils.command.installr r rr r Zdistutils.command.build_scriptsrr(rrr>rsrQr6rr rr rKrJrr9rr.r:rZsetuptools.externrZsetuptools.extern.six.movesrrrrZsetuptools.sandboxrZsetuptools.py31compatrrZsetuptools.py27compatrZsetuptools.commandrZsetuptools.archive_utilrZsetuptools.package_indexrrrrrZsetuptools.wheelrr$r r!r"r#r$r%r&r'r(r)r*r+r,r-r.Zpkg_resources.py31compatfilterwarningsZ PEP440Warning__all__r=r1rnrErHr"r2rrrr4r6r3rrrrrryrr rrbuiltin_module_namesrr*r-r0r\rdr2 ImportErrorrr4r6Zsys_executablerIobjectrXrLr^rQrMrjrkrrcrvr5rrxr;r;r;r< s           D |A))'l R    T`A  __pycache__/py36compat.cpython-36.opt-1.pyc000064400000010703147210141470014350 0ustar003 K]z@sdddlZddlmZddlmZddlmZddlmZGdddZe ejdr`Gd ddZdS) N)glob) convert_path)sdist)filterc@s\eZdZdZddZeddZddZdd Zd d Z d d Z ddZ ddZ ddZ dS)sdist_add_defaultsz Mix-in providing forward-compatibility for functionality as found in distutils on Python 3.7. Do not edit the code in this class except to update functionality as implemented in distutils. Instead, override in the subclass. cCs<|j|j|j|j|j|j|jdS)a9Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as scripts. - all C sources listed as part of extensions or C libraries in the setup script (doesn't catch C headers!) Warns if (README or README.txt) or setup.py are missing; everything else is optional. N)_add_defaults_standards_add_defaults_optional_add_defaults_python_add_defaults_data_files_add_defaults_ext_add_defaults_c_libs_add_defaults_scripts)selfr /usr/lib/python3.6/py36compat.py add_defaultsszsdist_add_defaults.add_defaultscCs:tjj|sdStjj|}tjj|\}}|tj|kS)z Case-sensitive path existence check >>> sdist_add_defaults._cs_path_exists(__file__) True >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False F)ospathexistsabspathsplitlistdir)fspathrZ directoryfilenamerrr_cs_path_exists(s  z"sdist_add_defaults._cs_path_existscCs|j|jjg}x|D]}t|trn|}d}x(|D] }|j|r0d}|jj|Pq0W|s|jddj |q|j|r|jj|q|jd|qWdS)NFTz,standard file not found: should have one of z, zstandard file '%s' not found) ZREADMES distributionZ script_name isinstancetuplerfilelistappendwarnjoin)rZ standardsfnZaltsZgot_itrrrr9s       z*sdist_add_defaults._add_defaults_standardscCs8ddg}x*|D]"}ttjjt|}|jj|qWdS)Nz test/test*.pyz setup.cfg)rrrisfilerrextend)rZoptionalpatternfilesrrrrNs z)sdist_add_defaults._add_defaults_optionalcCsd|jd}|jjr$|jj|jx:|jD]0\}}}}x"|D]}|jjtj j ||q>Wq,WdS)Nbuild_py) get_finalized_commandrZhas_pure_modulesrr$get_source_files data_filesrrrr!)rr'ZpkgZsrc_dirZ build_dir filenamesrrrrr Ts    z'sdist_add_defaults._add_defaults_pythoncCs|jjr~xr|jjD]f}t|trDt|}tjj|rz|j j |q|\}}x,|D]$}t|}tjj|rR|j j |qRWqWdS)N) rZhas_data_filesr*rstrrrrr#rr)ritemdirnamer+frrrr ds     z+sdist_add_defaults._add_defaults_data_filescCs(|jjr$|jd}|jj|jdS)N build_ext)rZhas_ext_modulesr(rr$r))rr0rrrr us  z$sdist_add_defaults._add_defaults_extcCs(|jjr$|jd}|jj|jdS)N build_clib)rZhas_c_librariesr(rr$r))rr1rrrr zs  z'sdist_add_defaults._add_defaults_c_libscCs(|jjr$|jd}|jj|jdS)N build_scripts)rZ has_scriptsr(rr$r))rr2rrrr s  z(sdist_add_defaults._add_defaults_scriptsN)__name__ __module__ __qualname____doc__r staticmethodrrrr r r r r rrrrr s rrc@s eZdZdS)rN)r3r4r5rrrrrs) rrZdistutils.utilrZdistutils.commandrZsetuptools.extern.six.movesrrhasattrrrrrs    | __pycache__/rotate.cpython-36.pyc000064400000004707147210141470012711 0ustar003 K]t@s`ddlmZddlmZddlmZddlZddlZddlm Z ddl m Z Gddde Z dS) ) convert_path)log)DistutilsOptionErrorN)six)Commandc@s:eZdZdZdZdddgZgZd d ZddZddZ dS)rotatezDelete older distributionsz2delete older distributions, keeping N newest filesmatch=mpatterns to match (required) dist-dir=d%directory where the distributions arekeep=k(number of matching distributions to keepcCsd|_d|_d|_dS)N)matchdist_dirkeep)selfr/usr/lib/python3.6/rotate.pyinitialize_optionsszrotate.initialize_optionsc Cs|jdkrtd|jdkr$tdyt|j|_Wntk rPtdYnXt|jtjrxdd|jjdD|_|j dd dS) NzQMust specify one or more (comma-separated) match patterns (e.g. '.zip' or '.egg')z$Must specify number of files to keepz--keep must be an integercSsg|]}t|jqSr)rstrip).0prrr +sz+rotate.finalize_options..,Zbdistr)rr) rrrint ValueError isinstancerZ string_typessplitZset_undefined_options)rrrrfinalize_optionss  zrotate.finalize_optionscCs|jdddlm}x|jD]}|jjd|}|tjj|j|}dd|D}|j |j t j dt ||||jd}xD|D]<\}}t j d||jstjj|rtj|qtj|qWqWdS) NZegg_infor)glob*cSsg|]}tjj||fqSr)ospathgetmtime)rfrrrr6szrotate.run..z%d file(s) matching %sz Deleting %s)Z run_commandr"rZ distributionZget_namer$r%joinrsortreverserinfolenrZdry_runisdirshutilZrmtreeunlink)rr"patternfilestr'rrrrun/s       z rotate.runN)rr r )r r r )rrr) __name__ __module__ __qualname____doc__ descriptionZ user_optionsZboolean_optionsrr!r3rrrrr sr) Zdistutils.utilrZ distutilsrZdistutils.errorsrr$r.Zsetuptools.externrZ setuptoolsrrrrrrs     __pycache__/install_scripts.cpython-36.pyc000064400000004232147210141470014621 0ustar003 K] @sRddlmZddljjZddlZddlZddlm Z m Z m Z GdddejZdS))logN) Distribution PathMetadataensure_directoryc@s*eZdZdZddZddZd ddZd S) install_scriptsz;Do normal script install, plus any egg_info wrapper scriptscCstjj|d|_dS)NF)origrinitialize_optionsno_ep)selfr %/usr/lib/python3.6/install_scripts.pyr s z"install_scripts.initialize_optionsc Csddljj}|jd|jjr,tjj|ng|_ |j rs  __pycache__/__init__.cpython-36.opt-1.pyc000064400000001230147210141470014075 0ustar003 K]R@szdddddddddd d d d d dddddddddgZddlmZddlZddlmZdejkrrdejd<ejjd[[dS)alias bdist_eggZ bdist_rpmZ build_extZbuild_pyZdevelopZ easy_installZegg_infoZinstallZ install_librotateZsaveoptsZsdistZsetoptZtestZinstall_egg_infoinstall_scriptsregisterZ bdist_wininstZ upload_docsZuploadZ build_clibZ dist_info)bdistN)rZeggPython .egg file)rr) __all__Zdistutils.command.bdistrsysZsetuptools.commandrZformat_commandsZformat_commandappendr r /usr/lib/python3.6/__init__.pys         __pycache__/bdist_egg.cpython-36.pyc000064400000034002147210141470013331 0ustar003 K] G @sxdZddlmZddlmZmZddlmZddlm Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZmZmZdd lmZdd lmZdd lmZydd lmZmZd dZWn,ek rddlm Z mZddZYnXddZ!ddZ"ddZ#GdddeZ$e%j&dj'Z(ddZ)ddZ*ddZ+d d!d"Z,d#d$Z-d%d&Z.d'd(Z/d)d*d+d,gZ0d1d/d0Z1dS)2z6setuptools.command.bdist_egg Build .egg distributions)DistutilsSetupError) remove_treemkpath)log)CodeTypeN)six)get_build_platform Distributionensure_directory) EntryPoint)Library)Command)get_pathget_python_versioncCstdS)Npurelib)rrr/usr/lib/python3.6/bdist_egg.py _get_purelibsr)get_python_librcCstdS)NF)rrrrrrscCs2d|krtjj|d}|jdr.|dd}|S)N.rmodulei)ospathsplitextendswith)filenamerrr strip_module#s   rccs:x4tj|D]&\}}}|j|j|||fVq WdS)zbDo os.walk in a reproducible way, independent of indeterministic filesystem readdir order N)rwalksort)dirbasedirsfilesrrr sorted_walk+sr$c Cs6tjdj}t|d}|j||WdQRXdS)NaR def __bootstrap__(): global __bootstrap__, __loader__, __file__ import sys, pkg_resources, imp __file__ = pkg_resources.resource_filename(__name__, %r) __loader__ = None; del __bootstrap__, __loader__ imp.load_dynamic(__name__,__file__) __bootstrap__() w)textwrapdedentlstripopenwrite)ZresourcepyfileZ_stub_templatefrrr write_stub5s  r-c@seZdZdZd*dddefd+d-d.d/gZd ddgZddZddZddZ ddZ ddZ ddZ d d!Z d"d#Zd$d%Zd&d'Zd(d)Zd S)0 bdist_eggzcreate an "egg" distribution bdist-dir=b1temporary directory for creating the distributionz plat-name=pz;platform name to embed in generated filenames (default: %s)exclude-source-filesN+remove all .py files from the generated egg keep-tempkz/keep the pseudo-installation tree around after z!creating the distribution archive dist-dir=d-directory to put final built distributions in skip-build2skip rebuilding everything (for testing/debugging)cCs.d|_d|_d|_d|_d|_d|_d|_dS)Nr) bdist_dir plat_name keep_tempdist_dir skip_build egg_outputexclude_source_files)selfrrrinitialize_optionsZszbdist_egg.initialize_optionscCs|jd}|_|j|_|jdkr>|jdj}tjj|d|_|jdkrPt |_|j dd|j dkrt dd|j |jt|jjo|jj }tjj|j|d|_ dS)Negg_infoZbdistZeggr?z.egg)r?r?)get_finalized_commandei_cmdrEr< bdist_baserrjoinr=rZset_undefined_optionsrAr Zegg_nameZ egg_versionr distributionhas_ext_modulesr?)rCrGrHbasenamerrrfinalize_optionscs      zbdist_egg.finalize_optionsc Cs|j|jd_tjjtjjt}|jj g}|j_ x|D]}t |t rt |dkrtjj |drtjj|d}tjj|}||ks|j|tjr|t |dd|df}|jj j|qrgetattrr)rCZinstcmdZold_rootrk all_outputs ext_outputsZ to_compiler2Zext_namerextr+Z archive_rootrEZ script_dirZ native_libsZ libs_filerrrrunsz                    z bdist_egg.runc Cstjdxt|jD]\}}}x|D]}tjj||}|jdrXtjd|tj ||jdr&|}d}t j ||}tjj|tj |j dd} tjd|| fytj| Wntk rYnXtj|| q&WqWdS) Nz+Removing .py files from temporary directoryz.pyz Deleting %s __pycache__z#(?P.+)\.(?P[^.]+)\.pycnamez.pyczRenaming file from [%s] to [%s])rr_walk_eggr<rrrIrdebugrzrematchpardirgroupremoveOSErrorrename) rCr!r"r#rrZpath_oldpatternmZpath_newrrrrs*        zbdist_egg.zap_pyfilescCs2t|jdd}|dk r|Stjdt|j|jS)Nr|z4zip_safe flag not set; analyzing archive contents...)rrJrr~ analyze_eggr<rt)rCsaferrrr| s  zbdist_egg.zip_safec Cstj|jjpd}|jdijd}|dkr0dS|j s>|jrLtd|ftj dd}|j }dj |j}|jd}t j j|j}d t}|jstt j j|j|jd t|jd} | j|| jd S) Nzsetuptools.installationZ eggsecutabler%zGeggsecutable entry point (%r) cannot have 'extras' or refer to a modulerraH#!/bin/sh if [ `basename $0` = "%(basename)s" ] then exec python%(pyver)s -c "import sys, os; sys.path.insert(0, os.path.abspath('$0')); from %(pkg)s import %(base)s; sys.exit(%(full)s())" "$@" else echo $0 is not the correct name for this egg file. echo Please rename it back to %(basename)s and try again. exec false fi )rea)r Z parse_maprJZ entry_pointsgetZattrsZextrasrsysversionZ module_namerIrrrLrAlocalsrerrjr)r*rx) rCZepmZepZpyverpkgZfullr!rLheaderr,rrrrs*      zbdist_egg.gen_headercCsltjj|j}tjj|d}xJ|jjjD]<}|j|r(tjj||t |d}t ||j ||q(WdS)z*Copy metadata (egg info) to the target_dirrN) rrnormpathrErIrGZfilelistr#r\rZr Z copy_file)rCZ target_dirZ norm_egg_infoprefixrtargetrrrrw:s zbdist_egg.copy_metadata_toc Csg}g}|jdi}x|t|jD]n\}}}x6|D].}tjj|djtkr.|j|||q.Wx*|D]"}|||d|tjj||<qfWqW|j j r |j d}xd|j D]Z} t | trq|j| j} |j| }tjj|jdstjjtjj|j|r|j|qW||fS)zAGet a list of relative paths to C extensions in the output distrorrPrlZ build_extzdl-)r<r$rrrlowerNATIVE_EXTENSIONSr^rIrJrKrF extensionsrXr Zget_ext_fullnamerZget_ext_filenamerLr\r}) rCrrpathsr!r"r#rZ build_cmdrfullnamerrrrsFs(   &      zbdist_egg.get_ext_outputs)r/r0r1)r3Nr4Pkeep the pseudo-installation tree around after creating the distribution archive)r5r6r)r7r8r9)r:Nr;)__name__ __module__ __qualname__ descriptionrZ user_optionsZboolean_optionsrDrMrcrdr`rrr|rrwrsrrrrr.Cs4   Q' r.z.dll .so .dylib .pydccsLt|}t|\}}}d|kr(|jd|||fVx|D] }|Vq:WdS)z@Walk an unpacked egg's contents, skipping the metadata directoryzEGG-INFON)r$nextr)egg_dirZwalkerr!r"r#Zbdfrrrrfs   rc Csx0tjD]$\}}tjjtjj|d|r |Sq Wts.visit) compression) zipfilerrrrjrr_Z ZIP_DEFLATEDZ ZIP_STOREDZZipFiler$rx) Z zip_filenamerrqrecompressrrrrrrrjr"r#r)rrerrs  r)rrTr%)2__doc__Zdistutils.errorsrZdistutils.dir_utilrrZ distutilsrtypesrrrrr&rZsetuptools.externrZ pkg_resourcesrr r r Zsetuptools.extensionr Z setuptoolsr sysconfigrrr ImportErrorZdistutils.sysconfigrrr$r-r.rrsplitrrrr{rrrrrfrrrrrsL         " $  __pycache__/install_lib.cpython-36.opt-1.pyc000064400000007603147210141470014644 0ustar003 K]@sBddlZddlZddlmZmZddljjZGdddejZdS)N)productstarmapc@sZeZdZdZddZddZddZedd Zd d Z ed d Z dddZ ddZ dS) install_libz9Don't add compiled flags to filenames of non-Python filescCs&|j|j}|dk r"|j|dS)N)ZbuildinstallZ byte_compile)selfoutfilesr!/usr/lib/python3.6/install_lib.pyrun szinstall_lib.runcs4fddjD}t|j}ttj|S)z Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations. c3s"|]}j|D] }|VqqdS)N) _all_packages).0Zns_pkgpkg)rrr sz-install_lib.get_exclusions..)_get_SVEM_NSPsr_gen_exclusion_pathssetr_exclude_pkg_path)rZ all_packagesZ excl_specsr)rr get_exclusionss  zinstall_lib.get_exclusionscCs$|jd|g}tjj|jf|S)zw Given a package name and exclusion path within that package, compute the full exclusion path. .)splitospathjoinZ install_dir)rr Zexclusion_pathpartsrrr rszinstall_lib._exclude_pkg_pathccs$x|r|V|jd\}}}qWdS)zn >>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo'] rN) rpartition)Zpkg_namesepZchildrrr r 'szinstall_lib._all_packagescCs,|jjs gS|jd}|j}|r(|jjSgS)z Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise. r)Z distributionZnamespace_packagesZget_finalized_commandZ!single_version_externally_managed)rZ install_cmdZsvemrrr r1s  zinstall_lib._get_SVEM_NSPsccsbdVdVdVttds dStjjddtj}|dV|d V|d V|d VdS) zk Generate file paths to be excluded for namespace packages (bytecode cache files). z __init__.pyz __init__.pycz __init__.pyoget_tagN __pycache__z __init__.z.pycz.pyoz .opt-1.pycz .opt-2.pyc)hasattrimprrrr)baserrr rAs    z install_lib._gen_exclusion_pathsrc sX|jstjj|||Sddlm}ddlmgfdd}||||S)Nr)unpack_directory)logcs<|krjd|dSjd|tjj|j||S)Nz/Skipping installation of %s (namespace package)Fzcopying %s -> %s)warninforrdirnameappend)srcdst)excluder#rrr pfgs z!install_lib.copy_tree..pf)rorigr copy_treeZsetuptools.archive_utilr"Z distutilsr#) rZinfileZoutfileZ preserve_modeZpreserve_timesZpreserve_symlinkslevelr"r+r)r*r#rr r-Vs   zinstall_lib.copy_treecs.tjj|}|jr*fdd|DS|S)Ncsg|]}|kr|qSrr)r f)r*rr xsz+install_lib.get_outputs..)r,r get_outputsr)rZoutputsr)r*r r1ts  zinstall_lib.get_outputsN)r!r!rr!) __name__ __module__ __qualname____doc__r rr staticmethodr rrr-r1rrrr rs   r) rr itertoolsrrZdistutils.command.install_libZcommandrr,rrrr s __pycache__/setopt.cpython-36.pyc000064400000010656147210141470012731 0ustar003 K]@sddlmZddlmZddlmZddlZddlZddlmZddl m Z ddd d gZ dd dZ dddZ Gdd d e ZGdd d eZdS)) convert_path)log)DistutilsOptionErrorN) configparser)Command config_file edit_config option_basesetoptlocalcCsh|dkr dS|dkr,tjjtjjtjdS|dkrZtjdkrBdpDd}tjjtd |St d |d S) zGet the filename of the distutils, local, global, or per-user config `kind` must be one of "local", "global", or "user" r z setup.cfgglobalz distutils.cfguserposix.z~/%spydistutils.cfgz7config_file() type must be 'local', 'global', or 'user'N) ospathjoindirname distutils__file__name expanduserr ValueError)Zkinddotr/usr/lib/python3.6/setopt.pyrsFc Cs.tjd|tj}|j|gx|jD]\}}|dkrTtjd|||j|q*|j|svtjd|||j |x||jD]p\}}|dkrtjd||||j |||j |stjd|||j|qtjd|||||j |||qWq*Wtjd||s*t |d }|j|WdQRXdS) aYEdit a configuration file to include `settings` `settings` is a dictionary of dictionaries or ``None`` values, keyed by command/section name. A ``None`` value means to delete the entire section, while a dictionary lists settings to be changed or deleted in that section. A setting of ``None`` means to delete that setting. zReading configuration from %sNzDeleting section [%s] from %szAdding new section [%s] to %szDeleting %s.%s from %sz#Deleting empty [%s] section from %szSetting %s.%s to %r in %sz Writing %sw)rdebugrZRawConfigParserreaditemsinfoZremove_sectionZ has_sectionZ add_sectionZ remove_optionoptionssetopenwrite) filenameZsettingsdry_runZoptsZsectionr"optionvaluefrrrr!s8            c@s2eZdZdZdddgZddgZd d Zd dZdS)r zr? descriptionr r@rAr6r;rSrrrrr ss )r )F)Zdistutils.utilrrrZdistutils.errorsrrZsetuptools.extern.six.movesrZ setuptoolsr__all__rrr r rrrrs        +'__pycache__/__init__.cpython-36.pyc000064400000001230147210141470013136 0ustar003 K]R@szdddddddddd d d d d dddddddddgZddlmZddlZddlmZdejkrrdejd<ejjd[[dS)alias bdist_eggZ bdist_rpmZ build_extZbuild_pyZdevelopZ easy_installZegg_infoZinstallZ install_librotateZsaveoptsZsdistZsetoptZtestZinstall_egg_infoinstall_scriptsregisterZ bdist_wininstZ upload_docsZuploadZ build_clibZ dist_info)bdistN)rZeggPython .egg file)rr) __all__Zdistutils.command.bdistrsysZsetuptools.commandrZformat_commandsZformat_commandappendr r /usr/lib/python3.6/__init__.pys         __pycache__/dist_info.cpython-36.pyc000064400000002445147210141470013366 0ustar003 K]@s8dZddlZddlmZddlmZGdddeZdS)zD Create a dist_info directory As defined in the wheel specification N)Command)logc@s.eZdZdZd gZddZddZd d Zd S) dist_infozcreate a .dist-info directory egg-base=eLdirectory containing .egg-info directories (default: top of the source tree)cCs d|_dS)N)egg_base)selfr /usr/lib/python3.6/dist_info.pyinitialize_optionsszdist_info.initialize_optionscCsdS)Nr )r r r r finalize_optionsszdist_info.finalize_optionscCsn|jd}|j|_|j|j|jdtd d}tjdjt j j ||jd}|j |j|dS)Negg_infoz .egg-infoz .dist-infoz creating '{}' bdist_wheel) Zget_finalized_commandrr runrlenrinfoformatospathabspathZegg2dist)r rZ dist_info_dirrr r r rs  z dist_info.runN)rrr)__name__ __module__ __qualname__ descriptionZ user_optionsr r rr r r r r s r)__doc__rZdistutils.corerZ distutilsrrr r r r s  __pycache__/bdist_egg.cpython-36.opt-1.pyc000064400000034002147210141470014270 0ustar003 K] G @sxdZddlmZddlmZmZddlmZddlm Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZmZmZdd lmZdd lmZdd lmZydd lmZmZd dZWn,ek rddlm Z mZddZYnXddZ!ddZ"ddZ#GdddeZ$e%j&dj'Z(ddZ)ddZ*ddZ+d d!d"Z,d#d$Z-d%d&Z.d'd(Z/d)d*d+d,gZ0d1d/d0Z1dS)2z6setuptools.command.bdist_egg Build .egg distributions)DistutilsSetupError) remove_treemkpath)log)CodeTypeN)six)get_build_platform Distributionensure_directory) EntryPoint)Library)Command)get_pathget_python_versioncCstdS)Npurelib)rrr/usr/lib/python3.6/bdist_egg.py _get_purelibsr)get_python_librcCstdS)NF)rrrrrrscCs2d|krtjj|d}|jdr.|dd}|S)N.rmodulei)ospathsplitextendswith)filenamerrr strip_module#s   rccs:x4tj|D]&\}}}|j|j|||fVq WdS)zbDo os.walk in a reproducible way, independent of indeterministic filesystem readdir order N)rwalksort)dirbasedirsfilesrrr sorted_walk+sr$c Cs6tjdj}t|d}|j||WdQRXdS)NaR def __bootstrap__(): global __bootstrap__, __loader__, __file__ import sys, pkg_resources, imp __file__ = pkg_resources.resource_filename(__name__, %r) __loader__ = None; del __bootstrap__, __loader__ imp.load_dynamic(__name__,__file__) __bootstrap__() w)textwrapdedentlstripopenwrite)ZresourcepyfileZ_stub_templatefrrr write_stub5s  r-c@seZdZdZd*dddefd+d-d.d/gZd ddgZddZddZddZ ddZ ddZ ddZ d d!Z d"d#Zd$d%Zd&d'Zd(d)Zd S)0 bdist_eggzcreate an "egg" distribution bdist-dir=b1temporary directory for creating the distributionz plat-name=pz;platform name to embed in generated filenames (default: %s)exclude-source-filesN+remove all .py files from the generated egg keep-tempkz/keep the pseudo-installation tree around after z!creating the distribution archive dist-dir=d-directory to put final built distributions in skip-build2skip rebuilding everything (for testing/debugging)cCs.d|_d|_d|_d|_d|_d|_d|_dS)Nr) bdist_dir plat_name keep_tempdist_dir skip_build egg_outputexclude_source_files)selfrrrinitialize_optionsZszbdist_egg.initialize_optionscCs|jd}|_|j|_|jdkr>|jdj}tjj|d|_|jdkrPt |_|j dd|j dkrt dd|j |jt|jjo|jj }tjj|j|d|_ dS)Negg_infoZbdistZeggr?z.egg)r?r?)get_finalized_commandei_cmdrEr< bdist_baserrjoinr=rZset_undefined_optionsrAr Zegg_nameZ egg_versionr distributionhas_ext_modulesr?)rCrGrHbasenamerrrfinalize_optionscs      zbdist_egg.finalize_optionsc Cs|j|jd_tjjtjjt}|jj g}|j_ x|D]}t |t rt |dkrtjj |drtjj|d}tjj|}||ks|j|tjr|t |dd|df}|jj j|qrgetattrr)rCZinstcmdZold_rootrk all_outputs ext_outputsZ to_compiler2Zext_namerextr+Z archive_rootrEZ script_dirZ native_libsZ libs_filerrrrunsz                    z bdist_egg.runc Cstjdxt|jD]\}}}x|D]}tjj||}|jdrXtjd|tj ||jdr&|}d}t j ||}tjj|tj |j dd} tjd|| fytj| Wntk rYnXtj|| q&WqWdS) Nz+Removing .py files from temporary directoryz.pyz Deleting %s __pycache__z#(?P.+)\.(?P[^.]+)\.pycnamez.pyczRenaming file from [%s] to [%s])rr_walk_eggr<rrrIrdebugrzrematchpardirgroupremoveOSErrorrename) rCr!r"r#rrZpath_oldpatternmZpath_newrrrrs*        zbdist_egg.zap_pyfilescCs2t|jdd}|dk r|Stjdt|j|jS)Nr|z4zip_safe flag not set; analyzing archive contents...)rrJrr~ analyze_eggr<rt)rCsaferrrr| s  zbdist_egg.zip_safec Cstj|jjpd}|jdijd}|dkr0dS|j s>|jrLtd|ftj dd}|j }dj |j}|jd}t j j|j}d t}|jstt j j|j|jd t|jd} | j|| jd S) Nzsetuptools.installationZ eggsecutabler%zGeggsecutable entry point (%r) cannot have 'extras' or refer to a modulerraH#!/bin/sh if [ `basename $0` = "%(basename)s" ] then exec python%(pyver)s -c "import sys, os; sys.path.insert(0, os.path.abspath('$0')); from %(pkg)s import %(base)s; sys.exit(%(full)s())" "$@" else echo $0 is not the correct name for this egg file. echo Please rename it back to %(basename)s and try again. exec false fi )rea)r Z parse_maprJZ entry_pointsgetZattrsZextrasrsysversionZ module_namerIrrrLrAlocalsrerrjr)r*rx) rCZepmZepZpyverpkgZfullr!rLheaderr,rrrrs*      zbdist_egg.gen_headercCsltjj|j}tjj|d}xJ|jjjD]<}|j|r(tjj||t |d}t ||j ||q(WdS)z*Copy metadata (egg info) to the target_dirrN) rrnormpathrErIrGZfilelistr#r\rZr Z copy_file)rCZ target_dirZ norm_egg_infoprefixrtargetrrrrw:s zbdist_egg.copy_metadata_toc Csg}g}|jdi}x|t|jD]n\}}}x6|D].}tjj|djtkr.|j|||q.Wx*|D]"}|||d|tjj||<qfWqW|j j r |j d}xd|j D]Z} t | trq|j| j} |j| }tjj|jdstjjtjj|j|r|j|qW||fS)zAGet a list of relative paths to C extensions in the output distrorrPrlZ build_extzdl-)r<r$rrrlowerNATIVE_EXTENSIONSr^rIrJrKrF extensionsrXr Zget_ext_fullnamerZget_ext_filenamerLr\r}) rCrrpathsr!r"r#rZ build_cmdrfullnamerrrrsFs(   &      zbdist_egg.get_ext_outputs)r/r0r1)r3Nr4Pkeep the pseudo-installation tree around after creating the distribution archive)r5r6r)r7r8r9)r:Nr;)__name__ __module__ __qualname__ descriptionrZ user_optionsZboolean_optionsrDrMrcrdr`rrr|rrwrsrrrrr.Cs4   Q' r.z.dll .so .dylib .pydccsLt|}t|\}}}d|kr(|jd|||fVx|D] }|Vq:WdS)z@Walk an unpacked egg's contents, skipping the metadata directoryzEGG-INFON)r$nextr)egg_dirZwalkerr!r"r#Zbdfrrrrfs   rc Csx0tjD]$\}}tjjtjj|d|r |Sq Wts.visit) compression) zipfilerrrrjrr_Z ZIP_DEFLATEDZ ZIP_STOREDZZipFiler$rx) Z zip_filenamerrqrecompressrrrrrrrjr"r#r)rrerrs  r)rrTr%)2__doc__Zdistutils.errorsrZdistutils.dir_utilrrZ distutilsrtypesrrrrr&rZsetuptools.externrZ pkg_resourcesrr r r Zsetuptools.extensionr Z setuptoolsr sysconfigrrr ImportErrorZdistutils.sysconfigrrr$r-r.rrsplitrrrr{rrrrrfrrrrrsL         " $  __pycache__/saveopts.cpython-36.pyc000064400000001520147210141470013245 0ustar003 K]@s$ddlmZmZGdddeZdS)) edit_config option_basec@seZdZdZdZddZdS)saveoptsz#Save command-line options to a filez7save supplied options to setup.cfg or other config filecCsp|j}i}xP|jD]F}|dkr qx6|j|jD]$\}\}}|dkr0||j|i|<q0WqWt|j||jdS)Nrz command line)Z distributionZcommand_optionsZget_option_dictitems setdefaultrfilenameZdry_run)selfZdistZsettingscmdoptsrcvalr /usr/lib/python3.6/saveopts.pyrun s z saveopts.runN)__name__ __module__ __qualname____doc__ descriptionrr r r rrsrN)Zsetuptools.command.setoptrrrr r r rs__pycache__/install_scripts.cpython-36.opt-1.pyc000064400000004232147210141470015560 0ustar003 K] @sRddlmZddljjZddlZddlZddlm Z m Z m Z GdddejZdS))logN) Distribution PathMetadataensure_directoryc@s*eZdZdZddZddZd ddZd S) install_scriptsz;Do normal script install, plus any egg_info wrapper scriptscCstjj|d|_dS)NF)origrinitialize_optionsno_ep)selfr %/usr/lib/python3.6/install_scripts.pyr s z"install_scripts.initialize_optionsc Csddljj}|jd|jjr,tjj|ng|_ |j rs  __pycache__/easy_install.cpython-36.pyc000064400000176663147210141470014115 0ustar003 K]T @sdZddlmZddlmZddlmZmZddlmZmZm Z m Z ddl m Z m Z ddlmZmZddlmZdd lmZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd l Z dd l!Z!dd l"Z"dd l#Z#dd l$Z$dd l%Z%dd l&m'Z'dd l(m)Z)m*Z*dd l+m,Z,ddl-m.Z.ddl/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:m;Z;ddl4mm?Z?ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOdd lPZ@ejQde@jRdddddddgZSdd ZTd!dZUe'jVr2d"d#ZWd$d%ZXnd&d#ZWd'd%ZXd(d)ZYGd*dde,ZZd+d,Z[d-d.Z\d/d0Z]d1dZ^d2dZ_Gd3ddeGZ`Gd4d5d5e`Zaejbjcd6d7d8kreaZ`d9d:Zdd;d<Zed=d>Zfd?d@ZgdpdAdBZhdCdDZidEdFZjdGejkkrejZlndHdIZldqdKdLZmdMdNZndOdPZodQdRZpyddSlmqZrWnesk r^dTdUZrYnXdVdWZqGdXdYdYetZueujvZwGdZd[d[euZxGd\d]d]eyZzGd^d_d_ezZ{Gd`dadae{Z|ezj}Z}ezj~Z~dbdcZdddeZdfeefdgdhZdidjZdkdlZdrdmdZe"jdndoZd S)sa% Easy Install ------------ A tool for doing automatic download/extract/build of distutils-based Python packages. For detailed documentation, see the accompanying EasyInstall.txt file, or visit the `EasyInstall home page`__. __ https://setuptools.readthedocs.io/en/latest/easy_install.html )glob) get_platform) convert_path subst_vars)DistutilsArgErrorDistutilsOptionErrorDistutilsErrorDistutilsPlatformError)INSTALL_SCHEMES SCHEME_KEYS)logdir_util) first_line_re)find_executableN)six) configparsermap)Command) run_setup)get_pathget_config_vars) rmtree_safe)setopt)unpack_archive) PackageIndexparse_requirement_arg URL_SCHEME) bdist_eggegg_info)Wheel) yield_linesnormalize_pathresource_stringensure_directoryget_distributionfind_distributions Environment Requirement Distribution PathMetadata EggMetadata WorkingSetDistributionNotFoundVersionConflict DEVELOP_DISTdefault)categorysamefile easy_installPthDistributionsextract_wininst_cfgmainget_exe_prefixescCstjddkS)NP)structcalcsizer;r;"/usr/lib/python3.6/easy_install.pyis_64bitIsr=cCsjtjj|otjj|}ttjdo&|}|r:tjj||Stjjtjj|}tjjtjj|}||kS)z Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. r1)ospathexistshasattrr1normpathnormcase)Zp1Zp2Z both_existZ use_samefileZnorm_p1Znorm_p2r;r;r<r1MscCs|S)Nr;)sr;r;r< _to_ascii_srEc Cs*ytj|ddStk r$dSXdS)NasciiTF)rZ text_type UnicodeError)rDr;r;r<isasciibs  rHcCs |jdS)NrF)encode)rDr;r;r<rEjsc Cs(y|jddStk r"dSXdS)NrFTF)rIrG)rDr;r;r<rHms  cCstj|jjddS)N z; )textwrapdedentstripreplace)textr;r;r<usrPc@seZdZdZdZdZdddddddddddddddddddddgZdd dd dd0d3d9ddddZ?ejdj Z@ddZAddZBddZCddZDddZEddZFddZGddZHejdj ZIddZJddZKddZLeMeMddddZNeMdddZOddZPdS)r2z'Manage a download/build/install processz Find/get/install Python packagesTprefix=Ninstallation prefixzip-okzinstall package as a zipfile multi-versionm%make apps have to require() a versionupgradeU1force upgrade (searches PyPI for latest versions) install-dir=dinstall package to DIR script-dir=rDinstall scripts to DIRexclude-scriptsxDon't install scripts always-copya'Copy all needed packages to install dir index-url=i base URL of Python Package Index find-links=f(additional URL(s) to search for packagesbuild-directory=b/download/extract/build in DIR; keep the results optimize=Olalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]record=3filename in which to record list of installed files always-unzipZ*don't install as a zipfile, no matter what site-dirs=S)list of directories where .pth files workeditablee+Install specified packages in editable formno-depsNdon't install dependencies allow-hosts=H$pattern(s) that hostnames must matchlocal-snapshots-okl(allow building eggs from local checkoutsversion"print version information and exit no-find-links9Don't load find-links defined in packages being installedz!install in user site-package '%s'usercCs,d|_d|_|_d|_|_|_d|_d|_d|_d|_ d|_ |_ d|_ |_ |_d|_|_|_d|_|_|_d|_d|_d|_d|_d|_d|_d|_d|_d|_tjrtj |_!tj"|_#n d|_!d|_#d|_$d|_%d|_&|_'d|_(i|_)d|_*d|_+|j,j-|_-|j,j.||j,j/ddS)NrFr2)0rzip_oklocal_snapshots_ok install_dir script_direxclude_scripts index_url find_linksbuild_directoryargsoptimizerecordrY always_copy multi_versionr{no_deps allow_hostsrootprefix no_reportrinstall_purelibinstall_platlibinstall_headers install_libinstall_scripts install_data install_baseinstall_platbasesiteENABLE_USER_SITE USER_BASEinstall_userbase USER_SITEinstall_usersite no_find_links package_indexpth_filealways_copy_from site_dirsinstalled_projectssitepy_installedZ_dry_run distributionverboseZ_set_command_optionsget_option_dict)selfr;r;r<initialize_optionssF     zeasy_install.initialize_optionscCs"dd|D}tt|j|dS)Ncss*|]"}tjj|stjj|r|VqdS)N)r>r?r@islink).0filenamer;r;r< sz/easy_install.delete_blockers..)listr _delete_path)rblockersZextant_blockersr;r;r<delete_blockersszeasy_install.delete_blockerscCsJtjd||jrdStjj|o.tjj| }|r8tntj}||dS)Nz Deleting %s) r infodry_runr>r?isdirrrmtreeunlink)rr?Zis_treeZremoverr;r;r<rs  zeasy_install._delete_pathcCs6tjdd}td}d}t|jfttdS)zT Render the Setuptools version and installation details, then exit. N setuptoolsz=setuptools {dist.version} from {dist.location} (Python {ver}))sysrr$printformatlocals SystemExit)Zverdisttmplr;r;r<_render_versions zeasy_install._render_versionc Cst|jo |jtjjd}tdd\}}|jj|jj|jj||dd|d|d||||t tddd |_ t j r|j |j d <|j|j d <|j|j|j|jd d d d|jdkr|j|_|jdkrd|_|jdd!|jdd"|jr|jr|j|_|j|_|jdd#tttj}t|_|jdk rdd|jjdD}xV|D]N}t jj!|s~t"j#d|n,t||krt$|dn|jj%t|q^W|j&s|j'|j(pd|_(|jdd|_)x4|jt|jfD] }||j)kr|j)j*d|qW|j+dk r8dd|j+jdD}ndg}|j,dkr`|j-|j(|j)|d|_,t.|j)tj|_/|j0dk rt1|j0t2j3r|j0j|_0ng|_0|j4r|j,j5|j)tj|js|j,j6|j0|jdd$t1|j7t8s@y2t8|j7|_7d|j7kodknst9Wnt9k r>t$dYnX|j&rZ|j: rZt;d|j<sjt;d g|_=dS)%Nrr exec_prefixrabiflags) Z dist_nameZ dist_versionZ dist_fullname py_versionpy_version_shortpy_version_nodotZ sys_prefixrZsys_exec_prefixrruserbaseZusersiterrrrFrrinstallrcSsg|]}tjj|jqSr;)r>r? expanduserrM)rrDr;r;r< 3sz1easy_install.finalize_options..,z"%s (in --site-dirs) does not existz$ (in --site-dirs) is not on sys.pathzhttps://pypi.org/simple/cSsg|] }|jqSr;)rM)rrDr;r;r<rHs*)Z search_pathhostsrz--optimize must be 0, 1, or 2z9Must specify a build directory (-b) when using --editablez:No urls, filenames, or requirements specified (see --help))rr)rr)rr)rr)>rrrsplitrrZget_nameZ get_versionZ get_fullnamegetattr config_varsrrrr_fix_install_dir_for_user_siteexpand_basedirs expand_dirs_expandrrrZset_undefined_optionsrrrrr!r? get_site_dirs all_site_dirsrr>rr warnrappendr{check_site_dirr shadow_pathinsertrr create_indexr& local_indexr isinstancerZ string_typesrZscan_egg_linksadd_find_linksrint ValueErrorrrroutputs) rrrrrBrr]Z path_itemrr;r;r<finalize_optionss                zeasy_install.finalize_optionscCs`|j stj rdS|j|jdkr2d}t||j|_|_tj j ddd}|j |dS)z; Fix the install_dir if "--user" was used. Nz$User base directory is not specifiedposixZunixZ_user) rrrcreate_home_pathrr rrr>namerN select_scheme)rmsgZ scheme_namer;r;r<rms z+easy_install._fix_install_dir_for_user_sitecCs\xV|D]N}t||}|dk rtjdks0tjdkrrr?rrrsetattr)rattrsattrvalr;r;r< _expand_attrs|s    zeasy_install._expand_attrscCs|jdddgdS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.rrrN)r)rr;r;r<rszeasy_install.expand_basedirscCsddddddg}|j|dS)z+Calls `os.path.expanduser` on install dirs.rrrrrrN)r)rdirsr;r;r<rszeasy_install.expand_dirsc Cs|j|jjkrtj|jzx|jD]}|j||j q$W|jr|j}|j rt |j }x(t t |D]}|||d||<qfWddl m }|j|j|j|fd|j|jWdtj|jjXdS)Nr) file_utilz'writing list of installed files to '%s')rrr set_verbosityrr2rrrrlenrange distutilsrexecuteZ write_filewarn_deprecated_options)rspecrZroot_lenZcounterrr;r;r<runs$       zeasy_install.runc CsDy tj}Wn"tk r.tjdtj}YnXtjj|j d|S)zReturn a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo. rztest-easy-install-%s) r>getpid ExceptionrandomZrandintrmaxsizer?joinr)rpidr;r;r<pseudo_tempnames  zeasy_install.pseudo_tempnamecCsdS)Nr;)rr;r;r<rsz$easy_install.warn_deprecated_optionscCsdt|j}tjj|d}tjj|sTytj|Wn ttfk rR|j YnX||j k}| rv|j rv|j }nd|j d}tjj|}y*|rtj|t|djtj|Wn ttfk r|j YnX| r|j rt|j|r|jdkrt||j |_nd|_|tttkr6d|_n$|j rZtjj| rZd|_d|_||_dS)z;Verify that self.install_dir is .pth-capable dir, if neededzeasy-install.pthz .write-testwNT)r!rr>r?r r@makedirsOSErrorIOErrorcant_write_to_targetrrcheck_pth_processingrropencloserno_default_version_msgrr3r _pythonpathr)rinstdirrZ is_site_dirZtestfileZ test_existsr;r;r<rs>         zeasy_install.check_site_diraS can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: %s The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s z This directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install-dir option). a Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://setuptools.readthedocs.io/en/latest/easy_install.html Please make the appropriate changes for your system and try again. cCsP|jtjd|jf}tjj|js6|d|j7}n|d|j7}t |dS)NrJ) _easy_install__cant_write_msgrexc_inforr>r?r@_easy_install__not_exists_id_easy_install__access_msgr)rrr;r;r<rs z!easy_install.cant_write_to_targetc Cs|j}tjd||jd}|d}tjj|}tdd}y8|rNtj|tjj |}t j j |ddt |d}Wn ttfk r|jYnXz|j|jft|jd }tj}tjd krtjj|\}} tjj|d } | jd kotjj| } | r| }d dlm} | |dddgd tjj|rJtjd|dSWd |r\|jtjj|rttj|tjj|rtj|X|jstjd|dS)z@Empirically verify whether .pth files are supported in inst. dirz Checking .pth file support in %sz.pthz.okzz import os f = open({ok_file!r}, 'w') f.write('OK') f.close() rJT)exist_okrNrz pythonw.exez python.exer)spawnz-Ez-cpassz-TEST PASSED: %s appears to support .pth filesz+TEST FAILED: %s does NOT support .pth filesF)rr rrr>r?r@ _one_linerrdirname pkg_resourcesZ py31compatrrrrrwriterrrr executablerrr lowerdistutils.spawnr rr) rrrZok_fileZ ok_existsrr#rkr&basenameZaltZuse_altr r;r;r<rsV            z!easy_install.check_pth_processingcCs\|j rN|jdrNx:|jdD],}|jd|r2q|j|||jd|qW|j|dS)z=Write all the scripts for `dist`, unless scripts are excludedscriptszscripts/N)rZmetadata_isdirZmetadata_listdirinstall_scriptZ get_metadatainstall_wrapper_scripts)rr script_namer;r;r<install_egg_scriptsSsz easy_install.install_egg_scriptscCs\tjj|rLxJtj|D].\}}}x"|D]}|jjtjj||q(WqWn |jj|dS)N)r>r?rwalkrrr )rr?baserfilesrr;r;r< add_outputas    zeasy_install.add_outputcCs|jrtd|fdS)NzjInvalid argument %r: you can't use filenames or URLs with --editable (except via the --find-links option).)r{r)rrr;r;r< not_editableiszeasy_install.not_editablecCs<|js dStjjtjj|j|jr8td|j|jfdS)Nz2%r already exists in %s; can't do a checkout there)r{r>r?r@r rkeyr)rrr;r;r<check_editableqs zeasy_install.check_editablec cs@tjtjdd}zt|VWdtjj|o8tt |XdS)Nz easy_install-)r) tempfilemkdtemprustrr>r?r@rr)rtmpdirr;r;r<_tmpdir{szeasy_install._tmpdirFcCs|js|j|j}t|tst|rT|j||jj||}|j d|||dSt j j |r||j||j d|||dSt |}|j||jj|||j|j|j |j}|dkrd|}|jr|d7}t|n0|jtkr|j|||d|S|j ||j||SWdQRXdS)NTz+Could not find suitable distribution for %rz2 (--always-copy skips system and development eggs)Using)r{install_site_pyr;rr'rr3rdownload install_itemr>r?r@rr5Zfetch_distributionrYrrrZ precedencer.process_distributionlocation)rrdepsr:dlrrr;r;r<r2s2         zeasy_install.easy_installcCs|p|j}|ptjj||k}|p,|jd }|pT|jdk oTtjjt|t|jk}|r| rx$|j|jD]}|j |krnPqnWd}t j dtjj ||r|j |||}x<|D]}|j|||qWn |j|g}|j||d|d|dk rx|D]}||kr|SqWdS)Nz.eggTz Processing %srr<)rr>r?r#endswithrr!r project_namerAr rr) install_eggsr@egg_distribution)rrr>r:rBZinstall_neededrZdistsr;r;r<r?s.         zeasy_install.install_itemcCs@t|}x2tD]*}d|}t||dkrt||||qWdS)z=Sets the install directories by applying the install schemes.Zinstall_N)r r rr)rrschemer4Zattrnamer;r;r<rs  zeasy_install.select_schemecGs|j||jj|||j|jkr2|jj||jj||j|||j|j<tj |j ||f||j dr|j r|jj |jd| r|j rdS|dk r|j|jkrtjd|dS|dks||kr|j}tt|}tj d|ytgj|g|j|j}Wn^tk rB}ztt|WYdd}~Xn0tk rp}zt|jWYdd}~XnX|js|jrx*|D]"}|j|jkr|j|jqWtj d|dS)Nzdependency_links.txtzSkipping dependencies for %szProcessing dependencies for %sz'Finished processing dependencies for %s) update_pthraddrr4remover.rr rinstallation_report has_metadatarrZget_metadata_linesrras_requirementr'r9r+Zresolver2r,rr-Zreportr)rZ requirementrrBrZdistreqZdistrosr|r;r;r<r@sB            z!easy_install.process_distributioncCs2|jdk r|j S|jdr dS|jds.dSdS)Nz not-zip-safeTzzip-safeF)rrM)rrr;r;r< should_unzips   zeasy_install.should_unzipcCstjj|j|j}tjj|r:d}tj||j|j||Stjj|rL|}nRtjj ||krftj |tj |}t |dkrtjj||d}tjj|r|}t |tj|||S)Nz<%r already exists in %s; build directory %s will not be keptrr)r>r?r rr4r@r rrr#rlistdirrr#shutilmove)rr dist_filename setup_basedstrcontentsr;r;r< maybe_moves"       zeasy_install.maybe_movecCs0|jr dSx tjj|D]}|j|qWdS)N)r ScriptWriterbestget_args write_script)rrrr;r;r<r,sz$easy_install.install_wrapper_scriptscCsNt|j}t||}|r8|j|t}tj||}|j|t|ddS)z/Generate a legacy script wrapper and install itrnN) r9rNis_python_script_load_templaterrX get_headerr[rE)rrr- script_textdev_pathrZ is_scriptZbodyr;r;r<r+"s   zeasy_install.install_scriptcCs(d}|r|jdd}td|}|jdS)z There are a couple of template scripts in the package. This function loads one of them and prepares it for use. z script.tmplz.tmplz (dev).tmplrzutf-8)rNr"decode)r`rZ raw_bytesr;r;r<r],s   zeasy_install._load_templatetc sjfdd|Dtjd|jtjjj|}j|jrLdSt }t |tjj |rptj |t |d|}|j|WdQRXt|d|dS)z1Write an executable file to the scripts directorycsg|]}tjjj|qSr;)r>r?r r)rrb)rr;r<r>sz-easy_install.write_script..zInstalling %s script to %sNri)rr rrr>r?r r2r current_umaskr#r@rrr%chmod)rr-rVmodertargetmaskrkr;)rr<r[;s   zeasy_install.write_scriptcCs`|jjdr|j||gS|jjdr8|j||gS|jjdrT|j||gS|}tjj|r|jd rt|||j ntjj |rtjj |}|j |r|j r|dk r|j|||}tjj|d}tjj|s2ttjj|dd}|stdtjj |t|dkr*td tjj ||d }|jrPtj|j||gS|j||SdS) Nz.eggz.exez.whlz.pyzsetup.pyrz"Couldn't find a setup script in %srzMultiple setup scripts in %sr)r'rD install_egg install_exe install_wheelr>r?isfilerunpack_progressrabspath startswithrrWr r@rrrr{r rreport_editablebuild_and_install)rrrSr:rT setup_scriptZsetupsr;r;r<rFOs<   zeasy_install.install_eggscCs>tjj|r"t|tjj|d}nttj|}tj ||dS)NzEGG-INFO)metadata) r>r?rr)r r* zipimport zipimporterr(Z from_filename)regg_pathrrr;r;r<rG{s    zeasy_install.egg_distributionc Cstjj|jtjj|}tjj|}|js2t||j|}t ||s|tjj |rttjj | rtt j ||jdn"tjj|r|jtj|fd|yd}tjj |r|j|rtjd}}n tjd}}nL|j|r|j||jd}}n*d}|j|rtjd}}n tjd}}|j|||f|dtjj|tjj|ft||d Wn$tk rzt|dd YnX|j||j|S) N)rz Removing FZMovingZCopyingZ ExtractingTz %s to %s)fix_zipimporter_caches)r>r?r rr)rmrr#rGr1rrr remove_treer@rrrnrQrRZcopytreerOZmkpathunpack_and_compileZcopy2r#update_dist_cachesr r2)rrur: destinationrZnew_dist_is_zippedrkrWr;r;r<rhsT               zeasy_install.install_eggc sTt|}|dkrtd|td|jdd|jddtd}tjj||jd}||_ |d}tjj|d}tjj|d }t |t |||_ |j ||tjj|st|d } | jd x<|jdD].\} } | d kr| jd | jddj| fqW| jtjj|d|jfddtj|Dtj|||j|jd|j||S)Nz(%s is not a valid distutils Windows .exerrrr)rErplatformz.eggz.tmpzEGG-INFOzPKG-INFOrzMetadata-Version: 1.0 target_versionz%s: %s _-r*csg|]}tjj|dqS)r)r>r?r )rr)rr;r<rsz,easy_install.install_exe..)rr)r4rr(getrr>r?r egg_namerAr#r)Z _provider exe_to_eggr@rr%itemsrNtitlerrrXrZrZ make_zipfilerrrh) rrSr:cfgrruegg_tmpZ _egg_infoZpkg_infrkkvr;)rr<ris<      " zeasy_install.install_exec s>t|ggifdd}t||g}xtD]l}|jjdr>|jd}|d}tj|dd|d<tjj f|}j ||j |tj ||q>W|j tj tjj dtj|xbdD]Z} t| rtjj d| d } tjj| st| d } | jd j t| d | jqWd S)z;Extract a bdist_wininst to the directories an egg would usecs|j}xԈD]\}}|j|r||t|d}|jd}tjjf|}|j}|jdsl|jdrtj |d |d <dtjj |dd<j |n4|jdr|dkrdtjj |dd<j ||SqW|jdst j d |dS) N/z.pydz.dllrrz.pyzSCRIPTS/z.pthzWARNING: can't process %sr)r'rnrrr>r?r rDr strip_modulesplitextrr r)srcrUrDoldnewpartsrC)r native_libsprefixes to_compile top_levelr;r<processs$      z(easy_install.exe_to_egg..processz.pydrrz.pyzEGG-INFOrrz.txtrrJNrrr)rr)r6rr'rDrrrr>r?r rZ write_stub byte_compileZwrite_safety_flagZ analyze_eggrr@rr%r) rrSrrZstubsresrZresourceZpyfilerZtxtrkr;)rrrrrr<rs6           zeasy_install.exe_to_eggc Cst|}|jsttjj|j|j}tjj|}|j sBt |tjj |rntjj | rnt j||j dn"tjj|r|jtj|fd|z.|j|j|fdtjj|tjj|fWdt|ddX|j||j|S)N)rz Removing zInstalling %s to %sF)rv)rZ is_compatibleAssertionErrorr>r?r rrrmrr#rrr rwr@rrZinstall_as_eggr)r#ryr2rG)rZ wheel_pathr:Zwheelrzr;r;r<rjs.      zeasy_install.install_wheela( Because this distribution was installed --multi-version, before you can import modules from this package in an application, you will need to 'import pkg_resources' and then use a 'require()' call similar to one of these examples, in order to select the desired version: pkg_resources.require("%(name)s") # latest installed version pkg_resources.require("%(name)s==%(version)s") # this exact version pkg_resources.require("%(name)s>=%(version)s") # this version or higher z Note also that the installation directory must be on sys.path at runtime for this to work. (e.g. by being the application's script directory, by being on PYTHONPATH, or by being added to sys.path by your code.) Installedc Cs`d}|jr@|j r@|d|j7}|jtttjkr@|d|j7}|j }|j }|j }d}|t S)z9Helpful installation message for display to package usersz %(what)s %(eggloc)s%(extras)srJr) rr_easy_install__mv_warningrrr!rr?_easy_install__id_warningrArErr) rZreqrZwhatrZegglocrrZextrasr;r;r<rLIsz easy_install.installation_reportaR Extracted editable version of %(spec)s to %(dirname)s If it uses setuptools in its setup script, you can activate it in "development" mode by going to that directory and running:: %(python)s setup.py develop See the setuptools documentation for the "develop" command for more info. cCs"tjj|}tj}d|jtS)NrJ)r>r?r#rr&_easy_install__editable_msgr)rrrqr#pythonr;r;r<robs zeasy_install.report_editablecCstjjdttjjdtt|}|jdkrNd|jd}|jdd|n|jdkrd|jdd|jrv|jdd t j d |t |ddd j |yt ||Wn6tk r}ztd |jdfWYdd}~XnXdS) Nzdistutils.command.bdist_eggzdistutils.command.egg_inforrrrr~z-qz-nz Running %s %s zSetup script exited with %s)rmodules setdefaultrrrrrrr rrr rrrr)rrqrTrrr;r;r<rgs      zeasy_install.run_setupc Csddg}tjdtjj|d}z|jtjj||j||j|||t|g}g}x2|D]*}x$||D]}|j|j |j |qlWq^W| r|j rt j d||St|t j|jXdS)Nrz --dist-dirz egg-dist-tmp-)rdirz+No eggs found in %s (setup script problem?))r6r7r>r?r#_set_fetcher_optionsrrr&rhrArr rrrr) rrqrTrZdist_dirZall_eggsZeggsr4rr;r;r<rp{s$   zeasy_install.build_and_installc Cst|jjdj}d }i}x2|jD]&\}}||kr4q"|d||jdd <q"Wt|d }tjj|d }t j ||d S)a When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well. r2rrrrrrr}r~)r2z setup.cfgN)rrrrrr) rrcopyrrNdictr>r?r rZ edit_config) rr0Zei_optsZfetch_directivesZ fetch_optionsr4rZsettingsZ cfg_filenamer;r;r<rs  z!easy_install._set_fetcher_optionscCs0|jdkrdSxX|j|jD]H}|js2|j|jkrtjd||jj||j|jkr|jj|jqW|js|j|jjkrtjd|n2tjd||jj ||j|jkr|jj |j|j s,|jj |jdkr,t jj|jd}t jj|rt j|t|d}|j|jj|jd|jdS)Nz&Removing %s from easy-install.pth filez4%s is already the active version in easy-install.pthz"Adding %s to easy-install.pth filerzsetuptools.pthwtrJ)rr4rrAr rrKrpathsrJrrsaver>r?r rrrrr% make_relativer)rrr]rrkr;r;r<rIs4           zeasy_install.update_pthcCstjd|||S)NzUnpacking %s to %s)r debug)rrrUr;r;r<rlszeasy_install.unpack_progresscshggfdd}t|||jjsdx.D]&}tj|tjdBd@}t||q:WdS)Ncs\|jdr"|jd r"j|n|jds6|jdr@j|j||j rX|pZdS)Nz.pyz EGG-INFO/z.dllz.so)rDrnrrlr)rrU)rto_chmodrr;r<pfs    z+easy_install.unpack_and_compile..pfimi)rrrr>statST_MODErd)rrurzrrkrer;)rrrr<rxs   zeasy_install.unpack_and_compilec Csjtjr dSddlm}z@tj|jd||dd|jd|jrT|||jd|jdWdtj|jXdS)Nr)rr)rforcer) rdont_write_bytecodedistutils.utilrr rrrr)rrrr;r;r<rs zeasy_install.byte_compilea bad install directory or PYTHONPATH You are attempting to install a package to a directory that is not on PYTHONPATH and which Python does not read ".pth" files from. The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s and your PYTHONPATH environment variable currently contains: %r Here are some of your options for correcting the problem: * You can choose a different installation directory, i.e., one that is on PYTHONPATH or supports .pth files * You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python and want to use the package(s) you are installing.) * You can set up the installation directory to support ".pth" files by using one of the approaches described here: https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again.cCs|j}||jtjjddfS)N PYTHONPATHr)_easy_install__no_default_msgrr>environr)rtemplater;r;r<rsz#easy_install.no_default_version_msgcCs|jr dStjj|jd}tdd}|jd}d}tjj|rtj d|jt j |}|j }WdQRX|j dstd |||krtjd ||jst|t j |d dd }|j|WdQRX|j|gd |_dS)z8Make sure there's a site.py in the target dir, if neededNzsite.pyrz site-patch.pyzutf-8rzChecking existing site.py in %sz def __boot():z;%s is not a setuptools-generated site.py; please remove it.z Creating %sr)encodingT)rr>r?r rr"rar@r riorreadrnrrrr#r%r)rZsitepysourceZcurrentZstrmr;r;r<r=s,       zeasy_install.install_site_pycCsj|js dSttjjd}xJtj|jD]:\}}|j|r(tjj | r(|j d|tj |dq(WdS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) rrr>r?rrZ iteritemsrrnrZ debug_printr)rhomerr?r;r;r<r>szeasy_install.create_home_pathz/$base/lib/python$py_version_short/site-packagesz $base/bin)rr)rz$base/Lib/site-packagesz $base/ScriptscGs|jdj}|jrh|j}|j|d<|jjtj|j}x0|j D]$\}}t ||ddkr@t |||q@Wddl m }xJ|D]B}t ||}|dk rz|||}tjdkrtjj|}t |||qzWdS)Nrr0r)rr)Zget_finalized_commandrrrr rr>rDEFAULT_SCHEMErrrrrr?r)rrrrHrrrr;r;r<rTs         zeasy_install._expand)rQNrR)rSrTrU)rVrWrX)rYrZr[)r\r]r^)r_rDr`)rarbrc)rdrerf)rgrhri)rjrkrl)rmrnro)rprqrr)rsNrt)rurvrw)rxryrz)r{r|r})r~rr)rrr)rrr)rNr)rNr)F)F)T)N)r)Q__name__ __module__ __qualname____doc__ descriptionZcommand_consumes_argumentsZ user_optionsZboolean_optionsrrrZhelp_msgrZ negative_optrrrrr staticmethodrrrrrrrrrrrKrLlstriprrrrrr.r2r3r5 contextlibcontextmanagerr;r2r?rr@rOrWr,r+r]r[rFrGrhrirrjrrrLrrorrprrIrlrxrrrr=rrr rrr;r;r;r<r2xs    0 z   0    ;  $ $ '  ,6-5   %    cCs tjjddjtj}td|S)Nrr)r>rrrpathsepfilter)rr;r;r<rksrc Csg}|jttjg}tjtjkr0|jtjx|D]}|r6tjdkr`|jtjj |ddn\tj dkr|jtjj |ddtj dd dtjj |dd gn|j|tjj |ddgtjd kr6d |kr6tj j d }|r6tjj |ddtj dd d}|j|q6Wtdtdf}x"|D]}||kr |j|q WtjrR|jtjy|jtjWntk rzYnXttt|}|S)z& Return a list of 'site' dirs os2emxriscosZLibz site-packagesrlibrNrz site-pythondarwinzPython.frameworkHOMELibraryPythonpurelibplatlib)rr)extendrrrrrr{r>r?r seprrrrrrrgetsitepackagesAttributeErrorrrr!)sitedirsrrrZhome_spZ lib_pathsZsite_libr;r;r<rpsV            rccsi}x|D]}t|}||kr q d||<tjj|s6q tj|}||fVx|D]}|jds`qP|dkrjqPttjj||}tt |}|j xP|D]H}|j dst|j }||krd||<tjj|sq|tj|fVqWqPWq WdS)zBYield sys.path directories that might contain "old-style" packagesrz.ptheasy-install.pthsetuptools.pthimportN)rr) r!r>r?rrPrDrr rr rrnrstrip)Zinputsseenr#r1rrklinesliner;r;r< expand_pathss4           rc Cs&t|d}z tj|}|dkr$dS|d|d|d}|dkrHdS|j|dtjd|jd\}}}|dkrzdS|j|d|d d d }tj|}y<|j|} | j d d d} | j t j } |j tj| Wntjk rdSX|jd s|jd rdS|S|jXdS)znExtract configuration data from a bdist_wininst .exe Returns a configparser.RawConfigParser, or None rbN  zegg path translations for a given .exe filePURELIB/rPLATLIB/pywin32_system32PLATLIB/SCRIPTS/EGG-INFO/scripts/DATA/lib/site-packagesrrrzPKG-INFOrz .egg-inforNz EGG-INFO/z.pthz -nspkg.pthPURELIBPLATLIB\rz%s/%s/cSsg|]\}}|j|fqSr;)r')rrbyr;r;r<r$sz$get_exe_prefixes..)rr)rr)rr)rr)rr)rr)rZZipFileZinfolistrrrrDrr upperrrZPY3rar rMrNrnrrsortreverse)Z exe_filenamerrTrrrrVZpthr;r;r<r6s>     & c@sTeZdZdZdZffddZddZddZed d Z d d Z d dZ ddZ dS)r3z)A .pth file with Distribution paths in itFcCsp||_ttt||_ttjj|j|_|j t j |gddx(t |j D]}tt|jt|dqNWdS)NT)rrrr!rr>r?r#basedir_loadr&__init__r rrJr%)rrrr?r;r;r<r/szPthDistributions.__init__cCsg|_d}tj|j}tjj|jrt|jd}x|D]}|j drJd}q6|j }|jj ||j s6|j j drxq6t tjj|j|}|jd<tjj| s||kr|jjd|_q6d||<q6W|j|jr| rd|_x&|jo|jdj r |jjqWdS) NFZrtrT#rrr)rrfromkeysrr>r?rkrrrnrrrMr!r rr@popdirtyr)rZ saw_importrrkrr?r;r;r<r8s2        zPthDistributions._loadc Cs|js dStt|j|j}|rtjd|j|j|}dj |d}t j j |jr`t j |jt|jd}|j|WdQRXn(t j j|jrtjd|jt j |jd|_dS)z$Write changed .pth file back to diskNz Saving %srJrzDeleting empty %sF)rrrrrr rr _wrap_linesr r>r?rrrr%r@)rZ rel_pathsrdatarkr;r;r<rWs   zPthDistributions.savecCs|S)Nr;)rr;r;r<rmszPthDistributions._wrap_linescCsN|j|jko$|j|jkp$|jtjk}|r>|jj|jd|_tj||dS)z"Add `dist` to the distribution mapTN) rArrr>getcwdrrr&rJ)rrnew_pathr;r;r<rJqs  zPthDistributions.addcCs6x$|j|jkr$|jj|jd|_qWtj||dS)z'Remove `dist` from the distribution mapTN)rArrKrr&)rrr;r;r<rKs zPthDistributions.removecCstjjt|\}}t|j}|g}tjdkr2dp6tj}xVt||kr||jkrn|jtj |j |j |Stjj|\}}|j|q:W|SdS)Nr) r>r?rr!rraltseprrcurdirrr )rr?ZnpathZlastZbaselenrrr;r;r<rs    zPthDistributions.make_relativeN) rrrrrrrrrrrJrKrr;r;r;r<r3*s  c@s(eZdZeddZedZedZdS)RewritePthDistributionsccs(|jVx|D] }|VqW|jVdS)N)preludepostlude)clsrrr;r;r<rs  z#RewritePthDistributions._wrap_linesz? import sys sys.__plen = len(sys.path) z import sys new = sys.path[sys.__plen:] del sys.path[sys.__plen:] p = getattr(sys, '__egginsert', 0) sys.path[p:p] = new sys.__egginsert = p + len(new) N)rrr classmethodrr"rr r;r;r;r<rs  rZSETUPTOOLS_SYS_PATH_TECHNIQUErawZrewritecCs ttjtrtStjtjjS)z_ Return a regular expression based on first_line_re suitable for matching strings. )rrpatternr9recompilerar;r;r;r<_first_line_res rcCsd|tjtjgkr.tjdkr.t|tj||Stj\}}}t j ||d|dd||ffdS)Nrrrz %s %s) r>rrKrrdrS_IWRITErrrZreraise)funcargexcZetZevr}r;r;r< auto_chmods  rcCs.t|}t|tj|r"t|nt|dS)aa Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data from the original distribution. Any such finders need to be cleared since the replacement distribution might be packaged differently, e.g. a zipped egg distribution might get replaced with an unzipped egg folder or vice versa. Having the old finders cached may then cause Python to attempt loading modules from the replacement distribution using an incorrect loader. zipimport.zipimporter objects are Python loaders charged with importing data packaged inside zip archives. If stale loaders referencing the original distribution, are left behind, they can fail to load modules from the replacement distribution. E.g. if an old zipimport.zipimporter instance is used to load data from a new zipped egg archive, it may cause the operation to attempt to locate the requested data in the wrong location - one indicated by the original distribution's zip archive directory information. Such an operation may then fail outright, e.g. report having read a 'bad local file header', or even worse, it may fail silently & return invalid data. zipimport._zip_directory_cache contains cached zip archive directory information for all existing zipimport.zipimporter instances and all such instances connected to the same archive share the same cached directory information. If asked, and the underlying Python implementation allows it, we can fix all existing zipimport.zipimporter instances instead of having to track them down and remove them one by one, by updating their shared cached zip archive directory information. This, of course, assumes that the replacement distribution is packaged as a zipped egg. If not asked to fix existing zipimport.zipimporter instances, we still do our best to clear any remaining zipimport.zipimporter related cached data that might somehow later get used when attempting to load data from the new distribution and thus cause such load operations to fail. Note that when tracking down such remaining stale data, we can not catch every conceivable usage from here, and we clear only those that we know of and have found to cause problems if left alive. Any remaining caches should be updated by whomever is in charge of maintaining them, i.e. they should be ready to handle us replacing their zip archives with new distributions at runtime. N)r!_uncacherpath_importer_cache!_replace_zip_directory_cache_data*_remove_and_clear_zip_directory_cache_data)Z dist_pathrvnormalized_pathr;r;r<rys <  rycCsTg}t|}xB|D]:}t|}|j|r|||dtjdfkr|j|qW|S)ap Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any sub-path entries are included as well, i.e. those corresponding to zip archives embedded in other zip archives. rr)rr!rnr>rr)rcacheresultZ prefix_lenpZnpr;r;r<"_collect_zipimporter_cache_entriess   rcCsDx>t||D]0}||}||=|o*|||}|dk r |||<q WdS)a Update zipimporter cache data for a given normalized path. Any sub-path entries are processed as well, i.e. those corresponding to zip archives embedded in other zip archives. Given updater is a callable taking a cache entry key and the original entry (after already removing the entry from the cache), and expected to update the entry and possibly return a new one to be inserted in its place. Returning None indicates that the entry should not be replaced with a new one. If no updater is given, the cache entries are simply removed without any additional processing, the same as if the updater simply returned None. N)r)rrupdaterr old_entryZ new_entryr;r;r<_update_zipimporter_cache*s  r!cCst||dS)N)r!)rrr;r;r<rJsrcCsdd}t|tj|ddS)NcSs |jdS)N)clear)r?r r;r;r<2clear_and_remove_cached_zip_archive_directory_dataOszf_remove_and_clear_zip_directory_cache_data..clear_and_remove_cached_zip_archive_directory_data)r)r!rs_zip_directory_cache)rr#r;r;r<rNsrZ__pypy__cCsdd}t|tj|ddS)NcSs&|jtj||jtj||S)N)r"rsrtupdater$)r?r r;r;r<)replace_cached_zip_archive_directory_dataes zT_replace_zip_directory_cache_data..replace_cached_zip_archive_directory_data)r)r!rsr$)rr&r;r;r<rds rc Cs2yt||dWnttfk r(dSXdSdS)z%Is this string a valid Python script?execFTN)r SyntaxError TypeError)rOrr;r;r< is_pythonws r+cCsJy(tj|dd}|jd}WdQRXWnttfk r@|SX|dkS)zCDetermine if the specified executable is a .sh (contains a #! line)zlatin-1)rrNz#!)rrrrr)r&fpmagicr;r;r<is_shs r.cCs tj|gS)z@Quote a command line argument according to Windows parsing rules) subprocess list2cmdline)rr;r;r< nt_quote_argsr1cCsH|jds|jdrdSt||r&dS|jdrDd|jdjkSdS)zMIs this text, as a whole, a Python script? (as opposed to shell/bat/etc. z.pyz.pywTz#!rrF)rDr+rn splitlinesr')r_rr;r;r<r\s  r\)rdcGsdS)Nr;)rr;r;r<_chmodsr3cCsRtjd||yt||Wn0tjk rL}ztjd|WYdd}~XnXdS)Nzchanging mode of %s to %ozchmod failed: %s)r rr3r>error)r?rer|r;r;r<rds rdc@seZdZdZgZeZeddZeddZ eddZ edd Z ed d Z d d Z eddZddZeddZeddZdS) CommandSpeczm A command spec for a #! header, specified as a list of arguments akin to those passed to Popen. cCs|S)zV Choose the best CommandSpec class based on environmental conditions. r;)r r;r;r<rYszCommandSpec.bestcCstjjtj}tjjd|S)N__PYVENV_LAUNCHER__)r>r?rBrr&rr)r Z_defaultr;r;r<_sys_executableszCommandSpec._sys_executablecCs:t||r|St|tr ||S|dkr0|jS|j|S)zg Construct a CommandSpec from a parameter to build_scripts, which may be None. N)rrfrom_environment from_string)r Zparamr;r;r< from_params  zCommandSpec.from_paramcCs||jgS)N)r7)r r;r;r<r8szCommandSpec.from_environmentcCstj|f|j}||S)z} Construct a command spec from a simple string representing a command line parseable by shlex.split. )shlexr split_args)r stringrr;r;r<r9szCommandSpec.from_stringcCs8tj|j||_tj|}t|s4dg|jdd<dS)Nz-xr)r;r_extract_optionsoptionsr/r0rH)rr_cmdliner;r;r<install_optionss zCommandSpec.install_optionscCs:|djd}tj|}|r.|jdp0dnd}|jS)zH Extract any options from the first line of the script. rJrrr)r2rmatchgrouprM)Z orig_scriptfirstrBr?r;r;r<r>s zCommandSpec._extract_optionscCs|j|t|jS)N)_renderrr?)rr;r;r< as_headerszCommandSpec.as_headercCs6d}x,|D]$}|j|r |j|r |ddSq W|S)Nz"'rr)rnrD)itemZ_QUOTESqr;r;r< _strip_quotess  zCommandSpec._strip_quotescCs tjdd|D}d|dS)Ncss|]}tj|jVqdS)N)r5rIrM)rrGr;r;r<rsz&CommandSpec._render..z#!rJ)r/r0)rr@r;r;r<rEszCommandSpec._renderN)rrrrr?rr<r rYr7r:r8r9rArr>rFrIrEr;r;r;r<r5s       r5c@seZdZeddZdS)WindowsCommandSpecF)rN)rrrrr<r;r;r;r<rJsrJc@seZdZdZejdjZeZ e dddZ e dddZ e dd d Z ed d Ze d dZe ddZe ddZe dddZdS)rXz` Encapsulates behavior around writing entry point scripts for console and gui apps. a # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r __requires__ = %(spec)r import re import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit( load_entry_point(%(spec)r, %(group)r, %(name)r)() ) NFcCs6tjdt|rtntj}|jd||}|j||S)Nz Use get_argsr)warningsrDeprecationWarningWindowsScriptWriterrXrYget_script_headerrZ)r rr&wininstwriterheaderr;r;r<get_script_argss zScriptWriter.get_script_argscCs6tjdt|rd}|jjj|}|j||jS)NzUse get_headerz python.exe)rKrrLcommand_spec_classrYr:rArF)r r_r&rOcmdr;r;r<rN's   zScriptWriter.get_script_headerc cs|dkr|j}t|j}xjdD]b}|d}xT|j|jD]B\}}|j||jt}|j||||} x| D] } | VqrWq>Wq"WdS)z Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. NconsoleguiZ_scripts)rUrV) r^r9rNZ get_entry_mapr_ensure_safe_namerr_get_script_args) r rrQrtype_rCrZepr_rrr;r;r<rZ1s     zScriptWriter.get_argscCstjd|}|rtddS)z? Prevent paths in *_scripts entry point names. z[\\/]z+Path separators not allowed in script namesN)rsearchr)rZ has_path_sepr;r;r<rWCs zScriptWriter._ensure_safe_namecCs tjdt|rtjS|jS)NzUse best)rKrrLrMrY)r Z force_windowsr;r;r< get_writerLs zScriptWriter.get_writercCs.tjdkstjdkr&tjdkr&tjS|SdS)zD Select the best ScriptWriter for this environment. win32javarN)rr{r>r_namerMrY)r r;r;r<rYRszScriptWriter.bestccs|||fVdS)Nr;)r rYrrQr_r;r;r<rX\szScriptWriter._get_script_argsrcCs"|jjj|}|j||jS)z;Create a #! line, getting options (if any) from script_text)rSrYr:rArF)r r_r&rTr;r;r<r^as zScriptWriter.get_header)NF)NF)N)rN)rrrrrKrLrrr5rSr rRrNrZrrWr[rYrXr^r;r;r;r<rX s       rXc@sLeZdZeZeddZeddZeddZeddZ e d d Z d S) rMcCstjdt|jS)NzUse best)rKrrLrY)r r;r;r<r[ls zWindowsScriptWriter.get_writercCs"tt|d}tjjdd}||S)zC Select the best ScriptWriter suitable for Windows )r&ZnaturalZSETUPTOOLS_LAUNCHERr&)rWindowsExecutableLauncherWriterr>rr)r Z writer_lookupZlauncherr;r;r<rYrs zWindowsScriptWriter.bestc #stddd|}|tjdjjdkrBdjft}tj|t dddd d dd g}|j ||j ||}fd d |D}|||d|fVdS)z For Windows, add a .py extensionz.pyaz.pyw)rUrVZPATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.z.pyz -script.pyz.pycz.pyoz.execsg|] }|qSr;r;)rrb)rr;r<rsz8WindowsScriptWriter._get_script_args..rbN) rr>rr'rrrrKr UserWarningrK_adjust_header) r rYrrQr_extrrrr;)rr<rXs   z$WindowsScriptWriter._get_script_argscCsNd}d}|dkr||}}tjtj|tj}|j||d}|j|rJ|S|S)z Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is). z pythonw.exez python.exerV)r=repl)rrescape IGNORECASEsub _use_header)r rYZ orig_headerr rdZ pattern_ob new_headerr;r;r<rbs z"WindowsScriptWriter._adjust_headercCs$|ddjd}tjdkp"t|S)z Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system. rr"r\r)rMrr{r)riZ clean_headerr;r;r<rhs zWindowsScriptWriter._use_headerN) rrrrJrSr r[rYrXrbrrhr;r;r;r<rMis    rMc@seZdZeddZdS)r_c #s|dkrd}d}dg}nd}d}dddg}|j||}fd d |D} |||d | fVd t|d fVtsd} | td fVdS)zG For Windows, add a .py extension and an .exe launcher rVz -script.pywz.pywZcliz -script.pyz.pyz.pycz.pyocsg|] }|qSr;r;)rrb)rr;r<rszDWindowsExecutableLauncherWriter._get_script_args..rbz.exernz .exe.manifestN)rbget_win_launcherr=load_launcher_manifest) r rYrrQr_Z launcher_typercrZhdrrZm_namer;)rr<rXs   z0WindowsExecutableLauncherWriter._get_script_argsN)rrrr rXr;r;r;r<r_sr_cCs2d|}tr|jdd}n |jdd}td|S)z Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. z%s.exe.z-64.z-32.r)r=rNr")typeZ launcher_fnr;r;r<rks  rkcCs0tjtd}tjr|tS|jdtSdS)Nzlauncher manifest.xmlzutf-8)r$r"rrPY2varsra)rZmanifestr;r;r<rls  rlFcCstj|||S)N)rQr)r? ignore_errorsonerrorr;r;r<rsrcCstjd}tj||S)N)r>umask)Ztmpr;r;r<rcs  rccCs:ddl}tjj|jd}|tjd<tjj|tdS)Nr) rr>r?r#__path__rargvrr5)rZargv0r;r;r< bootstraps   rwc sddlm}ddlmGfddd}|dkrBtjdd}t0|fddd g|tjdpfd|d |WdQRXdS) Nr)setup)r(cseZdZdZfddZdS)z-main..DistributionWithoutHelpCommandsrc s(tj|f||WdQRXdS)N) _patch_usage _show_help)rrkw)r(r;r<rz sz8main..DistributionWithoutHelpCommands._show_helpN)rrrZ common_usagerzr;)r(r;r<DistributionWithoutHelpCommandssr|rz-qr2z-v)Z script_argsr-Z distclass)rrxZsetuptools.distr(rrvry)rvr{rxr|r;)r(r<r5s    c #sLddl}tjdjfdd}|jj}||j_z dVWd||j_XdS)Nrze usage: %(script)s [options] requirement_or_url ... or: %(script)s --help csttjj|dS)N)Zscript)rr>r?r))r-)USAGEr;r< gen_usage sz_patch_usage..gen_usage)Zdistutils.corerKrLrZcorer~)rr~Zsavedr;)r}r<ry s   ry)N)r')N)rrrrrrZdistutils.errorsrrrr Zdistutils.command.installr r rr r Zdistutils.command.build_scriptsrr(rrr>rsrQr6rrrr rKrKrr9rr/r;rZsetuptools.externrZsetuptools.extern.six.movesrrrrZsetuptools.sandboxrZsetuptools.py31compatrrZsetuptools.py27compatrZsetuptools.commandrZsetuptools.archive_utilrZsetuptools.package_indexrrrrrZsetuptools.wheelrr$r r!r"r#r$r%r&r'r(r)r*r+r,r-r.Zpkg_resources.py31compatfilterwarningsZ PEP440Warning__all__r=r1rorErHr"r2rrrr4r6r3rrrrrryrr!rrbuiltin_module_namesrr+r.r1r\rdr3 ImportErrorrr5r7Zsys_executablerJobjectrXrMr_rRrNrkrlrrcrwr5rryr;r;r;r< s           D |A))'l R    T`A  __pycache__/register.cpython-36.pyc000064400000001005147210141470013223 0ustar003 K]@s"ddljjZGdddejZdS)Nc@seZdZejjZddZdS)registercCs|jdtjj|dS)NZegg_info)Z run_commandorigrrun)selfr/usr/lib/python3.6/register.pyrs z register.runN)__name__ __module__ __qualname__rr__doc__rrrrrrsr)Zdistutils.command.registerZcommandrrrrrrs __pycache__/develop.cpython-36.opt-1.pyc000064400000014316147210141470014005 0ustar003 K]n@sddlmZddlmZddlmZmZddlZddlZddl Z ddl m Z ddl m Z mZmZddlmZddlmZddlZGd d d ejeZGd d d eZdS) ) convert_path)log)DistutilsErrorDistutilsOptionErrorN)six) Distribution PathMetadatanormalize_path) easy_install) namespacesc@sveZdZdZdZejddgZejdgZd Zd d Z d d Z ddZ e ddZ ddZddZddZddZdS)developzSet up package for developmentz%install package in 'development mode' uninstalluUninstall this source package egg-path=N-Set the path to be used in the .egg-link fileFcCs2|jrd|_|j|jn|j|jdS)NT)r Z multi_versionuninstall_linkZuninstall_namespacesinstall_for_developmentZwarn_deprecated_options)selfr/usr/lib/python3.6/develop.pyruns  z develop.runcCs&d|_d|_tj|d|_d|_dS)N.)r egg_pathr initialize_options setup_pathZalways_copy_from)rrrrr's  zdevelop.initialize_optionscCs|jd}|jr,d}|j|jf}t|||jg|_tj||j|j |j j t j d|jd}t jj|j||_|j|_|jdkrt jj|j|_t|j}tt jj|j|j}||krtd|t|t|t jj|j|jd|_|j|j|j|j|_dS)Negg_infoz-Please rename %r to %r before using 'develop'z*.eggz .egg-linkzA--egg-path must be a relative path from the install directory to ) project_name)get_finalized_commandZbroken_egg_inforrZegg_nameargsr finalize_optionsZexpand_basedirsZ expand_dirsZ package_indexscanglobospathjoin install_diregg_linkegg_baserabspathr rrrdist_resolve_setup_pathr)rZeitemplaterZ egg_link_fntargetrrrrr .s<           zdevelop.finalize_optionscCsh|jtjdjd}|tjkr0d|jdd}ttjj|||}|ttjkrdt d|ttj|S)z Generate a path from egg_base back to '.' where the setup script resides and ensure that path points to the setup path from $install_dir/$egg_path. /z../zGCan't get a consistent path to setup script from installation directory) replacer#seprstripcurdircountr r$r%r)r(r&rZ path_to_setupZresolvedrrrr+Xs zdevelop._resolve_setup_pathc CsDtjrt|jddr|jddd|jd|jd}t|j}|jd|d|jd|jddd|jd|jd}||_ ||j _ t ||j |j _n"|jd|jdd d|jd|jtjr|jtjdt_|jtjd |j|j|js,t|jd }|j|j d |jWdQRX|jd|j |j dS) NZuse_2to3FZbuild_pyr)Zinplacer)r(Z build_extr/zCreating %s (link to %s)w )rZPY3getattr distributionZreinitialize_commandZ run_commandrr Z build_librr*locationrrZ _providerZinstall_site_py setuptoolsZbootstrap_install_fromr Zinstall_namespacesrinfor'r(dry_runopenwriterZprocess_distributionZno_deps)rZbpy_cmdZ build_pathZei_cmdfrrrrks4          zdevelop.install_for_developmentcCstjj|jrztjd|j|jt|j}dd|D}|j||j g|j |j gfkrhtj d|dS|j sztj |j|j s|j|j|jjrtj ddS)NzRemoving %s (link to %s)cSsg|] }|jqSr)r2).0linerrr sz*develop.uninstall_link..z$Link points to %s: uninstall abortedz5Note: you must uninstall or replace scripts manually!)r#r$existsr'rr;r(r=closerrwarnr<unlinkZ update_pthr*r8scripts)rZ egg_link_filecontentsrrrrs    zdevelop.uninstall_linkc Cs||jk rtj||S|j|x^|jjp,gD]N}tjjt |}tjj |}t j |}|j }WdQRX|j||||q.WdS)N)r*r install_egg_scriptsinstall_wrapper_scriptsr8rGr#r$r)rbasenameior=readZinstall_script)rr*Z script_nameZ script_pathZstrmZ script_textrrrrIs     zdevelop.install_egg_scriptscCst|}tj||S)N)VersionlessRequirementr rJ)rr*rrrrJszdevelop.install_wrapper_scripts)r rr)rNr)__name__ __module__ __qualname____doc__ descriptionr Z user_optionsZboolean_optionsZcommand_consumes_argumentsrrr staticmethodr+rrrIrJrrrrr s  * /r c@s(eZdZdZddZddZddZdS) rNaz Adapt a pkg_resources.Distribution to simply return the project name as the 'requirement' so that scripts will work across multiple versions. >>> dist = Distribution(project_name='foo', version='1.0') >>> str(dist.as_requirement()) 'foo==1.0' >>> adapted_dist = VersionlessRequirement(dist) >>> str(adapted_dist.as_requirement()) 'foo' cCs ||_dS)N)_VersionlessRequirement__dist)rr*rrr__init__szVersionlessRequirement.__init__cCs t|j|S)N)r7rU)rnamerrr __getattr__sz"VersionlessRequirement.__getattr__cCs|jS)N)r)rrrras_requirementsz%VersionlessRequirement.as_requirementN)rOrPrQrRrVrXrYrrrrrNs rN)Zdistutils.utilrZ distutilsrZdistutils.errorsrrr#r"rLZsetuptools.externrZ pkg_resourcesrrr Zsetuptools.command.easy_installr r:r ZDevelopInstallerr objectrNrrrrs     4__pycache__/upload.cpython-36.opt-1.pyc000064400000002443147210141470013631 0ustar003 K]@s*ddlZddlmZGdddejZdS)N)uploadc@s(eZdZdZddZddZddZdS) rza Override default upload behavior to obtain password in a variety of different ways. cCs8tjj||jptj|_|jp0|jp0|j|_dS)N) origrfinalize_optionsusernamegetpassZgetuserZpassword_load_password_from_keyring_prompt_for_password)selfr /usr/lib/python3.6/upload.pyr s   zupload.finalize_optionsc Cs2ytd}|j|j|jStk r,YnXdS)zM Attempt to load password from keyring. Suppress Exceptions. keyringN) __import__Z get_passwordZ repositoryr Exception)r r r r r rs z"upload._load_password_from_keyringc Cs&ytjSttfk r YnXdS)zH Prompt for a password on the tty. Suppress Exceptions. N)rrKeyboardInterrupt)r r r r r#szupload._prompt_for_passwordN)__name__ __module__ __qualname____doc__rrrr r r r rs r)rZdistutils.commandrrr r r r s __pycache__/build_py.cpython-36.opt-1.pyc000064400000020460147210141470014153 0ustar003 K]|% @sddlmZddlmZddljjZddlZddlZddl Z ddl Z ddl Z ddl Z ddlmZddlmZmZmZyddlmZWn"ek rGdddZYnXGd d d ejeZdd d Zd dZdS))glob) convert_pathN)six)mapfilter filterfalse) Mixin2to3c@seZdZdddZdS)rTcCsdS)z do nothingN)selffilesZdoctestsr r /usr/lib/python3.6/build_py.pyrun_2to3szMixin2to3.run_2to3N)T)__name__ __module__ __qualname__r r r r r rsrc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZeddZd S)!build_pyaXEnhanced 'build_py' command that includes data files with packages The data files are specified via a 'package_data' argument to 'setup()'. See 'setuptools.dist.Distribution' for more details. Also, this version of the 'build_py' command allows you to specify both 'py_modules' and 'packages' in the same setup operation. cCsFtjj||jj|_|jjp i|_d|jkr6|jd=g|_g|_dS)N data_files) origrfinalize_options distribution package_dataexclude_package_data__dict___build_py__updated_files_build_py__doctests_2to3)r r r r r!s   zbuild_py.finalize_optionscCs||j r|j rdS|jr"|j|jr8|j|j|j|jd|j|jd|j|jd|jt j j |dddS)z?Build modules, packages, and copy data files to build directoryNFTr)Zinclude_bytecode) Z py_modulespackagesZ build_modulesZbuild_packagesbuild_package_datar rrZ byte_compilerrZ get_outputs)r r r r run+sz build_py.runcCs&|dkr|j|_|jStjj||S)zlazily compute data filesr)_get_data_filesrrr __getattr__)r attrr r r r?s zbuild_py.__getattr__cCsJtjrt|tjr|jd}tjj||||\}}|rB|jj |||fS)N.) rZPY2 isinstanceZ string_typessplitrr build_modulerappend)r moduleZ module_filepackageZoutfilecopiedr r r r$Fs    zbuild_py.build_modulecCs|jtt|j|jpfS)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples)analyze_manifestlistr_get_pkg_data_filesr)r r r r rPszbuild_py._get_data_filescsJ|j|tjj|jg|jd}fdd|j|D}|||fS)Nr!csg|]}tjj|qSr )ospathrelpath).0file)src_dirr r ^sz0build_py._get_pkg_data_files..)get_package_dirr,r-joinZ build_libr#find_data_files)r r' build_dir filenamesr )r1r r+Us   zbuild_py._get_pkg_data_filescCsX|j|j||}tt|}tjj|}ttj j |}tj|j j |g|}|j |||S)z6Return filenames for package's data files in 'src_dir')_get_platform_patternsrrr itertoolschain from_iterablerr,r-isfilemanifest_filesgetexclude_data_files)r r'r1patternsZglobs_expandedZ globs_matchesZ glob_filesr r r r r5cs   zbuild_py.find_data_filesc Csx|jD]\}}}}xr|D]j}tjj||}|jtjj|tjj||}|j||\}} tjj|}| r||jj kr|j j |qWqWdS)z$Copy data files into build directoryN) rr,r-r4ZmkpathdirnameZ copy_fileabspathrZconvert_2to3_doctestsrr%) r r'r1r6r7filenametargetZsrcfileZoutfr(r r r rts   zbuild_py.build_package_datac Csi|_}|jjsdSi}x$|jp$fD]}||t|j|<q&W|jd|jd}x|jj D]}t j j t|\}}d}|} x:|r||kr||kr|}t j j |\}} t j j | |}qW||kr^|jdr|| krq^|j||gj|q^WdS)NZegg_infoz.py)r=rZinclude_package_datarassert_relativer3Z run_commandZget_finalized_commandZfilelistr r,r-r#r4endswith setdefaultr%) r ZmfZsrc_dirsr'Zei_cmdr-dfprevZoldfZdfr r r r)s(   zbuild_py.analyze_manifestcCsdS)Nr )r r r r get_data_filesszbuild_py.get_data_filescCsy |j|Stk rYnXtjj|||}||j|<| sJ|jj rN|Sx,|jjD]}||ksr|j|drXPqXW|Stj |d}|j }WdQRXd|krt j j d|f|S)z8Check namespace packages' __init__ for declare_namespacer!rbNsdeclare_namespacezNamespace package problem: %s is a namespace package, but its __init__.py does not call declare_namespace()! Please fix it. (See the setuptools manual under "Namespace Packages" for details.) ")packages_checkedKeyErrorrr check_packagerZnamespace_packages startswithioopenread distutilserrorsZDistutilsError)r r'Z package_dirZinit_pyZpkgrIcontentsr r r rOs&   zbuild_py.check_packagecCsi|_tjj|dS)N)rMrrinitialize_options)r r r r rWszbuild_py.initialize_optionscCs0tjj||}|jjdk r,tjj|jj|S|S)N)rrr3rZsrc_rootr,r-r4)r r'resr r r r3s zbuild_py.get_package_dircs\t|j|j||}fdd|D}tjj|}t|fddD}tt|S)z6Filter filenames for package's data files in 'src_dir'c3s|]}tj|VqdS)N)fnmatchr)r/pattern)r r r sz.build_py.exclude_data_files..c3s|]}|kr|VqdS)Nr )r/fn)badr r r[s)r*r8rr9r:r;set_unique_everseen)r r'r1r r@Z match_groupsZmatchesZkeepersr )r]r r r?s   zbuild_py.exclude_data_filescs.tj|jdg|j|g}fdd|DS)z yield platform-specific path patterns (suitable for glob or fn_match) from a glob-based spec (such as self.package_data or self.exclude_package_data) matching package in src_dir. c3s |]}tjjt|VqdS)N)r,r-r4r)r/rZ)r1r r r[sz2build_py._get_platform_patterns..)r9r:r>)specr'r1Z raw_patternsr )r1r r8s   zbuild_py._get_platform_patternsN)rrr__doc__rrrr$rr+r5rr)rKrOrWr3r? staticmethodr8r r r r rs    rccsjt}|j}|dkr:xPt|j|D]}|||Vq"Wn,x*|D]"}||}||kr@|||Vq@WdS)zHList unique elements, preserving order. Remember all elements ever seen.N)r^addr __contains__)iterablekeyseenZseen_addelementkr r r r_s  r_cCs:tjj|s|Sddlm}tjdj|}||dS)Nr)DistutilsSetupErrorz Error: setup script specifies an absolute path: %s setup() arguments must *always* be /-separated paths relative to the setup.py directory, *never* absolute paths. )r,r-isabsdistutils.errorsrktextwrapdedentlstrip)r-rkmsgr r r rEs   rE)N)rZdistutils.utilrZdistutils.command.build_pyZcommandrrr,rYrnrQrmrTr9Zsetuptools.externrZsetuptools.extern.six.movesrrrZsetuptools.lib2to3_exr ImportErrorr_rEr r r r s$    Y __pycache__/egg_info.cpython-36.opt-1.pyc000064400000050633147210141470014126 0ustar003 K]`@sdZddlmZddlmZddlmZddlm Z ddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'j(Z(ddl)m*Z*ddlm+Z+ddZ,GdddeZ-GdddeZGdddeZ.ddZ/ddZ0ddZ1dd Z2d!d"Z3d#d$Z4d%d&Z5d'd(Z6d0d*d+Z7d,d-Z8d.d/Z9dS)1zUsetuptools.command.egg_info Create a distribution's .egg-info directory and contents)FileList)DistutilsInternalError) convert_path)logN)six)map)Command)sdist) walk_revctrl) edit_config) bdist_egg)parse_requirements safe_name parse_version safe_version yield_lines EntryPointiter_entry_points to_filename)glob) packagingcCsd}|jtjj}tjtj}d|f}xt|D]\}}|t|dk}|dkrv|rd|d7}q4|d||f7}q4d}t|} x:|| kr||} | dkr||d7}n| d kr||7}n| d kr|d} | | kr|| d kr| d} | | kr|| d kr| d} x&| | kr6|| d kr6| d} qW| | krR|tj| 7}nR||d| } d} | dd krd } | dd} | tj| 7} |d| f7}| }n|tj| 7}|d7}qW|s4||7}q4W|d7}tj|tj tj BdS)z Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories. z[^%s]z**z.*z (?:%s+%s)*r*?[!]^Nz[%s]z\Z)flags) splitospathsepreescape enumeratelencompile MULTILINEDOTALL)rZpatZchunksr#Z valid_charcchunkZ last_chunkiZ chunk_lencharZinner_iinnerZ char_classr0/usr/lib/python3.6/egg_info.pytranslate_pattern$sV         r2c@seZdZdZd)d*d+d,gZdgZd diZddZeddZ e j ddZ ddZ ddZ d-ddZ ddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(S).egg_infoz+create a distribution's .egg-info directory egg-base=eLdirectory containing .egg-info directories (default: top of the source tree)tag-dated0Add date stamp (e.g. 20050528) to version number tag-build=b-Specify explicit tag to add to version numberno-dateD"Don't include date stamp [default]cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)NrF)egg_name egg_versionegg_baser3 tag_buildtag_datebroken_egg_infovtags)selfr0r0r1initialize_optionsszegg_info.initialize_optionscCsdS)Nr0)rGr0r0r1tag_svn_revisionszegg_info.tag_svn_revisioncCsdS)Nr0)rGvaluer0r0r1rIscCs0tj}|j|d<d|d<t|t|ddS)z Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. rCrrD)r3N) collections OrderedDicttagsr dict)rGfilenamer3r0r0r1save_version_infos zegg_info.save_version_infoc CsVt|jj|_|j|_|j|_t|j}y6t |t j j }|rFdnd}t t||j|jfWn,tk rtjjd|j|jfYnX|jdkr|jj}|pijdtj|_|jdt|jd|_|jtjkrtjj|j|j|_d|jkr|j|j|jj_ |jj}|dk rR|j |jj!krR|j|_"t|j|_#d|j_dS)Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrBz .egg-info-)$r distributionZget_namer@rMrFtagged_versionrAr isinstancerversionZVersionlistr ValueError distutilserrorsZDistutilsOptionErrorrBZ package_dirgetr!curdirZensure_dirnamerr3r"joincheck_broken_egg_infometadataZ _patched_distkeylowerZ_versionZ_parsed_version)rGZparsed_versionZ is_versionspecdirsZpdr0r0r1finalize_optionss8          zegg_info.finalize_optionsFcCsN|r|j|||n6tjj|rJ|dkr@| r@tjd||dS|j|dS)aWrite `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data` is ``None``, then this is a no-op unless `filename` exists, in which case a warning is issued about the orphaned file (if `force` is false), or deleted (if `force` is true). Nz$%s not set in setup(), but %s exists) write_filer!r"existsrwarn delete_file)rGwhatrOdataforcer0r0r1write_or_delete_files   zegg_info.write_or_delete_filecCsDtjd||tjr|jd}|js@t|d}|j||jdS)zWrite `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file. zwriting %s to %szutf-8wbN) rinforZPY3encodedry_runopenwriteclose)rGrhrOrifr0r0r1rds   zegg_info.write_filecCs tjd||jstj|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrmror!unlink)rGrOr0r0r1rgs zegg_info.delete_filecCs2|jj}|jr$|j|jr$t|St||jS)N)rRZ get_versionrFendswithr)rGrUr0r0r1rSs zegg_info.tagged_versioncCs|j|j|jj}x@tdD]4}|j|d|j}|||jtj j |j|jqWtj j |jd}tj j |r||j ||j dS)Nzegg_info.writers) installerznative_libs.txt)Zmkpathr3rRZfetch_build_eggrZrequireZresolvenamer!r"r\rerg find_sources)rGrvepwriternlr0r0r1run s     z egg_info.runcCs,d}|jr||j7}|jr(|tjd7}|S)Nrz-%Y%m%d)rCrDtimeZstrftime)rGrUr0r0r1rMs  z egg_info.tagscCs4tjj|jd}t|j}||_|j|j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r!r"r\r3manifest_makerrRmanifestr|filelist)rGZmanifest_filenameZmmr0r0r1rx s  zegg_info.find_sourcescCsd|jd}|jtjkr&tjj|j|}tjj|r`tjddddd||j |j |_ ||_ dS)Nz .egg-inforQNz Note: Your current .egg-info directory has a '-' in its name; this will not work correctly with "setup.py develop". Please rename %s to %s to correct this problem. ) r@rBr!r[r"r\rerrfr3rE)rGZbeir0r0r1r](s    zegg_info.check_broken_egg_infoN)r4r5r6)r7r8r9)r:r;r<)r=r>r?)F)__name__ __module__ __qualname__ descriptionZ user_optionsZboolean_optionsZ negative_optrHpropertyrIsetterrPrcrkrdrgrSr|rMrxr]r0r0r0r1r3ws(  / r3c@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)rcCs<|j|\}}}}|dkrV|jddj|x"|D]}|j|s4tjd|q4Wn|dkr|jddj|x"|D]}|j|sxtjd|qxWn|dkr|jd dj|x"|D]}|j|stjd |qWnZ|d kr(|jd dj|x&|D]}|j|stjd |qWn|dkrx|jd|dj|fx|D]"}|j ||sPtjd||qPWn|dkr|jd|dj|fx|D]"}|j ||stjd||qWnp|dkr|jd||j |s8tjd|n>|dkr,|jd||j |s8tjd|n t d|dS)Nincludezinclude  z%warning: no files found matching '%s'excludezexclude z9warning: no previously-included files found matching '%s'zglobal-includezglobal-include z>warning: no files found matching '%s' anywhere in distributionzglobal-excludezglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionzrecursive-includezrecursive-include %s %sz:warning: no files found matching '%s' under directory '%s'zrecursive-excludezrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'graftzgraft z+warning: no directories found matching '%s'prunezprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')Z_parse_template_line debug_printr\rrrfrglobal_includeglobal_excluderecursive_includerecursive_excluderrr)rGlineactionZpatternsdirZ dir_patternpatternr0r0r1process_template_line;sd                 zFileList.process_template_linecCsVd}xLtt|jdddD]2}||j|r|jd|j||j|=d}qW|S)z Remove all files from the file list that match the predicate. Return True if any matching files were removed Frz removing Tr)ranger'filesr)rGZ predicatefoundr-r0r0r1 _remove_filesszFileList._remove_filescCs$ddt|D}|j|t|S)z#Include files that match 'pattern'.cSsg|]}tjj|s|qSr0)r!r"isdir).0rsr0r0r1 sz$FileList.include..)rextendbool)rGrrr0r0r1rs zFileList.includecCst|}|j|jS)z#Exclude files that match 'pattern'.)r2rmatch)rGrrr0r0r1rszFileList.excludecCs8tjj|d|}ddt|ddD}|j|t|S)zN Include all files anywhere in 'dir/' that match the pattern. z**cSsg|]}tjj|s|qSr0)r!r"r)rrsr0r0r1rsz.FileList.recursive_include..T) recursive)r!r"r\rrr)rGrrZ full_patternrr0r0r1rs zFileList.recursive_includecCs ttjj|d|}|j|jS)zM Exclude any file anywhere in 'dir/' that match the pattern. z**)r2r!r"r\rr)rGrrrr0r0r1rszFileList.recursive_excludecCs$ddt|D}|j|t|S)zInclude all files from 'dir/'.cSs"g|]}tjj|D]}|qqSr0)rXrfindall)rZ match_diritemr0r0r1rsz"FileList.graft..)rrr)rGrrr0r0r1rs  zFileList.graftcCsttjj|d}|j|jS)zFilter out files from 'dir/'.z**)r2r!r"r\rr)rGrrr0r0r1rszFileList.prunecsJ|jdkr|jttjjd|fdd|jD}|j|t|S)z Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. Nz**csg|]}j|r|qSr0)r)rrs)rr0r1rsz+FileList.global_include..)Zallfilesrr2r!r"r\rr)rGrrr0)rr1rs   zFileList.global_includecCsttjjd|}|j|jS)zD Exclude all files anywhere that match the pattern. z**)r2r!r"r\rr)rGrrr0r0r1rszFileList.global_excludecCs8|jdr|dd}t|}|j|r4|jj|dS)N rr)rur _safe_pathrappend)rGrr"r0r0r1rs    zFileList.appendcCs|jjt|j|dS)N)rrfilterr)rGpathsr0r0r1rszFileList.extendcCstt|j|j|_dS)z Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths. N)rVrrr)rGr0r0r1_repairszFileList._repairc Csd}tj|}|dkr(tjd|dStj|d}|dkrNtj||ddSy tjj|shtjj|rldSWn&tk rtj||t j YnXdS)Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFzutf-8T) unicode_utilsfilesys_decoderrfZ try_encoder!r"reUnicodeEncodeErrorsysgetfilesystemencoding)rGr"Zenc_warnZu_pathZ utf8_pathr0r0r1rs  zFileList._safe_pathN)rrrrrrrrrrrrrrrrrr0r0r0r1r8sI     rc@s\eZdZdZddZddZddZdd Zd d Zd d Z e ddZ ddZ ddZ dS)r~z MANIFEST.incCsd|_d|_d|_d|_dS)Nr)Z use_defaultsrZ manifest_onlyZforce_manifest)rGr0r0r1rHsz!manifest_maker.initialize_optionscCsdS)Nr0)rGr0r0r1rcszmanifest_maker.finalize_optionscCsdt|_tjj|js|j|jtjj|jr<|j |j |jj |jj |jdS)N) rrr!r"rerwrite_manifest add_defaultstemplateZ read_templateprune_file_listsortZremove_duplicates)rGr0r0r1r|s  zmanifest_maker.runcCstj|}|jtjdS)N/)rrreplacer!r#)rGr"r0r0r1_manifest_normalizes z"manifest_maker._manifest_normalizecsBjjfddjjD}dj}jtj|f|dS)zo Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. csg|]}j|qSr0)r)rrs)rGr0r1r sz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrZexecuterd)rGrmsgr0)rGr1rs  zmanifest_maker.write_manifestcCs|j|stj||dS)N)_should_suppress_warningr rf)rGrr0r0r1rf$s zmanifest_maker.warncCs tjd|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r$r)rr0r0r1r(sz'manifest_maker._should_suppress_warningcCsttj||jj|j|jj|jtt}|rB|jj|nt j j |jrX|j |j d}|jj|jdS)Nr3)r rrrrrrVr rr!r"reZ read_manifestget_finalized_commandrr3)rGZrcfilesZei_cmdr0r0r1r/s   zmanifest_maker.add_defaultscCsZ|jd}|jj}|jj|j|jj|tjtj }|jj d|d|dddS)Nbuildz(^|z)(RCS|CVS|\.svn)r)Zis_regex) rrRZ get_fullnamerrZ build_baser$r%r!r#Zexclude_pattern)rGrZbase_dirr#r0r0r1r;s    zmanifest_maker.prune_file_listN)rrrrrHrcr|rrrf staticmethodrrrr0r0r0r1r~s    r~c Cs8dj|}|jd}t|d}|j|WdQRXdS)z{Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.  zutf-8rlN)r\rnrprq)rOcontentsrsr0r0r1rdEs   rdc Cs|tjd||jsx|jj}|j|j|_}|j|j|_}z|j |j Wd|||_|_Xt |jdd}t j |j |dS)Nz writing %sZzip_safe)rrmrorRr^rArUr@rwwrite_pkg_infor3getattrr Zwrite_safety_flag)cmdbasenamerOr^ZoldverZoldnameZsafer0r0r1rRs rcCstjj|rtjddS)NzsWARNING: 'depends.txt' is not used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)r!r"rerrf)rrrOr0r0r1warn_depends_obsoletees rcCs,t|pf}dd}t||}|j|dS)NcSs|dS)Nrr0)rr0r0r1osz%_write_requirements..)rr writelines)streamZreqslinesZ append_crr0r0r1_write_requirementsms  rcCsn|j}tj}t||j|jp"i}x2t|D]&}|jdjft t|||q.W|j d||j dS)Nz [{extra}] Z requirements) rRrStringIOrZinstall_requiresextras_requiresortedrqformatvarsrkgetvalue)rrrOZdistrirZextrar0r0r1write_requirementsts  rcCs,tj}t||jj|jd||jdS)Nzsetup-requirements)iorrrRZsetup_requiresrkr)rrrOrir0r0r1write_setup_requirementssrcCs:tjdd|jjD}|jd|djt|ddS)NcSsg|]}|jdddqS).rr)r )rkr0r0r1rsz(write_toplevel_names..ztop-level namesr)rNfromkeysrRZiter_distribution_namesrdr\r)rrrOZpkgsr0r0r1write_toplevel_namessrcCst|||ddS)NT) write_arg)rrrOr0r0r1 overwrite_argsrFcCsHtjj|d}t|j|d}|dk r4dj|d}|j||||dS)Nrr)r!r"splitextrrRr\rk)rrrOrjZargnamerJr0r0r1rs rcCs|jj}t|tjs|dkr"|}nr|dk rg}xZt|jD]J\}}t|tjsttj||}dj tt t |j }|j d||fqsR           (   SBEI    __pycache__/install.cpython-36.opt-1.pyc000064400000007471147210141470014021 0ustar003 K]K@svddlmZddlZddlZddlZddlZddljjZ ddl Z e jZ Gddde jZdde jj Dej e_ dS))DistutilsArgErrorNc@seZdZdZejjddgZejjddgZddd fd d d fgZe eZ d d Z ddZ ddZ ddZeddZddZdS)installz7Use easy_install to install the package, w/dependenciesold-and-unmanageableNTry not to use this!!single-version-externally-managed5used by system package builders to create 'flat' eggsZinstall_egg_infocCsdS)NT)selfrr/usr/lib/python3.6/install.pyszinstall.Zinstall_scriptscCsdS)NTr)r rrr r scCstjj|d|_d|_dS)N)origrinitialize_optionsold_and_unmanageable!single_version_externally_managed)r rrr r s zinstall.initialize_optionscCs<tjj||jrd|_n|jr8|j r8|j r8tddS)NTzAYou must specify --record or --root when building system packages)r rfinalize_optionsrootrrecordr)r rrr r%s zinstall.finalize_optionscCs(|js |jrtjj|Sd|_d|_dS)N)rrr rhandle_extra_pathZ path_fileZ extra_dirs)r rrr r0s  zinstall.handle_extra_pathcCs@|js |jrtjj|S|jtjs4tjj|n|jdS)N) rrr rrun_called_from_setupinspectZ currentframedo_egg_install)r rrr r:s   z install.runcCsz|dkr4d}tj|tjdkr0d}tj|dStj|d}|dd\}tj|}|jjdd }|d kox|j d kS) a Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any other way, the immediate caller *might* be 'run_command', but it won't have been called by 'run_commands'. Return True in that case or if a call stack is unavailable. Return False otherwise. Nz4Call stack not available. bdist_* commands may fail.Z IronPythonz6For best results, pass -X:Frames to enable call stack.T__name__rzdistutils.distZ run_commands) warningswarnplatformZpython_implementationrZgetouterframesZ getframeinfo f_globalsgetZfunction)Z run_framemsgresZcallerinfoZ caller_modulerrr rEs     zinstall._called_from_setupcCs|jjd}||jd|j|jd}|jd|_|jjtjd|j d|jj dj g}t j rp|jdt j ||_|jdt _ dS)N easy_installx)argsrr.z*.eggZ bdist_eggr)Z distributionZget_command_classrrZensure_finalizedZalways_copy_fromZ package_indexscanglobZ run_commandZget_command_objZ egg_output setuptoolsZbootstrap_install_frominsertr&r)r r$cmdr&rrr r`s  zinstall.do_egg_install)rNr)rNr)r __module__ __qualname____doc__r rZ user_optionsZboolean_options new_commandsdict_ncr rrr staticmethodrrrrrr rs      rcCsg|]}|dtjkr|qS)r)rr2).0r,rrr {sr5)Zdistutils.errorsrrr)rrZdistutils.command.installZcommandrr r*_installZ sub_commandsr0rrrr s  l__pycache__/setopt.cpython-36.opt-1.pyc000064400000010656147210141470013670 0ustar003 K]@sddlmZddlmZddlmZddlZddlZddlmZddl m Z ddd d gZ dd dZ dddZ Gdd d e ZGdd d eZdS)) convert_path)log)DistutilsOptionErrorN) configparser)Command config_file edit_config option_basesetoptlocalcCsh|dkr dS|dkr,tjjtjjtjdS|dkrZtjdkrBdpDd}tjjtd |St d |d S) zGet the filename of the distutils, local, global, or per-user config `kind` must be one of "local", "global", or "user" r z setup.cfgglobalz distutils.cfguserposix.z~/%spydistutils.cfgz7config_file() type must be 'local', 'global', or 'user'N) ospathjoindirname distutils__file__name expanduserr ValueError)Zkinddotr/usr/lib/python3.6/setopt.pyrsFc Cs.tjd|tj}|j|gx|jD]\}}|dkrTtjd|||j|q*|j|svtjd|||j |x||jD]p\}}|dkrtjd||||j |||j |stjd|||j|qtjd|||||j |||qWq*Wtjd||s*t |d }|j|WdQRXdS) aYEdit a configuration file to include `settings` `settings` is a dictionary of dictionaries or ``None`` values, keyed by command/section name. A ``None`` value means to delete the entire section, while a dictionary lists settings to be changed or deleted in that section. A setting of ``None`` means to delete that setting. zReading configuration from %sNzDeleting section [%s] from %szAdding new section [%s] to %szDeleting %s.%s from %sz#Deleting empty [%s] section from %szSetting %s.%s to %r in %sz Writing %sw)rdebugrZRawConfigParserreaditemsinfoZremove_sectionZ has_sectionZ add_sectionZ remove_optionoptionssetopenwrite) filenameZsettingsdry_runZoptsZsectionr"optionvaluefrrrr!s8            c@s2eZdZdZdddgZddgZd d Zd dZdS)r zr? descriptionr r@rAr6r;rSrrrrr ss )r )F)Zdistutils.utilrrrZdistutils.errorsrrZsetuptools.extern.six.movesrZ setuptoolsr__all__rrr r rrrrs        +'__pycache__/bdist_rpm.cpython-36.pyc000064400000003244147210141470013371 0ustar003 K]@s"ddljjZGdddejZdS)Nc@s eZdZdZddZddZdS) bdist_rpmaf Override the default bdist_rpm behavior to do the following: 1. Run egg_info to ensure the name and version are properly calculated. 2. Always run 'install' using --single-version-externally-managed to disable eggs in RPM distributions. 3. Replace dash with underscore in the version numbers for better RPM compatibility. cCs|jdtjj|dS)NZegg_info)Z run_commandorigrrun)selfr/usr/lib/python3.6/bdist_rpm.pyrs z bdist_rpm.runcsl|jj}|jdd}tjj|}d|d|fdd|D}|jd}d|}|j|||S)N-_z%define version cs0g|](}|jddjddjddjqS)zSource0: %{name}-%{version}.tarz)Source0: %{name}-%{unmangled_version}.tarzsetup.py install z5setup.py install --single-version-externally-managed z%setupz&%setup -n %{name}-%{unmangled_version})replace).0line)line23line24rr s z-bdist_rpm._make_spec_file..z%define unmangled_version )Z distributionZ get_versionr rr_make_spec_fileindexinsert)rversionZ rpmversionspecZ insert_locZunmangled_versionr)r rrrs     zbdist_rpm._make_spec_fileN)__name__ __module__ __qualname____doc__rrrrrrrs r)Zdistutils.command.bdist_rpmZcommandrrrrrrs __pycache__/dist_info.cpython-36.opt-1.pyc000064400000002445147210141470014325 0ustar003 K]@s8dZddlZddlmZddlmZGdddeZdS)zD Create a dist_info directory As defined in the wheel specification N)Command)logc@s.eZdZdZd gZddZddZd d Zd S) dist_infozcreate a .dist-info directory egg-base=eLdirectory containing .egg-info directories (default: top of the source tree)cCs d|_dS)N)egg_base)selfr /usr/lib/python3.6/dist_info.pyinitialize_optionsszdist_info.initialize_optionscCsdS)Nr )r r r r finalize_optionsszdist_info.finalize_optionscCsn|jd}|j|_|j|j|jdtd d}tjdjt j j ||jd}|j |j|dS)Negg_infoz .egg-infoz .dist-infoz creating '{}' bdist_wheel) Zget_finalized_commandrr runrlenrinfoformatospathabspathZegg2dist)r rZ dist_info_dirrr r r rs  z dist_info.runN)rrr)__name__ __module__ __qualname__ descriptionZ user_optionsr r rr r r r r s r)__doc__rZdistutils.corerZ distutilsrrr r r r s  __pycache__/build_ext.cpython-36.opt-1.pyc000064400000023325147210141470014326 0ustar003 K]u3@sddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZddlmZddlmZdd lmZyddlmZed Wnek reZYnXe d dd l mZd dZdZdZdZej dkrdZn>ej!dkr,yddl"Z"e#e"dZZWnek r*YnXddZ$ddZ%GdddeZes^ej!dkrjd!ddZ&ndZd"ddZ&dd Z'dS)#N) build_ext) copy_file) new_compiler)customize_compilerget_config_var)DistutilsError)log)Library)sixzCython.Compiler.MainLDSHARED) _config_varsc CsZtjdkrNtj}z$dtd<dtd<dtd<t|Wdtjtj|Xnt|dS)Ndarwinz0gcc -Wl,-x -dynamiclib -undefined dynamic_lookupr z -dynamiclibCCSHAREDz.dylibSO)sysplatform _CONFIG_VARScopyrclearupdate)compilerZtmpr/usr/lib/python3.6/build_ext.py_customize_compiler_for_shlibs  rFZsharedr TntRTLD_NOWcCs tr|SdS)N) have_rtld)srrr>srcCs>x8ddtjDD]"\}}}d|kr*|S|dkr|SqWdS)z;Return the file extension for an abi3-compliant Extension()css |]}|dtjkr|VqdS)N)impZ C_EXTENSION).0rrrr Csz"get_abi3_suffix..z.abi3z.pydN)r!Z get_suffixes)suffix_rrrget_abi3_suffixAs r&c@sveZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdddZdS)rcCs.|jd}|_tj|||_|r*|jdS)z;Build extensions in build directory, then copy if --inplacerN)Zinplace _build_extruncopy_extensions_to_source)selfZ old_inplacerrrr(Ks  z build_ext.runc Cs|jd}x|jD]}|j|j}|j|}|jd}dj|dd}|j|}tj j|tj j |}tj j|j |} t | ||j |jd|jr|j|ptj|dqWdS)Nbuild_py.)verbosedry_runT)get_finalized_command extensionsget_ext_fullnamenameget_ext_filenamesplitjoinZget_package_dirospathbasename build_librr.r/ _needs_stub write_stubcurdir) r*r+extfullnamefilenameZmodpathpackageZ package_dirZ dest_filenameZ src_filenamerrrr)Ss       z#build_ext.copy_extensions_to_sourcecCstj||}||jkr|j|}tjo4t|do4t}|r^td}|dt| }|t}t |t rt j j |\}}|jj|tStr|jrt j j|\}}t j j|d|S|S)NZpy_limited_api EXT_SUFFIXzdl-)r'r5ext_mapr ZPY3getattrr&_get_config_var_837len isinstancer r8r9splitextshlib_compilerlibrary_filenamelibtype use_stubs_links_to_dynamicr6r7)r*r@rAr?Zuse_abi3Zso_extfndrrrr5is"       zbuild_ext.get_ext_filenamecCs tj|d|_g|_i|_dS)N)r'initialize_optionsrJshlibsrD)r*rrrrQ~s zbuild_ext.initialize_optionscCs2tj||jpg|_|j|jdd|jD|_|jrB|jx|jD]}|j|j|_qJWx|jD]}|j}||j |<||j |j dd<|jr|j |pd}|ot ot |t }||_||_|j|}|_tjjtjj|j|}|o||jkr|jj||rht rhtj|jkrh|jjtjqhWdS)NcSsg|]}t|tr|qSr)rHr )r"r?rrr sz.build_ext.finalize_options..r,r-Fr0)r'finalize_optionsr2Zcheck_extensions_listrRsetup_shlib_compilerr3r4 _full_namerDr6links_to_dynamicrMrHr rNr<r5 _file_namer8r9dirnamer7r; library_dirsappendr>runtime_library_dirs)r*r?r@ZltdnsrAZlibdirrrrrTs,       zbuild_ext.finalize_optionscCst|j|j|jd}|_t||jdk r8|j|j|jdk rbx|jD]\}}|j ||qJW|j dk rx|j D]}|j |qtW|j dk r|j |j |jdk r|j|j|jdk r|j|j|jdk r|j|jtj||_dS)N)rr/force)rrr/r^rJrZ include_dirsZset_include_dirsZdefineZ define_macroZundefZundefine_macro librariesZ set_librariesrZZset_library_dirsZrpathZset_runtime_library_dirsZ link_objectsZset_link_objectslink_shared_object__get__)r*rr4valueZmacrorrrrUs(             zbuild_ext.setup_shlib_compilercCst|tr|jStj||S)N)rHr export_symbolsr'get_export_symbols)r*r?rrrrds zbuild_ext.get_export_symbolsc Cs\|j|j}z@t|tr"|j|_tj|||jrL|jdj }|j ||Wd||_XdS)Nr+) Z_convert_pyx_sources_to_langrrHr rJr'build_extensionr<r1r;r=)r*r?Z _compilercmdrrrres   zbuild_ext.build_extensioncsPtjdd|jDdj|jjddd dgtfdd|jDS) z?Return true if 'ext' links to a dynamic lib in the same packagecSsg|] }|jqSr)rV)r"librrrrSsz.build_ext.links_to_dynamic..r,Nr-rc3s|]}|kVqdS)Nr)r"Zlibname)libnamespkgrrr#sz-build_ext.links_to_dynamic..r0)dictfromkeysrRr7rVr6anyr_)r*r?r)rhrirrWs zbuild_ext.links_to_dynamiccCstj||jS)N)r' get_outputs_build_ext__get_stubs_outputs)r*rrrrmszbuild_ext.get_outputscs6fddjD}tj|j}tdd|DS)Nc3s0|](}|jrtjjjf|jjdVqdS)r,N)r<r8r9r7r;rVr6)r"r?)r*rrr#sz0build_ext.__get_stubs_outputs..css|]\}}||VqdS)Nr)r"baseZfnextrrrr#s)r2 itertoolsproduct!_build_ext__get_output_extensionslist)r*Z ns_ext_basesZpairsr)r*rZ__get_stubs_outputss  zbuild_ext.__get_stubs_outputsccs"dVdV|jdjrdVdS)Nz.pyz.pycr+z.pyo)r1optimize)r*rrrZ__get_output_extensionss z!build_ext.__get_output_extensionsFcCs.tjd|j|tjj|f|jjdd}|rJtjj|rJt|d|j st |d}|j djddd t d d tjj |jd d dt ddddt dddt ddddg|j|r*ddlm}||gdd|j d|jdj}|dkr||g|d|j dtjj|r*|j r*tj|dS)Nz writing stub loader for %s to %sr,z.pyz already exists! Please delete.w zdef __bootstrap__():z- global __bootstrap__, __file__, __loader__z% import sys, os, pkg_resources, impz, dlz: __file__ = pkg_resources.resource_filename(__name__,%r)z del __bootstrap__z if '__loader__' in globals():z del __loader__z# old_flags = sys.getdlopenflags()z old_dir = os.getcwd()z try:z( os.chdir(os.path.dirname(__file__))z$ sys.setdlopenflags(dl.RTLD_NOW)z( imp.load_dynamic(__name__,__file__)z finally:z" sys.setdlopenflags(old_flags)z os.chdir(old_dir)z__bootstrap__()rr) byte_compileT)rtr^r/Z install_lib)rinforVr8r9r7r6existsrr/openwriteif_dlr:rXcloseZdistutils.utilrwr1rtunlink)r* output_dirr?compileZ stub_filefrwrtrrrr=sP          zbuild_ext.write_stubN)F)__name__ __module__ __qualname__r(r)r5rQrTrUrdrerWrmrnrrr=rrrrrJs   rc Cs(|j|j||||||||| | | | dS)N)linkZSHARED_LIBRARY) r*objectsoutput_libnamerr_rZr\rcdebug extra_preargsextra_postargs build_temp target_langrrrr`s r`Zstaticc CsRtjj|\}} tjj| \}}|jdjdr<|dd}|j||||| dS)Nxrg)r8r9r6rIrK startswithZcreate_static_lib)r*rrrr_rZr\rcrrrrrrAr:r?rrrr`,s  cCstjdkrd}t|S)z In https://github.com/pypa/setuptools/pull/837, we discovered Python 3.3.0 exposes the extension suffix under the name 'SO'. rr-r)rrr-)r version_infor)r4rrrrFDs rF) NNNNNrNNNN) NNNNNrNNNN)(r8rrpr!Zdistutils.command.build_extrZ _du_build_extZdistutils.file_utilrZdistutils.ccompilerrZdistutils.sysconfigrrZdistutils.errorsrZ distutilsrZsetuptools.extensionr Zsetuptools.externr ZCython.Distutils.build_extr' __import__ ImportErrorr rrrrMrLrr4Zdlhasattrr|r&r`rFrrrrsZ              Q  __pycache__/build_clib.cpython-36.opt-1.pyc000064400000004504147210141470014435 0ustar003 K]@sFddljjZddlmZddlmZddlm Z GdddejZdS)N)DistutilsSetupError)log)newer_pairwise_groupc@seZdZdZddZdS) build_clibav Override the default build_clib behaviour to do the following: 1. Implement a rudimentary timestamp-based dependency system so 'compile()' doesn't run every time. 2. Add more keys to the 'build_info' dictionary: * obj_deps - specify dependencies for each object compiled. this should be a dictionary mapping a key with the source filename to a list of dependencies. Use an empty string for global dependencies. * cflags - specify a list of additional flags to pass to the compiler. c Cs~xv|D]l\}}|jd}|dks4t|ttf r@td|t|}tjd||jdt}t|tsxtd|g}|jdt}t|ttfstd|xX|D]P}|g} | j||j|t} t| ttfstd|| j| |j | qW|j j ||j d} t || ggfkr^|jd} |jd } |jd }|j j||j | | ||jd }|j j| ||j|jd qWdS) Nsourceszfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenameszbuilding '%s' libraryobj_depsz\in 'libraries' option (library '%s'), 'obj_deps' must be a dictionary of type 'source: list') output_dirmacros include_dirscflags)r r r Zextra_postargsdebug)r r )get isinstancelisttuplerrinfodictextendappendZcompilerZobject_filenamesZ build_temprcompiler Zcreate_static_libr)selfZ librariesZlib_nameZ build_inforrZ dependenciesZ global_depssourceZsrc_depsZ extra_depsZexpected_objectsr r r Zobjectsr /usr/lib/python3.6/build_clib.pybuild_librariess`           zbuild_clib.build_librariesN)__name__ __module__ __qualname____doc__rrrrrrsr) Zdistutils.command.build_clibZcommandrZorigZdistutils.errorsrZ distutilsrZsetuptools.dep_utilrrrrrs    launcher manifest.xml000064400000001164147210141470010661 0ustar00 bdist_rpm.py000064400000002744147210141470007111 0ustar00import distutils.command.bdist_rpm as orig class bdist_rpm(orig.bdist_rpm): """ Override the default bdist_rpm behavior to do the following: 1. Run egg_info to ensure the name and version are properly calculated. 2. Always run 'install' using --single-version-externally-managed to disable eggs in RPM distributions. 3. Replace dash with underscore in the version numbers for better RPM compatibility. """ def run(self): # ensure distro name is up-to-date self.run_command('egg_info') orig.bdist_rpm.run(self) def _make_spec_file(self): version = self.distribution.get_version() rpmversion = version.replace('-', '_') spec = orig.bdist_rpm._make_spec_file(self) line23 = '%define version ' + version line24 = '%define version ' + rpmversion spec = [ line.replace( "Source0: %{name}-%{version}.tar", "Source0: %{name}-%{unmangled_version}.tar" ).replace( "setup.py install ", "setup.py install --single-version-externally-managed " ).replace( "%setup", "%setup -n %{name}-%{unmangled_version}" ).replace(line23, line24) for line in spec ] insert_loc = spec.index(line24) + 1 unmangled_version = "%define unmangled_version " + version spec.insert(insert_loc, unmangled_version) return spec bdist_egg.py000064400000043411147210141470007051 0ustar00"""setuptools.command.bdist_egg Build .egg distributions""" from distutils.errors import DistutilsSetupError from distutils.dir_util import remove_tree, mkpath from distutils import log from types import CodeType import sys import os import re import textwrap import marshal from setuptools.extern import six from pkg_resources import get_build_platform, Distribution, ensure_directory from pkg_resources import EntryPoint from setuptools.extension import Library from setuptools import Command try: # Python 2.7 or >=3.2 from sysconfig import get_path, get_python_version def _get_purelib(): return get_path("purelib") except ImportError: from distutils.sysconfig import get_python_lib, get_python_version def _get_purelib(): return get_python_lib(False) def strip_module(filename): if '.' in filename: filename = os.path.splitext(filename)[0] if filename.endswith('module'): filename = filename[:-6] return filename def sorted_walk(dir): """Do os.walk in a reproducible way, independent of indeterministic filesystem readdir order """ for base, dirs, files in os.walk(dir): dirs.sort() files.sort() yield base, dirs, files def write_stub(resource, pyfile): _stub_template = textwrap.dedent(""" def __bootstrap__(): global __bootstrap__, __loader__, __file__ import sys, pkg_resources, imp __file__ = pkg_resources.resource_filename(__name__, %r) __loader__ = None; del __bootstrap__, __loader__ imp.load_dynamic(__name__,__file__) __bootstrap__() """).lstrip() with open(pyfile, 'w') as f: f.write(_stub_template % resource) class bdist_egg(Command): description = "create an \"egg\" distribution" user_options = [ ('bdist-dir=', 'b', "temporary directory for creating the distribution"), ('plat-name=', 'p', "platform name to embed in generated filenames " "(default: %s)" % get_build_platform()), ('exclude-source-files', None, "remove all .py files from the generated egg"), ('keep-temp', 'k', "keep the pseudo-installation tree around after " + "creating the distribution archive"), ('dist-dir=', 'd', "directory to put final built distributions in"), ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), ] boolean_options = [ 'keep-temp', 'skip-build', 'exclude-source-files' ] def initialize_options(self): self.bdist_dir = None self.plat_name = None self.keep_temp = 0 self.dist_dir = None self.skip_build = 0 self.egg_output = None self.exclude_source_files = None def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg') def do_install_data(self): # Hack for packages that install data to install's --install-lib self.get_finalized_command('install').install_lib = self.bdist_dir site_packages = os.path.normcase(os.path.realpath(_get_purelib())) old, self.distribution.data_files = self.distribution.data_files, [] for item in old: if isinstance(item, tuple) and len(item) == 2: if os.path.isabs(item[0]): realpath = os.path.realpath(item[0]) normalized = os.path.normcase(realpath) if normalized == site_packages or normalized.startswith( site_packages + os.sep ): item = realpath[len(site_packages) + 1:], item[1] # XXX else: raise ??? self.distribution.data_files.append(item) try: log.info("installing package data to %s", self.bdist_dir) self.call_command('install_data', force=0, root=None) finally: self.distribution.data_files = old def get_outputs(self): return [self.egg_output] def call_command(self, cmdname, **kw): """Invoke reinitialized command `cmdname` with keyword args""" for dirname in INSTALL_DIRECTORY_ATTRS: kw.setdefault(dirname, self.bdist_dir) kw.setdefault('skip_build', self.skip_build) kw.setdefault('dry_run', self.dry_run) cmd = self.reinitialize_command(cmdname, **kw) self.run_command(cmdname) return cmd def run(self): # Generate metadata first self.run_command("egg_info") # We run install_lib before install_data, because some data hacks # pull their data path from the install_lib command. log.info("installing library code to %s", self.bdist_dir) instcmd = self.get_finalized_command('install') old_root = instcmd.root instcmd.root = None if self.distribution.has_c_libraries() and not self.skip_build: self.run_command('build_clib') cmd = self.call_command('install_lib', warn_dir=0) instcmd.root = old_root all_outputs, ext_outputs = self.get_ext_outputs() self.stubs = [] to_compile = [] for (p, ext_name) in enumerate(ext_outputs): filename, ext = os.path.splitext(ext_name) pyfile = os.path.join(self.bdist_dir, strip_module(filename) + '.py') self.stubs.append(pyfile) log.info("creating stub loader for %s", ext_name) if not self.dry_run: write_stub(os.path.basename(ext_name), pyfile) to_compile.append(pyfile) ext_outputs[p] = ext_name.replace(os.sep, '/') if to_compile: cmd.byte_compile(to_compile) if self.distribution.data_files: self.do_install_data() # Make the EGG-INFO directory archive_root = self.bdist_dir egg_info = os.path.join(archive_root, 'EGG-INFO') self.mkpath(egg_info) if self.distribution.scripts: script_dir = os.path.join(egg_info, 'scripts') log.info("installing scripts to %s", script_dir) self.call_command('install_scripts', install_dir=script_dir, no_ep=1) self.copy_metadata_to(egg_info) native_libs = os.path.join(egg_info, "native_libs.txt") if all_outputs: log.info("writing %s", native_libs) if not self.dry_run: ensure_directory(native_libs) libs_file = open(native_libs, 'wt') libs_file.write('\n'.join(all_outputs)) libs_file.write('\n') libs_file.close() elif os.path.isfile(native_libs): log.info("removing %s", native_libs) if not self.dry_run: os.unlink(native_libs) write_safety_flag( os.path.join(archive_root, 'EGG-INFO'), self.zip_safe() ) if os.path.exists(os.path.join(self.egg_info, 'depends.txt')): log.warn( "WARNING: 'depends.txt' will not be used by setuptools 0.6!\n" "Use the install_requires/extras_require setup() args instead." ) if self.exclude_source_files: self.zap_pyfiles() # Make the archive make_zipfile(self.egg_output, archive_root, verbose=self.verbose, dry_run=self.dry_run, mode=self.gen_header()) if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) # Add to 'Distribution.dist_files' so that the "upload" command works getattr(self.distribution, 'dist_files', []).append( ('bdist_egg', get_python_version(), self.egg_output)) def zap_pyfiles(self): log.info("Removing .py files from temporary directory") for base, dirs, files in walk_egg(self.bdist_dir): for name in files: path = os.path.join(base, name) if name.endswith('.py'): log.debug("Deleting %s", path) os.unlink(path) if base.endswith('__pycache__'): path_old = path pattern = r'(?P.+)\.(?P[^.]+)\.pyc' m = re.match(pattern, name) path_new = os.path.join( base, os.pardir, m.group('name') + '.pyc') log.info( "Renaming file from [%s] to [%s]" % (path_old, path_new)) try: os.remove(path_new) except OSError: pass os.rename(path_old, path_new) def zip_safe(self): safe = getattr(self.distribution, 'zip_safe', None) if safe is not None: return safe log.warn("zip_safe flag not set; analyzing archive contents...") return analyze_egg(self.bdist_dir, self.stubs) def gen_header(self): epm = EntryPoint.parse_map(self.distribution.entry_points or '') ep = epm.get('setuptools.installation', {}).get('eggsecutable') if ep is None: return 'w' # not an eggsecutable, do it the usual way. if not ep.attrs or ep.extras: raise DistutilsSetupError( "eggsecutable entry point (%r) cannot have 'extras' " "or refer to a module" % (ep,) ) pyver = sys.version[:3] pkg = ep.module_name full = '.'.join(ep.attrs) base = ep.attrs[0] basename = os.path.basename(self.egg_output) header = ( "#!/bin/sh\n" 'if [ `basename $0` = "%(basename)s" ]\n' 'then exec python%(pyver)s -c "' "import sys, os; sys.path.insert(0, os.path.abspath('$0')); " "from %(pkg)s import %(base)s; sys.exit(%(full)s())" '" "$@"\n' 'else\n' ' echo $0 is not the correct name for this egg file.\n' ' echo Please rename it back to %(basename)s and try again.\n' ' exec false\n' 'fi\n' ) % locals() if not self.dry_run: mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run) f = open(self.egg_output, 'w') f.write(header) f.close() return 'a' def copy_metadata_to(self, target_dir): "Copy metadata (egg info) to the target_dir" # normalize the path (so that a forward-slash in egg_info will # match using startswith below) norm_egg_info = os.path.normpath(self.egg_info) prefix = os.path.join(norm_egg_info, '') for path in self.ei_cmd.filelist.files: if path.startswith(prefix): target = os.path.join(target_dir, path[len(prefix):]) ensure_directory(target) self.copy_file(path, target) def get_ext_outputs(self): """Get a list of relative paths to C extensions in the output distro""" all_outputs = [] ext_outputs = [] paths = {self.bdist_dir: ''} for base, dirs, files in sorted_walk(self.bdist_dir): for filename in files: if os.path.splitext(filename)[1].lower() in NATIVE_EXTENSIONS: all_outputs.append(paths[base] + filename) for filename in dirs: paths[os.path.join(base, filename)] = (paths[base] + filename + '/') if self.distribution.has_ext_modules(): build_cmd = self.get_finalized_command('build_ext') for ext in build_cmd.extensions: if isinstance(ext, Library): continue fullname = build_cmd.get_ext_fullname(ext.name) filename = build_cmd.get_ext_filename(fullname) if not os.path.basename(filename).startswith('dl-'): if os.path.exists(os.path.join(self.bdist_dir, filename)): ext_outputs.append(filename) return all_outputs, ext_outputs NATIVE_EXTENSIONS = dict.fromkeys('.dll .so .dylib .pyd'.split()) def walk_egg(egg_dir): """Walk an unpacked egg's contents, skipping the metadata directory""" walker = sorted_walk(egg_dir) base, dirs, files = next(walker) if 'EGG-INFO' in dirs: dirs.remove('EGG-INFO') yield base, dirs, files for bdf in walker: yield bdf def analyze_egg(egg_dir, stubs): # check for existing flag in EGG-INFO for flag, fn in safety_flags.items(): if os.path.exists(os.path.join(egg_dir, 'EGG-INFO', fn)): return flag if not can_scan(): return False safe = True for base, dirs, files in walk_egg(egg_dir): for name in files: if name.endswith('.py') or name.endswith('.pyw'): continue elif name.endswith('.pyc') or name.endswith('.pyo'): # always scan, even if we already know we're not safe safe = scan_module(egg_dir, base, name, stubs) and safe return safe def write_safety_flag(egg_dir, safe): # Write or remove zip safety flag file(s) for flag, fn in safety_flags.items(): fn = os.path.join(egg_dir, fn) if os.path.exists(fn): if safe is None or bool(safe) != flag: os.unlink(fn) elif safe is not None and bool(safe) == flag: f = open(fn, 'wt') f.write('\n') f.close() safety_flags = { True: 'zip-safe', False: 'not-zip-safe', } def scan_module(egg_dir, base, name, stubs): """Check whether module possibly uses unsafe-for-zipfile stuff""" filename = os.path.join(base, name) if filename[:-1] in stubs: return True # Extension module pkg = base[len(egg_dir) + 1:].replace(os.sep, '.') module = pkg + (pkg and '.' or '') + os.path.splitext(name)[0] if sys.version_info < (3, 3): skip = 8 # skip magic & date elif sys.version_info < (3, 7): skip = 12 # skip magic & date & file size else: skip = 16 # skip magic & reserved? & date & file size f = open(filename, 'rb') f.read(skip) code = marshal.load(f) f.close() safe = True symbols = dict.fromkeys(iter_symbols(code)) for bad in ['__file__', '__path__']: if bad in symbols: log.warn("%s: module references %s", module, bad) safe = False if 'inspect' in symbols: for bad in [ 'getsource', 'getabsfile', 'getsourcefile', 'getfile' 'getsourcelines', 'findsource', 'getcomments', 'getframeinfo', 'getinnerframes', 'getouterframes', 'stack', 'trace' ]: if bad in symbols: log.warn("%s: module MAY be using inspect.%s", module, bad) safe = False return safe def iter_symbols(code): """Yield names and strings used by `code` and its nested code objects""" for name in code.co_names: yield name for const in code.co_consts: if isinstance(const, six.string_types): yield const elif isinstance(const, CodeType): for name in iter_symbols(const): yield name def can_scan(): if not sys.platform.startswith('java') and sys.platform != 'cli': # CPython, PyPy, etc. return True log.warn("Unable to analyze compiled code on this platform.") log.warn("Please ask the author to include a 'zip_safe'" " setting (either True or False) in the package's setup.py") # Attribute names of options for commands that might need to be convinced to # install to the egg build directory INSTALL_DIRECTORY_ATTRS = [ 'install_lib', 'install_dir', 'install_data', 'install_base' ] def make_zipfile(zip_filename, base_dir, verbose=0, dry_run=0, compress=True, mode='w'): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ import zipfile mkpath(os.path.dirname(zip_filename), dry_run=dry_run) log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit(z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): p = path[len(base_dir) + 1:] if not dry_run: z.write(path, p) log.debug("adding '%s'", p) compression = zipfile.ZIP_DEFLATED if compress else zipfile.ZIP_STORED if not dry_run: z = zipfile.ZipFile(zip_filename, mode, compression=compression) for dirname, dirs, files in sorted_walk(base_dir): visit(z, dirname, files) z.close() else: for dirname, dirs, files in sorted_walk(base_dir): visit(None, dirname, files) return zip_filename py36compat.py000064400000011572147210141470007132 0ustar00import os from glob import glob from distutils.util import convert_path from distutils.command import sdist from setuptools.extern.six.moves import filter class sdist_add_defaults: """ Mix-in providing forward-compatibility for functionality as found in distutils on Python 3.7. Do not edit the code in this class except to update functionality as implemented in distutils. Instead, override in the subclass. """ def add_defaults(self): """Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as scripts. - all C sources listed as part of extensions or C libraries in the setup script (doesn't catch C headers!) Warns if (README or README.txt) or setup.py are missing; everything else is optional. """ self._add_defaults_standards() self._add_defaults_optional() self._add_defaults_python() self._add_defaults_data_files() self._add_defaults_ext() self._add_defaults_c_libs() self._add_defaults_scripts() @staticmethod def _cs_path_exists(fspath): """ Case-sensitive path existence check >>> sdist_add_defaults._cs_path_exists(__file__) True >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False """ if not os.path.exists(fspath): return False # make absolute so we always have a directory abspath = os.path.abspath(fspath) directory, filename = os.path.split(abspath) return filename in os.listdir(directory) def _add_defaults_standards(self): standards = [self.READMES, self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): alts = fn got_it = False for fn in alts: if self._cs_path_exists(fn): got_it = True self.filelist.append(fn) break if not got_it: self.warn("standard file not found: should have one of " + ', '.join(alts)) else: if self._cs_path_exists(fn): self.filelist.append(fn) else: self.warn("standard file '%s' not found" % fn) def _add_defaults_optional(self): optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: files = filter(os.path.isfile, glob(pattern)) self.filelist.extend(files) def _add_defaults_python(self): # build_py is used to get: # - python modules # - files defined in package_data build_py = self.get_finalized_command('build_py') # getting python files if self.distribution.has_pure_modules(): self.filelist.extend(build_py.get_source_files()) # getting package_data files # (computed in build_py.data_files by build_py.finalize_options) for pkg, src_dir, build_dir, filenames in build_py.data_files: for filename in filenames: self.filelist.append(os.path.join(src_dir, filename)) def _add_defaults_data_files(self): # getting distribution.data_files if self.distribution.has_data_files(): for item in self.distribution.data_files: if isinstance(item, str): # plain file item = convert_path(item) if os.path.isfile(item): self.filelist.append(item) else: # a (dirname, filenames) tuple dirname, filenames = item for f in filenames: f = convert_path(f) if os.path.isfile(f): self.filelist.append(f) def _add_defaults_ext(self): if self.distribution.has_ext_modules(): build_ext = self.get_finalized_command('build_ext') self.filelist.extend(build_ext.get_source_files()) def _add_defaults_c_libs(self): if self.distribution.has_c_libraries(): build_clib = self.get_finalized_command('build_clib') self.filelist.extend(build_clib.get_source_files()) def _add_defaults_scripts(self): if self.distribution.has_scripts(): build_scripts = self.get_finalized_command('build_scripts') self.filelist.extend(build_scripts.get_source_files()) if hasattr(sdist.sdist, '_add_defaults_standards'): # disable the functionality already available upstream class sdist_add_defaults: pass rotate.py000064400000004164147210141470006422 0ustar00from distutils.util import convert_path from distutils import log from distutils.errors import DistutilsOptionError import os import shutil from setuptools.extern import six from setuptools import Command class rotate(Command): """Delete older distributions""" description = "delete older distributions, keeping N newest files" user_options = [ ('match=', 'm', "patterns to match (required)"), ('dist-dir=', 'd', "directory where the distributions are"), ('keep=', 'k', "number of matching distributions to keep"), ] boolean_options = [] def initialize_options(self): self.match = None self.dist_dir = None self.keep = None def finalize_options(self): if self.match is None: raise DistutilsOptionError( "Must specify one or more (comma-separated) match patterns " "(e.g. '.zip' or '.egg')" ) if self.keep is None: raise DistutilsOptionError("Must specify number of files to keep") try: self.keep = int(self.keep) except ValueError: raise DistutilsOptionError("--keep must be an integer") if isinstance(self.match, six.string_types): self.match = [ convert_path(p.strip()) for p in self.match.split(',') ] self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) def run(self): self.run_command("egg_info") from glob import glob for pattern in self.match: pattern = self.distribution.get_name() + '*' + pattern files = glob(os.path.join(self.dist_dir, pattern)) files = [(os.path.getmtime(f), f) for f in files] files.sort() files.reverse() log.info("%d file(s) matching %s", len(files), pattern) files = files[self.keep:] for (t, f) in files: log.info("Deleting %s", f) if not self.dry_run: if os.path.isdir(f): shutil.rmtree(f) else: os.unlink(f) upload_docs.py000064400000016217147210141470007422 0ustar00# -*- coding: utf-8 -*- """upload_docs Implements a Distutils 'upload_docs' subcommand (upload documentation to PyPI's pythonhosted.org). """ from base64 import standard_b64encode from distutils import log from distutils.errors import DistutilsOptionError import os import socket import zipfile import tempfile import shutil import itertools import functools from setuptools.extern import six from setuptools.extern.six.moves import http_client, urllib from pkg_resources import iter_entry_points from .upload import upload def _encode(s): errors = 'surrogateescape' if six.PY3 else 'strict' return s.encode('utf-8', errors) class upload_docs(upload): # override the default repository as upload_docs isn't # supported by Warehouse (and won't be). DEFAULT_REPOSITORY = 'https://pypi.python.org/pypi/' description = 'Upload documentation to PyPI' user_options = [ ('repository=', 'r', "url of repository [default: %s]" % upload.DEFAULT_REPOSITORY), ('show-response', None, 'display full response text from server'), ('upload-dir=', None, 'directory to upload'), ] boolean_options = upload.boolean_options def has_sphinx(self): if self.upload_dir is None: for ep in iter_entry_points('distutils.commands', 'build_sphinx'): return True sub_commands = [('build_sphinx', has_sphinx)] def initialize_options(self): upload.initialize_options(self) self.upload_dir = None self.target_dir = None def finalize_options(self): upload.finalize_options(self) if self.upload_dir is None: if self.has_sphinx(): build_sphinx = self.get_finalized_command('build_sphinx') self.target_dir = build_sphinx.builder_target_dir else: build = self.get_finalized_command('build') self.target_dir = os.path.join(build.build_base, 'docs') else: self.ensure_dirname('upload_dir') self.target_dir = self.upload_dir if 'pypi.python.org' in self.repository: log.warn("Upload_docs command is deprecated. Use RTD instead.") self.announce('Using upload directory %s' % self.target_dir) def create_zipfile(self, filename): zip_file = zipfile.ZipFile(filename, "w") try: self.mkpath(self.target_dir) # just in case for root, dirs, files in os.walk(self.target_dir): if root == self.target_dir and not files: tmpl = "no files found in upload directory '%s'" raise DistutilsOptionError(tmpl % self.target_dir) for name in files: full = os.path.join(root, name) relative = root[len(self.target_dir):].lstrip(os.path.sep) dest = os.path.join(relative, name) zip_file.write(full, dest) finally: zip_file.close() def run(self): # Run sub commands for cmd_name in self.get_sub_commands(): self.run_command(cmd_name) tmp_dir = tempfile.mkdtemp() name = self.distribution.metadata.get_name() zip_file = os.path.join(tmp_dir, "%s.zip" % name) try: self.create_zipfile(zip_file) self.upload_file(zip_file) finally: shutil.rmtree(tmp_dir) @staticmethod def _build_part(item, sep_boundary): key, values = item title = '\nContent-Disposition: form-data; name="%s"' % key # handle multiple entries for the same name if not isinstance(values, list): values = [values] for value in values: if isinstance(value, tuple): title += '; filename="%s"' % value[0] value = value[1] else: value = _encode(value) yield sep_boundary yield _encode(title) yield b"\n\n" yield value if value and value[-1:] == b'\r': yield b'\n' # write an extra newline (lurve Macs) @classmethod def _build_multipart(cls, data): """ Build up the MIME payload for the POST data """ boundary = b'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' sep_boundary = b'\n--' + boundary end_boundary = sep_boundary + b'--' end_items = end_boundary, b"\n", builder = functools.partial( cls._build_part, sep_boundary=sep_boundary, ) part_groups = map(builder, data.items()) parts = itertools.chain.from_iterable(part_groups) body_items = itertools.chain(parts, end_items) content_type = 'multipart/form-data; boundary=%s' % boundary.decode('ascii') return b''.join(body_items), content_type def upload_file(self, filename): with open(filename, 'rb') as f: content = f.read() meta = self.distribution.metadata data = { ':action': 'doc_upload', 'name': meta.get_name(), 'content': (os.path.basename(filename), content), } # set up the authentication credentials = _encode(self.username + ':' + self.password) credentials = standard_b64encode(credentials) if six.PY3: credentials = credentials.decode('ascii') auth = "Basic " + credentials body, ct = self._build_multipart(data) msg = "Submitting documentation to %s" % (self.repository) self.announce(msg, log.INFO) # build the Request # We can't use urllib2 since we need to send the Basic # auth right with the first request schema, netloc, url, params, query, fragments = \ urllib.parse.urlparse(self.repository) assert not params and not query and not fragments if schema == 'http': conn = http_client.HTTPConnection(netloc) elif schema == 'https': conn = http_client.HTTPSConnection(netloc) else: raise AssertionError("unsupported schema " + schema) data = '' try: conn.connect() conn.putrequest("POST", url) content_type = ct conn.putheader('Content-type', content_type) conn.putheader('Content-length', str(len(body))) conn.putheader('Authorization', auth) conn.endheaders() conn.send(body) except socket.error as e: self.announce(str(e), log.ERROR) return r = conn.getresponse() if r.status == 200: msg = 'Server response (%s): %s' % (r.status, r.reason) self.announce(msg, log.INFO) elif r.status == 301: location = r.getheader('Location') if location is None: location = 'https://pythonhosted.org/%s/' % meta.get_name() msg = 'Upload successful. Visit %s' % location self.announce(msg, log.INFO) else: msg = 'Upload failed (%s): %s' % (r.status, r.reason) self.announce(msg, log.ERROR) if self.show_response: print('-' * 75, r.read(), '-' * 75) dist_info.py000064400000001700147210141470007073 0ustar00""" Create a dist_info directory As defined in the wheel specification """ import os from distutils.core import Command from distutils import log class dist_info(Command): description = 'create a .dist-info directory' user_options = [ ('egg-base=', 'e', "directory containing .egg-info directories" " (default: top of the source tree)"), ] def initialize_options(self): self.egg_base = None def finalize_options(self): pass def run(self): egg_info = self.get_finalized_command('egg_info') egg_info.egg_base = self.egg_base egg_info.finalize_options() egg_info.run() dist_info_dir = egg_info.egg_info[:-len('.egg-info')] + '.dist-info' log.info("creating '{}'".format(os.path.abspath(dist_info_dir))) bdist_wheel = self.get_finalized_command('bdist_wheel') bdist_wheel.egg2dist(egg_info.egg_info, dist_info_dir) register.py000064400000000416147210141470006744 0ustar00import distutils.command.register as orig class register(orig.register): __doc__ = orig.register.__doc__ def run(self): # Make sure that we are using valid current name/version info self.run_command('egg_info') orig.register.run(self) saveopts.py000064400000001222147210141470006760 0ustar00from setuptools.command.setopt import edit_config, option_base class saveopts(option_base): """Save command-line options to a file""" description = "save supplied options to setup.cfg or other config file" def run(self): dist = self.distribution settings = {} for cmd in dist.command_options: if cmd == 'saveopts': continue # don't save our own options! for opt, (src, val) in dist.get_option_dict(cmd).items(): if src == "command line": settings.setdefault(cmd, {})[opt] = val edit_config(self.filename, settings, self.dry_run) build_py.py000064400000022574147210141470006740 0ustar00from glob import glob from distutils.util import convert_path import distutils.command.build_py as orig import os import fnmatch import textwrap import io import distutils.errors import itertools from setuptools.extern import six from setuptools.extern.six.moves import map, filter, filterfalse try: from setuptools.lib2to3_ex import Mixin2to3 except ImportError: class Mixin2to3: def run_2to3(self, files, doctests=True): "do nothing" class build_py(orig.build_py, Mixin2to3): """Enhanced 'build_py' command that includes data files with packages The data files are specified via a 'package_data' argument to 'setup()'. See 'setuptools.dist.Distribution' for more details. Also, this version of the 'build_py' command allows you to specify both 'py_modules' and 'packages' in the same setup operation. """ def finalize_options(self): orig.build_py.finalize_options(self) self.package_data = self.distribution.package_data self.exclude_package_data = (self.distribution.exclude_package_data or {}) if 'data_files' in self.__dict__: del self.__dict__['data_files'] self.__updated_files = [] self.__doctests_2to3 = [] def run(self): """Build modules, packages, and copy data files to build directory""" if not self.py_modules and not self.packages: return if self.py_modules: self.build_modules() if self.packages: self.build_packages() self.build_package_data() self.run_2to3(self.__updated_files, False) self.run_2to3(self.__updated_files, True) self.run_2to3(self.__doctests_2to3, True) # Only compile actual .py files, using our base class' idea of what our # output files are. self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0)) def __getattr__(self, attr): "lazily compute data files" if attr == 'data_files': self.data_files = self._get_data_files() return self.data_files return orig.build_py.__getattr__(self, attr) def build_module(self, module, module_file, package): if six.PY2 and isinstance(package, six.string_types): # avoid errors on Python 2 when unicode is passed (#190) package = package.split('.') outfile, copied = orig.build_py.build_module(self, module, module_file, package) if copied: self.__updated_files.append(outfile) return outfile, copied def _get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" self.analyze_manifest() return list(map(self._get_pkg_data_files, self.packages or ())) def _get_pkg_data_files(self, package): # Locate package source directory src_dir = self.get_package_dir(package) # Compute package build directory build_dir = os.path.join(*([self.build_lib] + package.split('.'))) # Strip directory from globbed filenames filenames = [ os.path.relpath(file, src_dir) for file in self.find_data_files(package, src_dir) ] return package, src_dir, build_dir, filenames def find_data_files(self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" patterns = self._get_platform_patterns( self.package_data, package, src_dir, ) globs_expanded = map(glob, patterns) # flatten the expanded globs into an iterable of matches globs_matches = itertools.chain.from_iterable(globs_expanded) glob_files = filter(os.path.isfile, globs_matches) files = itertools.chain( self.manifest_files.get(package, []), glob_files, ) return self.exclude_data_files(package, src_dir, files) def build_package_data(self): """Copy data files into build directory""" for package, src_dir, build_dir, filenames in self.data_files: for filename in filenames: target = os.path.join(build_dir, filename) self.mkpath(os.path.dirname(target)) srcfile = os.path.join(src_dir, filename) outf, copied = self.copy_file(srcfile, target) srcfile = os.path.abspath(srcfile) if (copied and srcfile in self.distribution.convert_2to3_doctests): self.__doctests_2to3.append(outf) def analyze_manifest(self): self.manifest_files = mf = {} if not self.distribution.include_package_data: return src_dirs = {} for package in self.packages or (): # Locate package source directory src_dirs[assert_relative(self.get_package_dir(package))] = package self.run_command('egg_info') ei_cmd = self.get_finalized_command('egg_info') for path in ei_cmd.filelist.files: d, f = os.path.split(assert_relative(path)) prev = None oldf = f while d and d != prev and d not in src_dirs: prev = d d, df = os.path.split(d) f = os.path.join(df, f) if d in src_dirs: if path.endswith('.py') and f == oldf: continue # it's a module, not data mf.setdefault(src_dirs[d], []).append(path) def get_data_files(self): pass # Lazily compute data files in _get_data_files() function. def check_package(self, package, package_dir): """Check namespace packages' __init__ for declare_namespace""" try: return self.packages_checked[package] except KeyError: pass init_py = orig.build_py.check_package(self, package, package_dir) self.packages_checked[package] = init_py if not init_py or not self.distribution.namespace_packages: return init_py for pkg in self.distribution.namespace_packages: if pkg == package or pkg.startswith(package + '.'): break else: return init_py with io.open(init_py, 'rb') as f: contents = f.read() if b'declare_namespace' not in contents: raise distutils.errors.DistutilsError( "Namespace package problem: %s is a namespace package, but " "its\n__init__.py does not call declare_namespace()! Please " 'fix it.\n(See the setuptools manual under ' '"Namespace Packages" for details.)\n"' % (package,) ) return init_py def initialize_options(self): self.packages_checked = {} orig.build_py.initialize_options(self) def get_package_dir(self, package): res = orig.build_py.get_package_dir(self, package) if self.distribution.src_root is not None: return os.path.join(self.distribution.src_root, res) return res def exclude_data_files(self, package, src_dir, files): """Filter filenames for package's data files in 'src_dir'""" files = list(files) patterns = self._get_platform_patterns( self.exclude_package_data, package, src_dir, ) match_groups = ( fnmatch.filter(files, pattern) for pattern in patterns ) # flatten the groups of matches into an iterable of matches matches = itertools.chain.from_iterable(match_groups) bad = set(matches) keepers = ( fn for fn in files if fn not in bad ) # ditch dupes return list(_unique_everseen(keepers)) @staticmethod def _get_platform_patterns(spec, package, src_dir): """ yield platform-specific path patterns (suitable for glob or fn_match) from a glob-based spec (such as self.package_data or self.exclude_package_data) matching package in src_dir. """ raw_patterns = itertools.chain( spec.get('', []), spec.get(package, []), ) return ( # Each pattern has to be converted to a platform-specific path os.path.join(src_dir, convert_path(pattern)) for pattern in raw_patterns ) # from Python docs def _unique_everseen(iterable, key=None): "List unique elements, preserving order. Remember all elements ever seen." # unique_everseen('AAAABBBCCDAABBB') --> A B C D # unique_everseen('ABBCcAD', str.lower) --> A B C D seen = set() seen_add = seen.add if key is None: for element in filterfalse(seen.__contains__, iterable): seen_add(element) yield element else: for element in iterable: k = key(element) if k not in seen: seen_add(k) yield element def assert_relative(path): if not os.path.isabs(path): return path from distutils.errors import DistutilsSetupError msg = textwrap.dedent(""" Error: setup script specifies an absolute path: %s setup() arguments must *always* be /-separated paths relative to the setup.py directory, *never* absolute paths. """).lstrip() % path raise DistutilsSetupError(msg) bdist_wininst.py000064400000001175147210141470010003 0ustar00import distutils.command.bdist_wininst as orig class bdist_wininst(orig.bdist_wininst): def reinitialize_command(self, command, reinit_subcommands=0): """ Supplement reinitialize_command to work around http://bugs.python.org/issue20819 """ cmd = self.distribution.reinitialize_command( command, reinit_subcommands) if command in ('install', 'install_lib'): cmd.install_lib = None return cmd def run(self): self._is_running = True try: orig.bdist_wininst.run(self) finally: self._is_running = False install_scripts.py000064400000004607147210141470010343 0ustar00from distutils import log import distutils.command.install_scripts as orig import os import sys from pkg_resources import Distribution, PathMetadata, ensure_directory class install_scripts(orig.install_scripts): """Do normal script install, plus any egg_info wrapper scripts""" def initialize_options(self): orig.install_scripts.initialize_options(self) self.no_ep = False def run(self): import setuptools.command.easy_install as ei self.run_command("egg_info") if self.distribution.scripts: orig.install_scripts.run(self) # run first to set up self.outfiles else: self.outfiles = [] if self.no_ep: # don't install entry point scripts into .egg file! return ei_cmd = self.get_finalized_command("egg_info") dist = Distribution( ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), ei_cmd.egg_name, ei_cmd.egg_version, ) bs_cmd = self.get_finalized_command('build_scripts') exec_param = getattr(bs_cmd, 'executable', None) bw_cmd = self.get_finalized_command("bdist_wininst") is_wininst = getattr(bw_cmd, '_is_running', False) writer = ei.ScriptWriter if is_wininst: exec_param = "python.exe" writer = ei.WindowsScriptWriter if exec_param == sys.executable: # In case the path to the Python executable contains a space, wrap # it so it's not split up. exec_param = [exec_param] # resolve the writer to the environment writer = writer.best() cmd = writer.command_spec_class.best().from_param(exec_param) for args in writer.get_args(dist, cmd.as_header()): self.write_script(*args) def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" from 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) self.outfiles.append(target) mask = current_umask() if not self.dry_run: ensure_directory(target) f = open(target, "w" + mode) f.write(contents) f.close() chmod(target, 0o777 - mask) alias.py000064400000004572147210141470006220 0ustar00from distutils.errors import DistutilsOptionError from setuptools.extern.six.moves import map from setuptools.command.setopt import edit_config, option_base, config_file def shquote(arg): """Quote an argument for later parsing by shlex.split()""" for c in '"', "'", "\\", "#": if c in arg: return repr(arg) if arg.split() != [arg]: return repr(arg) return arg class alias(option_base): """Define a shortcut that invokes one or more commands""" description = "define a shortcut to invoke one or more commands" command_consumes_arguments = True user_options = [ ('remove', 'r', 'remove (unset) the alias'), ] + option_base.user_options boolean_options = option_base.boolean_options + ['remove'] def initialize_options(self): option_base.initialize_options(self) self.args = None self.remove = None def finalize_options(self): option_base.finalize_options(self) if self.remove and len(self.args) != 1: raise DistutilsOptionError( "Must specify exactly one argument (the alias name) when " "using --remove" ) def run(self): aliases = self.distribution.get_option_dict('aliases') if not self.args: print("Command Aliases") print("---------------") for alias in aliases: print("setup.py alias", format_alias(alias, aliases)) return elif len(self.args) == 1: alias, = self.args if self.remove: command = None elif alias in aliases: print("setup.py alias", format_alias(alias, aliases)) return else: print("No alias definition found for %r" % alias) return else: alias = self.args[0] command = ' '.join(map(shquote, self.args[1:])) edit_config(self.filename, {'aliases': {alias: command}}, self.dry_run) def format_alias(name, aliases): source, command = aliases[name] if source == config_file('global'): source = '--global-config ' elif source == config_file('user'): source = '--user-config ' elif source == config_file('local'): source = '' else: source = '--filename=%r' % source return source + name + ' ' + command easy_install.py000064400000252244147210141470007617 0ustar00""" Easy Install ------------ A tool for doing automatic download/extract/build of distutils-based Python packages. For detailed documentation, see the accompanying EasyInstall.txt file, or visit the `EasyInstall home page`__. __ https://setuptools.readthedocs.io/en/latest/easy_install.html """ from glob import glob from distutils.util import get_platform from distutils.util import convert_path, subst_vars from distutils.errors import ( DistutilsArgError, DistutilsOptionError, DistutilsError, DistutilsPlatformError, ) from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS from distutils import log, dir_util from distutils.command.build_scripts import first_line_re from distutils.spawn import find_executable import sys import os import zipimport import shutil import tempfile import zipfile import re import stat import random import textwrap import warnings import site import struct import contextlib import subprocess import shlex import io from setuptools.extern import six from setuptools.extern.six.moves import configparser, map from setuptools import Command from setuptools.sandbox import run_setup from setuptools.py31compat import get_path, get_config_vars from setuptools.py27compat import rmtree_safe from setuptools.command import setopt from setuptools.archive_util import unpack_archive from setuptools.package_index import ( PackageIndex, parse_requirement_arg, URL_SCHEME, ) from setuptools.command import bdist_egg, egg_info from setuptools.wheel import Wheel 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, ) import pkg_resources.py31compat # Turn on PEP440Warnings warnings.filterwarnings("default", category=pkg_resources.PEP440Warning) __all__ = [ 'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg', 'main', 'get_exe_prefixes', ] def is_64bit(): return struct.calcsize("P") == 8 def samefile(p1, p2): """ Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. """ both_exist = os.path.exists(p1) and os.path.exists(p2) use_samefile = hasattr(os.path, 'samefile') and both_exist if use_samefile: return os.path.samefile(p1, p2) norm_p1 = os.path.normpath(os.path.normcase(p1)) norm_p2 = os.path.normpath(os.path.normcase(p2)) return norm_p1 == norm_p2 if six.PY2: def _to_ascii(s): return s def isascii(s): try: six.text_type(s, 'ascii') return True except UnicodeError: return False else: def _to_ascii(s): return s.encode('ascii') def isascii(s): try: s.encode('ascii') return True except UnicodeError: return False _one_liner = lambda text: textwrap.dedent(text).strip().replace('\n', '; ') class easy_install(Command): """Manage a download/build/install process""" description = "Find/get/install Python packages" command_consumes_arguments = True user_options = [ ('prefix=', None, "installation prefix"), ("zip-ok", "z", "install package as a zipfile"), ("multi-version", "m", "make apps have to require() a version"), ("upgrade", "U", "force upgrade (searches PyPI for latest versions)"), ("install-dir=", "d", "install package to DIR"), ("script-dir=", "s", "install scripts to DIR"), ("exclude-scripts", "x", "Don't install scripts"), ("always-copy", "a", "Copy all needed packages to install dir"), ("index-url=", "i", "base URL of Python Package Index"), ("find-links=", "f", "additional URL(s) to search for packages"), ("build-directory=", "b", "download/extract/build in DIR; keep the results"), ('optimize=', 'O', "also compile with optimization: -O1 for \"python -O\", " "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), ('record=', None, "filename in which to record list of installed files"), ('always-unzip', 'Z', "don't install as a zipfile, no matter what"), ('site-dirs=', 'S', "list of directories where .pth files work"), ('editable', 'e', "Install specified packages in editable form"), ('no-deps', 'N', "don't install dependencies"), ('allow-hosts=', 'H', "pattern(s) that hostnames must match"), ('local-snapshots-ok', 'l', "allow building eggs from local checkouts"), ('version', None, "print version information and exit"), ('no-find-links', None, "Don't load find-links defined in packages being installed") ] boolean_options = [ 'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy', 'editable', 'no-deps', 'local-snapshots-ok', 'version' ] if site.ENABLE_USER_SITE: help_msg = "install in user site-package '%s'" % site.USER_SITE user_options.append(('user', None, help_msg)) boolean_options.append('user') negative_opt = {'always-unzip': 'zip-ok'} create_index = PackageIndex def initialize_options(self): # the --user option seems to be an opt-in one, # so the default should be False. self.user = 0 self.zip_ok = self.local_snapshots_ok = None self.install_dir = self.script_dir = self.exclude_scripts = None self.index_url = None self.find_links = None self.build_directory = None self.args = None self.optimize = self.record = None self.upgrade = self.always_copy = self.multi_version = None self.editable = self.no_deps = self.allow_hosts = None self.root = self.prefix = self.no_report = None self.version = None self.install_purelib = None # for pure module distributions self.install_platlib = None # non-pure (dists w/ extensions) self.install_headers = None # for C/C++ headers self.install_lib = None # set to either purelib or platlib self.install_scripts = None self.install_data = None self.install_base = None self.install_platbase = None if site.ENABLE_USER_SITE: self.install_userbase = site.USER_BASE self.install_usersite = site.USER_SITE else: self.install_userbase = None self.install_usersite = None self.no_find_links = None # Options not specifiable via command line self.package_index = None self.pth_file = self.always_copy_from = None self.site_dirs = None self.installed_projects = {} self.sitepy_installed = False # Always read easy_install options, even if we are subclassed, or have # an independent instance created. This ensures that defaults will # always come from the standard configuration file(s)' "easy_install" # section, even if this is a "develop" or "install" command, or some # other embedding. self._dry_run = None self.verbose = self.distribution.verbose self.distribution._set_command_options( self, self.distribution.get_option_dict('easy_install') ) def delete_blockers(self, blockers): extant_blockers = ( filename for filename in blockers if os.path.exists(filename) or os.path.islink(filename) ) list(map(self._delete_path, extant_blockers)) def _delete_path(self, path): log.info("Deleting %s", path) if self.dry_run: return is_tree = os.path.isdir(path) and not os.path.islink(path) remover = rmtree if is_tree else os.unlink remover(path) @staticmethod def _render_version(): """ Render the Setuptools version and installation details, then exit. """ ver = sys.version[:3] dist = get_distribution('setuptools') tmpl = 'setuptools {dist.version} from {dist.location} (Python {ver})' print(tmpl.format(**locals())) raise SystemExit() def finalize_options(self): self.version and self._render_version() py_version = sys.version.split()[0] prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix') self.config_vars = { 'dist_name': self.distribution.get_name(), 'dist_version': self.distribution.get_version(), 'dist_fullname': self.distribution.get_fullname(), 'py_version': py_version, 'py_version_short': py_version[0:3], 'py_version_nodot': py_version[0] + py_version[2], 'sys_prefix': prefix, 'prefix': prefix, 'sys_exec_prefix': exec_prefix, 'exec_prefix': exec_prefix, # Only python 3.2+ has abiflags 'abiflags': getattr(sys, 'abiflags', ''), } if site.ENABLE_USER_SITE: self.config_vars['userbase'] = self.install_userbase self.config_vars['usersite'] = self.install_usersite self._fix_install_dir_for_user_site() self.expand_basedirs() self.expand_dirs() self._expand( 'install_dir', 'script_dir', 'build_directory', 'site_dirs', ) # If a non-default installation directory was specified, default the # script directory to match it. if self.script_dir is None: self.script_dir = self.install_dir if self.no_find_links is None: self.no_find_links = False # Let install_dir get set by install_lib command, which in turn # gets its info from the install command, and takes into account # --prefix and --home and all that other crud. self.set_undefined_options( 'install_lib', ('install_dir', 'install_dir') ) # Likewise, set default script_dir from 'install_scripts.install_dir' self.set_undefined_options( 'install_scripts', ('install_dir', 'script_dir') ) if self.user and self.install_purelib: self.install_dir = self.install_purelib self.script_dir = self.install_scripts # default --record from the install command self.set_undefined_options('install', ('record', 'record')) # Should this be moved to the if statement below? It's not used # elsewhere normpath = map(normalize_path, sys.path) self.all_site_dirs = get_site_dirs() if self.site_dirs is not None: site_dirs = [ os.path.expanduser(s.strip()) for s in self.site_dirs.split(',') ] for d in site_dirs: if not os.path.isdir(d): log.warn("%s (in --site-dirs) does not exist", d) elif normalize_path(d) not in normpath: raise DistutilsOptionError( d + " (in --site-dirs) is not on sys.path" ) else: self.all_site_dirs.append(normalize_path(d)) if not self.editable: self.check_site_dir() self.index_url = self.index_url or "https://pypi.org/simple/" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): if path_item not in self.shadow_path: self.shadow_path.insert(0, path_item) if self.allow_hosts is not None: hosts = [s.strip() for s in self.allow_hosts.split(',')] else: hosts = ['*'] if self.package_index is None: self.package_index = self.create_index( self.index_url, search_path=self.shadow_path, hosts=hosts, ) self.local_index = Environment(self.shadow_path + sys.path) if self.find_links is not None: if isinstance(self.find_links, six.string_types): self.find_links = self.find_links.split() else: self.find_links = [] if self.local_snapshots_ok: self.package_index.scan_egg_links(self.shadow_path + sys.path) if not self.no_find_links: self.package_index.add_find_links(self.find_links) self.set_undefined_options('install_lib', ('optimize', 'optimize')) if not isinstance(self.optimize, int): try: self.optimize = int(self.optimize) if not (0 <= self.optimize <= 2): raise ValueError except ValueError: raise DistutilsOptionError("--optimize must be 0, 1, or 2") if self.editable and not self.build_directory: raise DistutilsArgError( "Must specify a build directory (-b) when using --editable" ) if not self.args: raise DistutilsArgError( "No urls, filenames, or requirements specified (see --help)") self.outputs = [] def _fix_install_dir_for_user_site(self): """ Fix the install_dir if "--user" was used. """ if not self.user or not site.ENABLE_USER_SITE: return self.create_home_path() if self.install_userbase is None: msg = "User base directory is not specified" raise DistutilsPlatformError(msg) self.install_base = self.install_platbase = self.install_userbase scheme_name = os.name.replace('posix', 'unix') + '_user' self.select_scheme(scheme_name) def _expand_attrs(self, attrs): for attr in attrs: val = getattr(self, attr) if val is not None: if os.name == 'posix' or os.name == 'nt': val = os.path.expanduser(val) val = subst_vars(val, self.config_vars) setattr(self, attr, val) def expand_basedirs(self): """Calls `os.path.expanduser` on install_base, install_platbase and root.""" self._expand_attrs(['install_base', 'install_platbase', 'root']) def expand_dirs(self): """Calls `os.path.expanduser` on install dirs.""" dirs = [ 'install_purelib', 'install_platlib', 'install_lib', 'install_headers', 'install_scripts', 'install_data', ] self._expand_attrs(dirs) def run(self): if self.verbose != self.distribution.verbose: log.set_verbosity(self.verbose) try: for spec in self.args: self.easy_install(spec, not self.no_deps) if self.record: outputs = self.outputs if self.root: # strip any package prefix root_len = len(self.root) for counter in range(len(outputs)): outputs[counter] = outputs[counter][root_len:] from distutils import file_util self.execute( file_util.write_file, (self.record, outputs), "writing list of installed files to '%s'" % self.record ) self.warn_deprecated_options() finally: log.set_verbosity(self.distribution.verbose) def pseudo_tempname(self): """Return a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo. """ try: pid = os.getpid() except Exception: pid = random.randint(0, sys.maxsize) return os.path.join(self.install_dir, "test-easy-install-%s" % pid) def warn_deprecated_options(self): pass def check_site_dir(self): """Verify that self.install_dir is .pth-capable dir, if needed""" instdir = normalize_path(self.install_dir) pth_file = os.path.join(instdir, 'easy-install.pth') if not os.path.exists(instdir): try: os.makedirs(instdir) except (OSError, IOError): self.cant_write_to_target() # Is it a configured, PYTHONPATH, implicit, or explicit site dir? is_site_dir = instdir in self.all_site_dirs if not is_site_dir and not self.multi_version: # No? Then directly test whether it does .pth file processing is_site_dir = self.check_pth_processing() else: # make sure we can write to target dir testfile = self.pseudo_tempname() + '.write-test' test_exists = os.path.exists(testfile) try: if test_exists: os.unlink(testfile) open(testfile, 'w').close() os.unlink(testfile) except (OSError, IOError): self.cant_write_to_target() if not is_site_dir and not self.multi_version: # Can't install non-multi to non-site dir raise DistutilsError(self.no_default_version_msg()) if is_site_dir: if self.pth_file is None: self.pth_file = PthDistributions(pth_file, self.all_site_dirs) else: self.pth_file = None if instdir not in map(normalize_path, _pythonpath()): # only PYTHONPATH dirs need a site.py, so pretend it's there self.sitepy_installed = True elif self.multi_version and not os.path.exists(pth_file): self.sitepy_installed = True # don't need site.py in this case self.pth_file = None # and don't create a .pth file self.install_dir = instdir __cant_write_msg = textwrap.dedent(""" can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: %s The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s """).lstrip() __not_exists_id = textwrap.dedent(""" This directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install-dir option). """).lstrip() __access_msg = textwrap.dedent(""" Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://setuptools.readthedocs.io/en/latest/easy_install.html Please make the appropriate changes for your system and try again. """).lstrip() def cant_write_to_target(self): msg = self.__cant_write_msg % (sys.exc_info()[1], self.install_dir,) if not os.path.exists(self.install_dir): msg += '\n' + self.__not_exists_id else: msg += '\n' + self.__access_msg raise DistutilsError(msg) def check_pth_processing(self): """Empirically verify whether .pth files are supported in inst. dir""" instdir = self.install_dir log.info("Checking .pth file support in %s", instdir) pth_file = self.pseudo_tempname() + ".pth" ok_file = pth_file + '.ok' ok_exists = os.path.exists(ok_file) tmpl = _one_liner(""" import os f = open({ok_file!r}, 'w') f.write('OK') f.close() """) + '\n' try: if ok_exists: os.unlink(ok_file) dirname = os.path.dirname(ok_file) pkg_resources.py31compat.makedirs(dirname, exist_ok=True) f = open(pth_file, 'w') except (OSError, IOError): self.cant_write_to_target() else: try: f.write(tmpl.format(**locals())) f.close() f = None executable = sys.executable if os.name == 'nt': dirname, basename = os.path.split(executable) alt = os.path.join(dirname, 'pythonw.exe') use_alt = ( basename.lower() == 'python.exe' and os.path.exists(alt) ) if use_alt: # use pythonw.exe to avoid opening a console window executable = alt from distutils.spawn import spawn spawn([executable, '-E', '-c', 'pass'], 0) if os.path.exists(ok_file): log.info( "TEST PASSED: %s appears to support .pth files", instdir ) return True finally: if f: f.close() if os.path.exists(ok_file): os.unlink(ok_file) if os.path.exists(pth_file): os.unlink(pth_file) if not self.multi_version: log.warn("TEST FAILED: %s does NOT support .pth files", instdir) return False def install_egg_scripts(self, dist): """Write all the scripts for `dist`, unless scripts are excluded""" if not self.exclude_scripts and dist.metadata_isdir('scripts'): for script_name in dist.metadata_listdir('scripts'): if dist.metadata_isdir('scripts/' + script_name): # The "script" is a directory, likely a Python 3 # __pycache__ directory, so skip it. continue self.install_script( dist, script_name, dist.get_metadata('scripts/' + script_name) ) self.install_wrapper_scripts(dist) def add_output(self, path): if os.path.isdir(path): for base, dirs, files in os.walk(path): for filename in files: self.outputs.append(os.path.join(base, filename)) else: self.outputs.append(path) def not_editable(self, spec): if self.editable: raise DistutilsArgError( "Invalid argument %r: you can't use filenames or URLs " "with --editable (except via the --find-links option)." % (spec,) ) def check_editable(self, spec): if not self.editable: return if os.path.exists(os.path.join(self.build_directory, spec.key)): raise DistutilsArgError( "%r already exists in %s; can't do a checkout there" % (spec.key, self.build_directory) ) @contextlib.contextmanager def _tmpdir(self): tmpdir = tempfile.mkdtemp(prefix=six.u("easy_install-")) try: # cast to str as workaround for #709 and #710 and #712 yield str(tmpdir) finally: os.path.exists(tmpdir) and rmtree(rmtree_safe(tmpdir)) def easy_install(self, spec, deps=False): if not self.editable: self.install_site_py() with self._tmpdir() as tmpdir: if not isinstance(spec, Requirement): if URL_SCHEME(spec): # It's a url, download it to tmpdir and process self.not_editable(spec) dl = self.package_index.download(spec, tmpdir) return self.install_item(None, dl, tmpdir, deps, True) elif os.path.exists(spec): # Existing file or directory, just process it directly self.not_editable(spec) return self.install_item(None, spec, tmpdir, deps, True) else: spec = parse_requirement_arg(spec) self.check_editable(spec) dist = self.package_index.fetch_distribution( spec, tmpdir, self.upgrade, self.editable, not self.always_copy, self.local_index ) if dist is None: msg = "Could not find suitable distribution for %r" % spec if self.always_copy: msg += " (--always-copy skips system and development eggs)" raise DistutilsError(msg) elif dist.precedence == DEVELOP_DIST: # .egg-info dists don't need installing, just process deps self.process_distribution(spec, dist, deps, "Using") return dist else: return self.install_item(spec, dist.location, tmpdir, deps) def install_item(self, spec, download, tmpdir, deps, install_needed=False): # Installation is also needed if file in tmpdir or is not an egg install_needed = install_needed or self.always_copy install_needed = install_needed or os.path.dirname(download) == tmpdir install_needed = install_needed or not download.endswith('.egg') install_needed = install_needed or ( self.always_copy_from is not None and os.path.dirname(normalize_path(download)) == normalize_path(self.always_copy_from) ) if spec and not install_needed: # at this point, we know it's a local .egg, we just don't know if # it's already installed. for dist in self.local_index[spec.project_name]: if dist.location == download: break else: install_needed = True # it's not in the local index log.info("Processing %s", os.path.basename(download)) if install_needed: dists = self.install_eggs(spec, download, tmpdir) for dist in dists: self.process_distribution(spec, dist, deps) else: dists = [self.egg_distribution(download)] self.process_distribution(spec, dists[0], deps, "Using") if spec is not None: for dist in dists: if dist in spec: return dist def select_scheme(self, name): """Sets the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! scheme = INSTALL_SCHEMES[name] for key in SCHEME_KEYS: attrname = 'install_' + key if getattr(self, attrname) is None: setattr(self, attrname, scheme[key]) def process_distribution(self, requirement, dist, deps=True, *info): self.update_pth(dist) self.package_index.add(dist) if dist in self.local_index[dist.key]: self.local_index.remove(dist) self.local_index.add(dist) self.install_egg_scripts(dist) self.installed_projects[dist.key] = dist log.info(self.installation_report(requirement, dist, *info)) if (dist.has_metadata('dependency_links.txt') and not self.no_find_links): self.package_index.add_find_links( dist.get_metadata_lines('dependency_links.txt') ) if not deps and not self.always_copy: return elif requirement is not None and dist.key != requirement.key: log.warn("Skipping dependencies for %s", dist) return # XXX this is not the distribution we were looking for elif requirement is None or dist not in requirement: # if we wound up with a different version, resolve what we've got distreq = dist.as_requirement() requirement = Requirement(str(distreq)) log.info("Processing dependencies for %s", requirement) try: distros = WorkingSet([]).resolve( [requirement], self.local_index, self.easy_install ) except DistributionNotFound as e: raise DistutilsError(str(e)) except VersionConflict as e: raise DistutilsError(e.report()) if self.always_copy or self.always_copy_from: # Force all the relevant distros to be copied or activated for dist in distros: if dist.key not in self.installed_projects: self.easy_install(dist.as_requirement()) log.info("Finished processing dependencies for %s", requirement) def should_unzip(self, dist): if self.zip_ok is not None: return not self.zip_ok if dist.has_metadata('not-zip-safe'): return True if not dist.has_metadata('zip-safe'): return True return False def maybe_move(self, spec, dist_filename, setup_base): dst = os.path.join(self.build_directory, spec.key) if os.path.exists(dst): msg = ( "%r already exists in %s; build directory %s will not be kept" ) log.warn(msg, spec.key, self.build_directory, setup_base) return setup_base if os.path.isdir(dist_filename): setup_base = dist_filename else: if os.path.dirname(dist_filename) == setup_base: os.unlink(dist_filename) # get it out of the tmp dir contents = os.listdir(setup_base) if len(contents) == 1: dist_filename = os.path.join(setup_base, contents[0]) if os.path.isdir(dist_filename): # if the only thing there is a directory, move it instead setup_base = dist_filename ensure_directory(dst) shutil.move(setup_base, dst) return dst def install_wrapper_scripts(self, dist): if self.exclude_scripts: return for args in ScriptWriter.best().get_args(dist): self.write_script(*args) def install_script(self, dist, script_name, script_text, dev_path=None): """Generate a legacy script wrapper and install it""" spec = str(dist.as_requirement()) is_script = is_python_script(script_text, script_name) if is_script: body = self._load_template(dev_path) % locals() script_text = ScriptWriter.get_header(script_text) + body self.write_script(script_name, _to_ascii(script_text), 'b') @staticmethod def _load_template(dev_path): """ There are a couple of template scripts in the package. This function loads one of them and prepares it for use. """ # See https://github.com/pypa/setuptools/issues/134 for info # on script file naming and downstream issues with SVR4 name = 'script.tmpl' if dev_path: name = name.replace('.tmpl', ' (dev).tmpl') raw_bytes = resource_string('setuptools', name) return raw_bytes.decode('utf-8') def write_script(self, script_name, contents, mode="t", blockers=()): """Write an executable file to the scripts directory""" self.delete_blockers( # clean up old .py/.pyw w/o a script [os.path.join(self.script_dir, x) for x in blockers] ) log.info("Installing %s script to %s", script_name, self.script_dir) target = os.path.join(self.script_dir, script_name) self.add_output(target) if self.dry_run: return mask = current_umask() ensure_directory(target) if os.path.exists(target): os.unlink(target) with open(target, "w" + mode) as f: f.write(contents) chmod(target, 0o777 - mask) def install_eggs(self, spec, dist_filename, tmpdir): # .egg dirs or files are already built, so just return them if dist_filename.lower().endswith('.egg'): return [self.install_egg(dist_filename, tmpdir)] elif dist_filename.lower().endswith('.exe'): return [self.install_exe(dist_filename, tmpdir)] elif dist_filename.lower().endswith('.whl'): return [self.install_wheel(dist_filename, tmpdir)] # Anything else, try to extract and build setup_base = tmpdir if os.path.isfile(dist_filename) and not dist_filename.endswith('.py'): unpack_archive(dist_filename, tmpdir, self.unpack_progress) elif os.path.isdir(dist_filename): setup_base = os.path.abspath(dist_filename) if (setup_base.startswith(tmpdir) # something we downloaded and self.build_directory and spec is not None): setup_base = self.maybe_move(spec, dist_filename, setup_base) # Find the setup.py file setup_script = os.path.join(setup_base, 'setup.py') if not os.path.exists(setup_script): setups = glob(os.path.join(setup_base, '*', 'setup.py')) if not setups: raise DistutilsError( "Couldn't find a setup script in %s" % os.path.abspath(dist_filename) ) if len(setups) > 1: raise DistutilsError( "Multiple setup scripts in %s" % os.path.abspath(dist_filename) ) setup_script = setups[0] # Now run it, and return the result if self.editable: log.info(self.report_editable(spec, setup_script)) return [] else: return self.build_and_install(setup_script, setup_base) def egg_distribution(self, egg_path): if os.path.isdir(egg_path): metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO')) else: metadata = EggMetadata(zipimport.zipimporter(egg_path)) return Distribution.from_filename(egg_path, metadata=metadata) def install_egg(self, egg_path, tmpdir): destination = os.path.join( self.install_dir, os.path.basename(egg_path), ) destination = os.path.abspath(destination) if not self.dry_run: ensure_directory(destination) dist = self.egg_distribution(egg_path) if not samefile(egg_path, destination): if os.path.isdir(destination) and not os.path.islink(destination): dir_util.remove_tree(destination, dry_run=self.dry_run) elif os.path.exists(destination): self.execute( os.unlink, (destination,), "Removing " + destination, ) try: new_dist_is_zipped = False if os.path.isdir(egg_path): if egg_path.startswith(tmpdir): f, m = shutil.move, "Moving" else: f, m = shutil.copytree, "Copying" elif self.should_unzip(dist): self.mkpath(destination) f, m = self.unpack_and_compile, "Extracting" else: new_dist_is_zipped = True if egg_path.startswith(tmpdir): f, m = shutil.move, "Moving" else: f, m = shutil.copy2, "Copying" self.execute( f, (egg_path, destination), (m + " %s to %s") % ( os.path.basename(egg_path), os.path.dirname(destination) ), ) update_dist_caches( destination, fix_zipimporter_caches=new_dist_is_zipped, ) except Exception: update_dist_caches(destination, fix_zipimporter_caches=False) raise self.add_output(destination) return self.egg_distribution(destination) def install_exe(self, dist_filename, tmpdir): # See if it's valid, get data cfg = extract_wininst_cfg(dist_filename) if cfg is None: raise DistutilsError( "%s is not a valid distutils Windows .exe" % dist_filename ) # Create a dummy distribution object until we build the real distro dist = Distribution( None, project_name=cfg.get('metadata', 'name'), version=cfg.get('metadata', 'version'), platform=get_platform(), ) # Convert the .exe to an unpacked egg egg_path = os.path.join(tmpdir, dist.egg_name() + '.egg') dist.location = egg_path egg_tmp = egg_path + '.tmp' _egg_info = os.path.join(egg_tmp, 'EGG-INFO') pkg_inf = os.path.join(_egg_info, 'PKG-INFO') ensure_directory(pkg_inf) # make sure EGG-INFO dir exists dist._provider = PathMetadata(egg_tmp, _egg_info) # XXX self.exe_to_egg(dist_filename, egg_tmp) # Write EGG-INFO/PKG-INFO if not os.path.exists(pkg_inf): f = open(pkg_inf, 'w') f.write('Metadata-Version: 1.0\n') for k, v in cfg.items('metadata'): if k != 'target_version': f.write('%s: %s\n' % (k.replace('_', '-').title(), v)) f.close() script_dir = os.path.join(_egg_info, 'scripts') # delete entry-point scripts to avoid duping self.delete_blockers([ os.path.join(script_dir, args[0]) for args in ScriptWriter.get_args(dist) ]) # Build .egg file from tmpdir bdist_egg.make_zipfile( egg_path, egg_tmp, verbose=self.verbose, dry_run=self.dry_run, ) # install the .egg return self.install_egg(egg_path, tmpdir) def exe_to_egg(self, dist_filename, egg_tmp): """Extract a bdist_wininst to the directories an egg would use""" # Check for .pth file and set up prefix translations prefixes = get_exe_prefixes(dist_filename) to_compile = [] native_libs = [] top_level = {} def process(src, dst): s = src.lower() for old, new in prefixes: if s.startswith(old): src = new + src[len(old):] parts = src.split('/') dst = os.path.join(egg_tmp, *parts) dl = dst.lower() if dl.endswith('.pyd') or dl.endswith('.dll'): parts[-1] = bdist_egg.strip_module(parts[-1]) top_level[os.path.splitext(parts[0])[0]] = 1 native_libs.append(src) elif dl.endswith('.py') and old != 'SCRIPTS/': top_level[os.path.splitext(parts[0])[0]] = 1 to_compile.append(dst) return dst if not src.endswith('.pth'): log.warn("WARNING: can't process %s", src) return None # extract, tracking .pyd/.dll->native_libs and .py -> to_compile unpack_archive(dist_filename, egg_tmp, process) stubs = [] for res in native_libs: if res.lower().endswith('.pyd'): # create stubs for .pyd's parts = res.split('/') resource = parts[-1] parts[-1] = bdist_egg.strip_module(parts[-1]) + '.py' pyfile = os.path.join(egg_tmp, *parts) to_compile.append(pyfile) stubs.append(pyfile) bdist_egg.write_stub(resource, pyfile) self.byte_compile(to_compile) # compile .py's bdist_egg.write_safety_flag( os.path.join(egg_tmp, 'EGG-INFO'), bdist_egg.analyze_egg(egg_tmp, stubs)) # write zip-safety flag for name in 'top_level', 'native_libs': if locals()[name]: txt = os.path.join(egg_tmp, 'EGG-INFO', name + '.txt') if not os.path.exists(txt): f = open(txt, 'w') f.write('\n'.join(locals()[name]) + '\n') f.close() def install_wheel(self, wheel_path, tmpdir): wheel = Wheel(wheel_path) assert wheel.is_compatible() destination = os.path.join(self.install_dir, wheel.egg_name()) destination = os.path.abspath(destination) if not self.dry_run: ensure_directory(destination) if os.path.isdir(destination) and not os.path.islink(destination): dir_util.remove_tree(destination, dry_run=self.dry_run) elif os.path.exists(destination): self.execute( os.unlink, (destination,), "Removing " + destination, ) try: self.execute( wheel.install_as_egg, (destination,), ("Installing %s to %s") % ( os.path.basename(wheel_path), os.path.dirname(destination) ), ) finally: update_dist_caches(destination, fix_zipimporter_caches=False) self.add_output(destination) return self.egg_distribution(destination) __mv_warning = textwrap.dedent(""" Because this distribution was installed --multi-version, before you can import modules from this package in an application, you will need to 'import pkg_resources' and then use a 'require()' call similar to one of these examples, in order to select the desired version: pkg_resources.require("%(name)s") # latest installed version pkg_resources.require("%(name)s==%(version)s") # this exact version pkg_resources.require("%(name)s>=%(version)s") # this version or higher """).lstrip() __id_warning = textwrap.dedent(""" Note also that the installation directory must be on sys.path at runtime for this to work. (e.g. by being the application's script directory, by being on PYTHONPATH, or by being added to sys.path by your code.) """) def installation_report(self, req, dist, what="Installed"): """Helpful installation message for display to package users""" msg = "\n%(what)s %(eggloc)s%(extras)s" if self.multi_version and not self.no_report: msg += '\n' + self.__mv_warning if self.install_dir not in map(normalize_path, sys.path): msg += '\n' + self.__id_warning eggloc = dist.location name = dist.project_name version = dist.version extras = '' # TODO: self.report_extras(req, dist) return msg % locals() __editable_msg = textwrap.dedent(""" Extracted editable version of %(spec)s to %(dirname)s If it uses setuptools in its setup script, you can activate it in "development" mode by going to that directory and running:: %(python)s setup.py develop See the setuptools documentation for the "develop" command for more info. """).lstrip() def report_editable(self, spec, setup_script): dirname = os.path.dirname(setup_script) python = sys.executable return '\n' + self.__editable_msg % locals() def run_setup(self, setup_script, setup_base, args): sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg) sys.modules.setdefault('distutils.command.egg_info', egg_info) args = list(args) if self.verbose > 2: v = 'v' * (self.verbose - 1) args.insert(0, '-' + v) elif self.verbose < 2: args.insert(0, '-q') if self.dry_run: args.insert(0, '-n') log.info( "Running %s %s", setup_script[len(setup_base) + 1:], ' '.join(args) ) try: run_setup(setup_script, args) except SystemExit as v: raise DistutilsError("Setup script exited with %s" % (v.args[0],)) def build_and_install(self, setup_script, setup_base): args = ['bdist_egg', '--dist-dir'] dist_dir = tempfile.mkdtemp( prefix='egg-dist-tmp-', dir=os.path.dirname(setup_script) ) try: self._set_fetcher_options(os.path.dirname(setup_script)) args.append(dist_dir) self.run_setup(setup_script, setup_base, args) all_eggs = Environment([dist_dir]) eggs = [] for key in all_eggs: for dist in all_eggs[key]: eggs.append(self.install_egg(dist.location, setup_base)) if not eggs and not self.dry_run: log.warn("No eggs found in %s (setup script problem?)", dist_dir) return eggs finally: rmtree(dist_dir) log.set_verbosity(self.verbose) # restore our log verbosity def _set_fetcher_options(self, base): """ When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well. """ # find the fetch options from easy_install and write them out # to the setup.cfg file. ei_opts = self.distribution.get_option_dict('easy_install').copy() fetch_directives = ( 'find_links', 'site_dirs', 'index_url', 'optimize', 'site_dirs', 'allow_hosts', ) fetch_options = {} for key, val in ei_opts.items(): if key not in fetch_directives: continue fetch_options[key.replace('_', '-')] = val[1] # create a settings dictionary suitable for `edit_config` settings = dict(easy_install=fetch_options) cfg_filename = os.path.join(base, 'setup.cfg') setopt.edit_config(cfg_filename, settings) def update_pth(self, dist): if self.pth_file is None: return for d in self.pth_file[dist.key]: # drop old entries if self.multi_version or d.location != dist.location: log.info("Removing %s from easy-install.pth file", d) self.pth_file.remove(d) if d.location in self.shadow_path: self.shadow_path.remove(d.location) if not self.multi_version: if dist.location in self.pth_file.paths: log.info( "%s is already the active version in easy-install.pth", dist, ) else: log.info("Adding %s to easy-install.pth file", dist) self.pth_file.add(dist) # add new entry if dist.location not in self.shadow_path: self.shadow_path.append(dist.location) if not self.dry_run: self.pth_file.save() if dist.key == 'setuptools': # Ensure that setuptools itself never becomes unavailable! # XXX should this check for latest version? filename = os.path.join(self.install_dir, 'setuptools.pth') if os.path.islink(filename): os.unlink(filename) f = open(filename, 'wt') f.write(self.pth_file.make_relative(dist.location) + '\n') f.close() def unpack_progress(self, src, dst): # Progress filter for unpacking log.debug("Unpacking %s to %s", src, dst) return dst # only unpack-and-compile skips files for dry run def unpack_and_compile(self, egg_path, destination): to_compile = [] to_chmod = [] def pf(src, dst): if dst.endswith('.py') and not src.startswith('EGG-INFO/'): to_compile.append(dst) elif dst.endswith('.dll') or dst.endswith('.so'): to_chmod.append(dst) self.unpack_progress(src, dst) return not self.dry_run and dst or None unpack_archive(egg_path, destination, pf) self.byte_compile(to_compile) if not self.dry_run: for f in to_chmod: mode = ((os.stat(f)[stat.ST_MODE]) | 0o555) & 0o7755 chmod(f, mode) def byte_compile(self, to_compile): if sys.dont_write_bytecode: return from distutils.util import byte_compile try: # try to make the byte compile messages quieter log.set_verbosity(self.verbose - 1) byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run) if self.optimize: byte_compile( to_compile, optimize=self.optimize, force=1, dry_run=self.dry_run, ) finally: log.set_verbosity(self.verbose) # restore original verbosity __no_default_msg = textwrap.dedent(""" bad install directory or PYTHONPATH You are attempting to install a package to a directory that is not on PYTHONPATH and which Python does not read ".pth" files from. The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s and your PYTHONPATH environment variable currently contains: %r Here are some of your options for correcting the problem: * You can choose a different installation directory, i.e., one that is on PYTHONPATH or supports .pth files * You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python and want to use the package(s) you are installing.) * You can set up the installation directory to support ".pth" files by using one of the approaches described here: https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again.""").lstrip() def no_default_version_msg(self): template = self.__no_default_msg return template % (self.install_dir, os.environ.get('PYTHONPATH', '')) def install_site_py(self): """Make sure there's a site.py in the target dir, if needed""" if self.sitepy_installed: return # already did it, or don't need to sitepy = os.path.join(self.install_dir, "site.py") source = resource_string("setuptools", "site-patch.py") source = source.decode('utf-8') current = "" if os.path.exists(sitepy): log.debug("Checking existing site.py in %s", self.install_dir) with io.open(sitepy) as strm: current = strm.read() if not current.startswith('def __boot():'): raise DistutilsError( "%s is not a setuptools-generated site.py; please" " remove it." % sitepy ) if current != source: log.info("Creating %s", sitepy) if not self.dry_run: ensure_directory(sitepy) with io.open(sitepy, 'w', encoding='utf-8') as strm: strm.write(source) self.byte_compile([sitepy]) self.sitepy_installed = True def create_home_path(self): """Create directories under ~.""" if not self.user: return home = convert_path(os.path.expanduser("~")) for name, path in six.iteritems(self.config_vars): if path.startswith(home) and not os.path.isdir(path): self.debug_print("os.makedirs('%s', 0o700)" % path) os.makedirs(path, 0o700) INSTALL_SCHEMES = dict( posix=dict( install_dir='$base/lib/python$py_version_short/site-packages', script_dir='$base/bin', ), ) DEFAULT_SCHEME = dict( install_dir='$base/Lib/site-packages', script_dir='$base/Scripts', ) def _expand(self, *attrs): config_vars = self.get_finalized_command('install').config_vars if self.prefix: # Set default install_dir/scripts from --prefix config_vars = config_vars.copy() config_vars['base'] = self.prefix scheme = self.INSTALL_SCHEMES.get(os.name, self.DEFAULT_SCHEME) for attr, val in scheme.items(): if getattr(self, attr, None) is None: setattr(self, attr, val) from distutils.util import subst_vars for attr in attrs: val = getattr(self, attr) if val is not None: val = subst_vars(val, config_vars) if os.name == 'posix': val = os.path.expanduser(val) setattr(self, attr, val) def _pythonpath(): items = os.environ.get('PYTHONPATH', '').split(os.pathsep) return filter(None, items) def get_site_dirs(): """ Return a list of 'site' dirs """ sitedirs = [] # start with PYTHONPATH sitedirs.extend(_pythonpath()) prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(sys.exec_prefix) for prefix in prefixes: if prefix: if sys.platform in ('os2emx', 'riscos'): sitedirs.append(os.path.join(prefix, "Lib", "site-packages")) elif os.sep == '/': sitedirs.extend([ os.path.join( prefix, "lib", "python" + sys.version[:3], "site-packages", ), os.path.join(prefix, "lib", "site-python"), ]) else: sitedirs.extend([ prefix, os.path.join(prefix, "lib", "site-packages"), ]) if sys.platform == 'darwin': # for framework builds *only* we add the standard Apple # locations. Currently only per-user, but /Library and # /Network/Library could be added too if 'Python.framework' in prefix: home = os.environ.get('HOME') if home: home_sp = os.path.join( home, 'Library', 'Python', sys.version[:3], 'site-packages', ) sitedirs.append(home_sp) lib_paths = get_path('purelib'), get_path('platlib') for site_lib in lib_paths: if site_lib not in sitedirs: sitedirs.append(site_lib) if site.ENABLE_USER_SITE: sitedirs.append(site.USER_SITE) try: sitedirs.extend(site.getsitepackages()) except AttributeError: pass sitedirs = list(map(normalize_path, sitedirs)) return sitedirs def expand_paths(inputs): """Yield sys.path directories that might contain "old-style" packages""" seen = {} for dirname in inputs: dirname = normalize_path(dirname) if dirname in seen: continue seen[dirname] = 1 if not os.path.isdir(dirname): continue files = os.listdir(dirname) yield dirname, files for name in files: if not name.endswith('.pth'): # We only care about the .pth files continue if name in ('easy-install.pth', 'setuptools.pth'): # Ignore .pth files that we control continue # Read the .pth file f = open(os.path.join(dirname, name)) lines = list(yield_lines(f)) f.close() # Yield existing non-dupe, non-import directory lines from it for line in lines: if not line.startswith("import"): line = normalize_path(line.rstrip()) if line not in seen: seen[line] = 1 if not os.path.isdir(line): continue yield line, os.listdir(line) def extract_wininst_cfg(dist_filename): """Extract configuration data from a bdist_wininst .exe Returns a configparser.RawConfigParser, or None """ f = open(dist_filename, 'rb') try: endrec = zipfile._EndRecData(f) if endrec is None: return None prepended = (endrec[9] - endrec[5]) - endrec[6] if prepended < 12: # no wininst data here return None f.seek(prepended - 12) tag, cfglen, bmlen = struct.unpack("egg path translations for a given .exe file""" prefixes = [ ('PURELIB/', ''), ('PLATLIB/pywin32_system32', ''), ('PLATLIB/', ''), ('SCRIPTS/', 'EGG-INFO/scripts/'), ('DATA/lib/site-packages', ''), ] z = zipfile.ZipFile(exe_filename) try: for info in z.infolist(): name = info.filename parts = name.split('/') if len(parts) == 3 and parts[2] == 'PKG-INFO': if parts[1].endswith('.egg-info'): prefixes.insert(0, ('/'.join(parts[:2]), 'EGG-INFO/')) break if len(parts) != 2 or not name.endswith('.pth'): continue if name.endswith('-nspkg.pth'): continue if parts[0].upper() in ('PURELIB', 'PLATLIB'): contents = z.read(name) if six.PY3: contents = contents.decode() for pth in yield_lines(contents): pth = pth.strip().replace('\\', '/') if not pth.startswith('import'): prefixes.append((('%s/%s/' % (parts[0], pth)), '')) finally: z.close() prefixes = [(x.lower(), y) for x, y in prefixes] prefixes.sort() prefixes.reverse() return prefixes class PthDistributions(Environment): """A .pth file with Distribution paths in it""" dirty = False def __init__(self, filename, sitedirs=()): self.filename = filename self.sitedirs = list(map(normalize_path, sitedirs)) self.basedir = normalize_path(os.path.dirname(self.filename)) self._load() Environment.__init__(self, [], None, None) for path in yield_lines(self.paths): list(map(self.add, find_distributions(path, True))) def _load(self): self.paths = [] saw_import = False seen = dict.fromkeys(self.sitedirs) if os.path.isfile(self.filename): f = open(self.filename, 'rt') for line in f: if line.startswith('import'): saw_import = True continue path = line.rstrip() self.paths.append(path) if not path.strip() or path.strip().startswith('#'): continue # skip non-existent paths, in case somebody deleted a package # manually, and duplicate paths as well path = self.paths[-1] = normalize_path( os.path.join(self.basedir, path) ) if not os.path.exists(path) or path in seen: self.paths.pop() # skip it self.dirty = True # we cleaned up, so we're dirty now :) continue seen[path] = 1 f.close() if self.paths and not saw_import: self.dirty = True # ensure anything we touch has import wrappers while self.paths and not self.paths[-1].strip(): self.paths.pop() def save(self): """Write changed .pth file back to disk""" if not self.dirty: return rel_paths = list(map(self.make_relative, self.paths)) if rel_paths: log.debug("Saving %s", self.filename) lines = self._wrap_lines(rel_paths) data = '\n'.join(lines) + '\n' if os.path.islink(self.filename): os.unlink(self.filename) with open(self.filename, 'wt') as f: f.write(data) elif os.path.exists(self.filename): log.debug("Deleting empty %s", self.filename) os.unlink(self.filename) self.dirty = False @staticmethod def _wrap_lines(lines): return lines def add(self, dist): """Add `dist` to the distribution map""" new_path = ( dist.location not in self.paths and ( dist.location not in self.sitedirs or # account for '.' being in PYTHONPATH dist.location == os.getcwd() ) ) if new_path: self.paths.append(dist.location) self.dirty = True Environment.add(self, dist) def remove(self, dist): """Remove `dist` from the distribution map""" while dist.location in self.paths: self.paths.remove(dist.location) self.dirty = True Environment.remove(self, dist) def make_relative(self, path): npath, last = os.path.split(normalize_path(path)) baselen = len(self.basedir) parts = [last] sep = os.altsep == '/' and '/' or os.sep while len(npath) >= baselen: if npath == self.basedir: parts.append(os.curdir) parts.reverse() return sep.join(parts) npath, last = os.path.split(npath) parts.append(last) else: return path class RewritePthDistributions(PthDistributions): @classmethod def _wrap_lines(cls, lines): yield cls.prelude for line in lines: yield line yield cls.postlude prelude = _one_liner(""" import sys sys.__plen = len(sys.path) """) postlude = _one_liner(""" import sys new = sys.path[sys.__plen:] del sys.path[sys.__plen:] p = getattr(sys, '__egginsert', 0) sys.path[p:p] = new sys.__egginsert = p + len(new) """) if os.environ.get('SETUPTOOLS_SYS_PATH_TECHNIQUE', 'raw') == 'rewrite': PthDistributions = RewritePthDistributions def _first_line_re(): """ Return a regular expression based on first_line_re suitable for matching strings. """ if isinstance(first_line_re.pattern, str): return first_line_re # first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern. return re.compile(first_line_re.pattern.decode()) def auto_chmod(func, arg, exc): if func in [os.unlink, os.remove] and os.name == 'nt': chmod(arg, stat.S_IWRITE) return func(arg) et, ev, _ = sys.exc_info() six.reraise(et, (ev[0], ev[1] + (" %s %s" % (func, arg)))) def update_dist_caches(dist_path, fix_zipimporter_caches): """ Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data from the original distribution. Any such finders need to be cleared since the replacement distribution might be packaged differently, e.g. a zipped egg distribution might get replaced with an unzipped egg folder or vice versa. Having the old finders cached may then cause Python to attempt loading modules from the replacement distribution using an incorrect loader. zipimport.zipimporter objects are Python loaders charged with importing data packaged inside zip archives. If stale loaders referencing the original distribution, are left behind, they can fail to load modules from the replacement distribution. E.g. if an old zipimport.zipimporter instance is used to load data from a new zipped egg archive, it may cause the operation to attempt to locate the requested data in the wrong location - one indicated by the original distribution's zip archive directory information. Such an operation may then fail outright, e.g. report having read a 'bad local file header', or even worse, it may fail silently & return invalid data. zipimport._zip_directory_cache contains cached zip archive directory information for all existing zipimport.zipimporter instances and all such instances connected to the same archive share the same cached directory information. If asked, and the underlying Python implementation allows it, we can fix all existing zipimport.zipimporter instances instead of having to track them down and remove them one by one, by updating their shared cached zip archive directory information. This, of course, assumes that the replacement distribution is packaged as a zipped egg. If not asked to fix existing zipimport.zipimporter instances, we still do our best to clear any remaining zipimport.zipimporter related cached data that might somehow later get used when attempting to load data from the new distribution and thus cause such load operations to fail. Note that when tracking down such remaining stale data, we can not catch every conceivable usage from here, and we clear only those that we know of and have found to cause problems if left alive. Any remaining caches should be updated by whomever is in charge of maintaining them, i.e. they should be ready to handle us replacing their zip archives with new distributions at runtime. """ # There are several other known sources of stale zipimport.zipimporter # instances that we do not clear here, but might if ever given a reason to # do so: # * Global setuptools pkg_resources.working_set (a.k.a. 'master working # set') may contain distributions which may in turn contain their # zipimport.zipimporter loaders. # * Several zipimport.zipimporter loaders held by local variables further # up the function call stack when running the setuptools installation. # * Already loaded modules may have their __loader__ attribute set to the # exact loader instance used when importing them. Python 3.4 docs state # that this information is intended mostly for introspection and so is # not expected to cause us problems. normalized_path = normalize_path(dist_path) _uncache(normalized_path, sys.path_importer_cache) if fix_zipimporter_caches: _replace_zip_directory_cache_data(normalized_path) else: # Here, even though we do not want to fix existing and now stale # zipimporter cache information, we still want to remove it. Related to # Python's zip archive directory information cache, we clear each of # its stale entries in two phases: # 1. Clear the entry so attempting to access zip archive information # via any existing stale zipimport.zipimporter instances fails. # 2. Remove the entry from the cache so any newly constructed # zipimport.zipimporter instances do not end up using old stale # zip archive directory information. # This whole stale data removal step does not seem strictly necessary, # but has been left in because it was done before we started replacing # the zip archive directory information cache content if possible, and # there are no relevant unit tests that we can depend on to tell us if # this is really needed. _remove_and_clear_zip_directory_cache_data(normalized_path) def _collect_zipimporter_cache_entries(normalized_path, cache): """ Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any sub-path entries are included as well, i.e. those corresponding to zip archives embedded in other zip archives. """ result = [] prefix_len = len(normalized_path) for p in cache: np = normalize_path(p) if (np.startswith(normalized_path) and np[prefix_len:prefix_len + 1] in (os.sep, '')): result.append(p) return result def _update_zipimporter_cache(normalized_path, cache, updater=None): """ Update zipimporter cache data for a given normalized path. Any sub-path entries are processed as well, i.e. those corresponding to zip archives embedded in other zip archives. Given updater is a callable taking a cache entry key and the original entry (after already removing the entry from the cache), and expected to update the entry and possibly return a new one to be inserted in its place. Returning None indicates that the entry should not be replaced with a new one. If no updater is given, the cache entries are simply removed without any additional processing, the same as if the updater simply returned None. """ for p in _collect_zipimporter_cache_entries(normalized_path, cache): # N.B. pypy's custom zipimport._zip_directory_cache implementation does # not support the complete dict interface: # * Does not support item assignment, thus not allowing this function # to be used only for removing existing cache entries. # * Does not support the dict.pop() method, forcing us to use the # get/del patterns instead. For more detailed information see the # following links: # https://github.com/pypa/setuptools/issues/202#issuecomment-202913420 # http://bit.ly/2h9itJX old_entry = cache[p] del cache[p] new_entry = updater and updater(p, old_entry) if new_entry is not None: cache[p] = new_entry def _uncache(normalized_path, cache): _update_zipimporter_cache(normalized_path, cache) def _remove_and_clear_zip_directory_cache_data(normalized_path): def clear_and_remove_cached_zip_archive_directory_data(path, old_entry): old_entry.clear() _update_zipimporter_cache( normalized_path, zipimport._zip_directory_cache, updater=clear_and_remove_cached_zip_archive_directory_data) # PyPy Python implementation does not allow directly writing to the # zipimport._zip_directory_cache and so prevents us from attempting to correct # its content. The best we can do there is clear the problematic cache content # and have PyPy repopulate it as needed. The downside is that if there are any # stale zipimport.zipimporter instances laying around, attempting to use them # will fail due to not having its zip archive directory information available # instead of being automatically corrected to use the new correct zip archive # directory information. if '__pypy__' in sys.builtin_module_names: _replace_zip_directory_cache_data = \ _remove_and_clear_zip_directory_cache_data else: def _replace_zip_directory_cache_data(normalized_path): def replace_cached_zip_archive_directory_data(path, old_entry): # N.B. In theory, we could load the zip directory information just # once for all updated path spellings, and then copy it locally and # update its contained path strings to contain the correct # spelling, but that seems like a way too invasive move (this cache # structure is not officially documented anywhere and could in # theory change with new Python releases) for no significant # benefit. old_entry.clear() zipimport.zipimporter(path) old_entry.update(zipimport._zip_directory_cache[path]) return old_entry _update_zipimporter_cache( normalized_path, zipimport._zip_directory_cache, updater=replace_cached_zip_archive_directory_data) def is_python(text, filename=''): "Is this string a valid Python script?" try: compile(text, filename, 'exec') except (SyntaxError, TypeError): return False else: return True def is_sh(executable): """Determine if the specified executable is a .sh (contains a #! line)""" try: with io.open(executable, encoding='latin-1') as fp: magic = fp.read(2) except (OSError, IOError): return executable return magic == '#!' def nt_quote_arg(arg): """Quote a command line argument according to Windows parsing rules""" return subprocess.list2cmdline([arg]) def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ if filename.endswith('.py') or filename.endswith('.pyw'): return True # extension says it's Python if is_python(script_text, filename): return True # it's syntactically valid Python if script_text.startswith('#!'): # It begins with a '#!' line, so check if 'python' is in it somewhere return 'python' in script_text.splitlines()[0].lower() return False # Not any Python I can recognize try: from os import chmod as _chmod except ImportError: # Jython compatibility def _chmod(*args): pass def chmod(path, mode): log.debug("changing mode of %s to %o", path, mode) try: _chmod(path, mode) except os.error as e: log.debug("chmod failed: %s", e) class CommandSpec(list): """ A command spec for a #! header, specified as a list of arguments akin to those passed to Popen. """ options = [] split_args = dict() @classmethod def best(cls): """ Choose the best CommandSpec class based on environmental conditions. """ return cls @classmethod def _sys_executable(cls): _default = os.path.normpath(sys.executable) return os.environ.get('__PYVENV_LAUNCHER__', _default) @classmethod def from_param(cls, param): """ Construct a CommandSpec from a parameter to build_scripts, which may be None. """ if isinstance(param, cls): return param if isinstance(param, list): return cls(param) if param is None: return cls.from_environment() # otherwise, assume it's a string. return cls.from_string(param) @classmethod def from_environment(cls): return cls([cls._sys_executable()]) @classmethod def from_string(cls, string): """ Construct a command spec from a simple string representing a command line parseable by shlex.split. """ items = shlex.split(string, **cls.split_args) return cls(items) def install_options(self, script_text): self.options = shlex.split(self._extract_options(script_text)) cmdline = subprocess.list2cmdline(self) if not isascii(cmdline): self.options[:0] = ['-x'] @staticmethod def _extract_options(orig_script): """ Extract any options from the first line of the script. """ first = (orig_script + '\n').splitlines()[0] match = _first_line_re().match(first) options = match.group(1) or '' if match else '' return options.strip() def as_header(self): return self._render(self + list(self.options)) @staticmethod def _strip_quotes(item): _QUOTES = '"\'' for q in _QUOTES: if item.startswith(q) and item.endswith(q): return item[1:-1] return item @staticmethod def _render(items): cmdline = subprocess.list2cmdline( CommandSpec._strip_quotes(item.strip()) for item in items) return '#!' + cmdline + '\n' # For pbr compat; will be removed in a future version. sys_executable = CommandSpec._sys_executable() class WindowsCommandSpec(CommandSpec): split_args = dict(posix=False) class ScriptWriter(object): """ Encapsulates behavior around writing entry point scripts for console and gui apps. """ template = textwrap.dedent(r""" # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r __requires__ = %(spec)r import re import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit( load_entry_point(%(spec)r, %(group)r, %(name)r)() ) """).lstrip() command_spec_class = CommandSpec @classmethod def get_script_args(cls, dist, executable=None, wininst=False): # for backward compatibility warnings.warn("Use get_args", DeprecationWarning) writer = (WindowsScriptWriter if wininst else ScriptWriter).best() header = cls.get_script_header("", executable, wininst) return writer.get_args(dist, header) @classmethod def get_script_header(cls, script_text, executable=None, wininst=False): # for backward compatibility warnings.warn("Use get_header", DeprecationWarning) if wininst: executable = "python.exe" cmd = cls.command_spec_class.best().from_param(executable) cmd.install_options(script_text) return cmd.as_header() @classmethod def get_args(cls, dist, header=None): """ Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. """ if header is None: header = cls.get_header() spec = str(dist.as_requirement()) for type_ in 'console', 'gui': group = type_ + '_scripts' for name, ep in dist.get_entry_map(group).items(): cls._ensure_safe_name(name) script_text = cls.template % locals() args = cls._get_script_args(type_, name, header, script_text) for res in args: yield res @staticmethod def _ensure_safe_name(name): """ Prevent paths in *_scripts entry point names. """ has_path_sep = re.search(r'[\\/]', name) if has_path_sep: raise ValueError("Path separators not allowed in script names") @classmethod def get_writer(cls, force_windows): # for backward compatibility warnings.warn("Use best", DeprecationWarning) return WindowsScriptWriter.best() if force_windows else cls.best() @classmethod def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls @classmethod def _get_script_args(cls, type_, name, header, script_text): # Simply write the stub with no extension. yield (name, header + script_text) @classmethod def get_header(cls, script_text="", executable=None): """Create a #! line, getting options (if any) from script_text""" cmd = cls.command_spec_class.best().from_param(executable) cmd.install_options(script_text) return cmd.as_header() class WindowsScriptWriter(ScriptWriter): command_spec_class = WindowsCommandSpec @classmethod def get_writer(cls): # for backward compatibility warnings.warn("Use best", DeprecationWarning) return cls.best() @classmethod def best(cls): """ Select the best ScriptWriter suitable for Windows """ writer_lookup = dict( executable=WindowsExecutableLauncherWriter, natural=cls, ) # for compatibility, use the executable launcher by default launcher = os.environ.get('SETUPTOOLS_LAUNCHER', 'executable') return writer_lookup[launcher] @classmethod def _get_script_args(cls, type_, name, header, script_text): "For Windows, add a .py extension" ext = dict(console='.pya', gui='.pyw')[type_] if ext not in os.environ['PATHEXT'].lower().split(';'): msg = ( "{ext} not listed in PATHEXT; scripts will not be " "recognized as executables." ).format(**locals()) warnings.warn(msg, UserWarning) old = ['.pya', '.py', '-script.py', '.pyc', '.pyo', '.pyw', '.exe'] old.remove(ext) header = cls._adjust_header(type_, header) blockers = [name + x for x in old] yield name + ext, header + script_text, 't', blockers @classmethod def _adjust_header(cls, type_, orig_header): """ Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is). """ pattern = 'pythonw.exe' repl = 'python.exe' if type_ == 'gui': pattern, repl = repl, pattern pattern_ob = re.compile(re.escape(pattern), re.IGNORECASE) new_header = pattern_ob.sub(string=orig_header, repl=repl) return new_header if cls._use_header(new_header) else orig_header @staticmethod def _use_header(new_header): """ Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system. """ clean_header = new_header[2:-1].strip('"') return sys.platform != 'win32' or find_executable(clean_header) class WindowsExecutableLauncherWriter(WindowsScriptWriter): @classmethod def _get_script_args(cls, type_, name, header, script_text): """ For Windows, add a .py extension and an .exe launcher """ if type_ == 'gui': launcher_type = 'gui' ext = '-script.pyw' old = ['.pyw'] else: launcher_type = 'cli' ext = '-script.py' old = ['.py', '.pyc', '.pyo'] hdr = cls._adjust_header(type_, header) blockers = [name + x for x in old] yield (name + ext, hdr + script_text, 't', blockers) yield ( name + '.exe', get_win_launcher(launcher_type), 'b' # write in binary mode ) if not is_64bit(): # install a manifest for the launcher to prevent Windows # from detecting it as an installer (which it will for # launchers like easy_install.exe). Consider only # adding a manifest for launchers detected as installers. # See Distribute #143 for details. m_name = name + '.exe.manifest' yield (m_name, load_launcher_manifest(name), 't') # for backward-compatibility get_script_args = ScriptWriter.get_script_args get_script_header = ScriptWriter.get_script_header def get_win_launcher(type): """ Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. """ launcher_fn = '%s.exe' % type if is_64bit(): launcher_fn = launcher_fn.replace(".", "-64.") else: launcher_fn = launcher_fn.replace(".", "-32.") return resource_string('setuptools', launcher_fn) def load_launcher_manifest(name): manifest = pkg_resources.resource_string(__name__, 'launcher manifest.xml') if six.PY2: return manifest % vars() else: return manifest.decode('utf-8') % vars() def rmtree(path, ignore_errors=False, onerror=auto_chmod): return shutil.rmtree(path, ignore_errors, onerror) def current_umask(): tmp = os.umask(0o022) os.umask(tmp) return tmp def bootstrap(): # This function is called when setuptools*.egg is run using /bin/sh import setuptools argv0 = os.path.dirname(setuptools.__path__[0]) sys.argv[0] = argv0 sys.argv.append(argv0) main() def main(argv=None, **kw): from setuptools import setup from setuptools.dist import Distribution class DistributionWithoutHelpCommands(Distribution): common_usage = "" def _show_help(self, *args, **kw): with _patch_usage(): Distribution._show_help(self, *args, **kw) if argv is None: argv = sys.argv[1:] with _patch_usage(): setup( script_args=['-q', 'easy_install', '-v'] + argv, script_name=sys.argv[0] or 'easy_install', distclass=DistributionWithoutHelpCommands, **kw ) @contextlib.contextmanager def _patch_usage(): import distutils.core USAGE = textwrap.dedent(""" usage: %(script)s [options] requirement_or_url ... or: %(script)s --help """).lstrip() def gen_usage(script_name): return USAGE % dict( script=os.path.basename(script_name), ) saved = distutils.core.gen_usage distutils.core.gen_usage = gen_usage try: yield finally: distutils.core.gen_usage = saved build_clib.py000064400000010604147210141470007210 0ustar00import distutils.command.build_clib as orig from distutils.errors import DistutilsSetupError from distutils import log from setuptools.dep_util import newer_pairwise_group class build_clib(orig.build_clib): """ Override the default build_clib behaviour to do the following: 1. Implement a rudimentary timestamp-based dependency system so 'compile()' doesn't run every time. 2. Add more keys to the 'build_info' dictionary: * obj_deps - specify dependencies for each object compiled. this should be a dictionary mapping a key with the source filename to a list of dependencies. Use an empty string for global dependencies. * cflags - specify a list of additional flags to pass to the compiler. """ def build_libraries(self, libraries): for (lib_name, build_info) in libraries: sources = build_info.get('sources') if sources is None or not isinstance(sources, (list, tuple)): raise DistutilsSetupError( "in 'libraries' option (library '%s'), " "'sources' must be present and must be " "a list of source filenames" % lib_name) sources = list(sources) log.info("building '%s' library", lib_name) # Make sure everything is the correct type. # obj_deps should be a dictionary of keys as sources # and a list/tuple of files that are its dependencies. obj_deps = build_info.get('obj_deps', dict()) if not isinstance(obj_deps, dict): raise DistutilsSetupError( "in 'libraries' option (library '%s'), " "'obj_deps' must be a dictionary of " "type 'source: list'" % lib_name) dependencies = [] # Get the global dependencies that are specified by the '' key. # These will go into every source's dependency list. global_deps = obj_deps.get('', list()) if not isinstance(global_deps, (list, tuple)): raise DistutilsSetupError( "in 'libraries' option (library '%s'), " "'obj_deps' must be a dictionary of " "type 'source: list'" % lib_name) # Build the list to be used by newer_pairwise_group # each source will be auto-added to its dependencies. for source in sources: src_deps = [source] src_deps.extend(global_deps) extra_deps = obj_deps.get(source, list()) if not isinstance(extra_deps, (list, tuple)): raise DistutilsSetupError( "in 'libraries' option (library '%s'), " "'obj_deps' must be a dictionary of " "type 'source: list'" % lib_name) src_deps.extend(extra_deps) dependencies.append(src_deps) expected_objects = self.compiler.object_filenames( sources, output_dir=self.build_temp ) if newer_pairwise_group(dependencies, expected_objects) != ([], []): # First, compile the source code to object files in the library # directory. (This should probably change to putting object # files in a temporary build directory.) macros = build_info.get('macros') include_dirs = build_info.get('include_dirs') cflags = build_info.get('cflags') objects = self.compiler.compile( sources, output_dir=self.build_temp, macros=macros, include_dirs=include_dirs, extra_postargs=cflags, debug=self.debug ) # Now "link" the object files together into a static library. # (On Unix at least, this isn't really linking -- it just # builds an archive. Whatever.) self.compiler.create_static_lib( expected_objects, lib_name, output_dir=self.build_clib, debug=self.debug ) install.py000064400000011113147210141470006562 0ustar00from distutils.errors import DistutilsArgError import inspect import glob import warnings import platform import distutils.command.install as orig import 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/ _install = orig.install class install(orig.install): """Use easy_install to install the package, w/dependencies""" user_options = orig.install.user_options + [ ('old-and-unmanageable', None, "Try not to use this!"), ('single-version-externally-managed', None, "used by system package builders to create 'flat' eggs"), ] boolean_options = orig.install.boolean_options + [ 'old-and-unmanageable', 'single-version-externally-managed', ] new_commands = [ ('install_egg_info', lambda self: True), ('install_scripts', lambda self: True), ] _nc = dict(new_commands) def initialize_options(self): orig.install.initialize_options(self) self.old_and_unmanageable = None self.single_version_externally_managed = None def finalize_options(self): orig.install.finalize_options(self) if self.root: self.single_version_externally_managed = True elif self.single_version_externally_managed: if not self.root and not self.record: raise DistutilsArgError( "You must specify --record or --root when building system" " packages" ) def handle_extra_path(self): if self.root or self.single_version_externally_managed: # explicit backward-compatibility mode, allow extra_path to work return orig.install.handle_extra_path(self) # Ignore extra_path when installing an egg (or being run by another # command without --root or --single-version-externally-managed self.path_file = None self.extra_dirs = '' def run(self): # Explicit request for old-style install? Just do it if self.old_and_unmanageable or self.single_version_externally_managed: return orig.install.run(self) if not self._called_from_setup(inspect.currentframe()): # Run in backward-compatibility mode to support bdist_* commands. orig.install.run(self) else: self.do_egg_install() @staticmethod def _called_from_setup(run_frame): """ Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any other way, the immediate caller *might* be 'run_command', but it won't have been called by 'run_commands'. Return True in that case or if a call stack is unavailable. Return False otherwise. """ if run_frame is None: msg = "Call stack not available. bdist_* commands may fail." warnings.warn(msg) if platform.python_implementation() == 'IronPython': msg = "For best results, pass -X:Frames to enable call stack." warnings.warn(msg) return True res = inspect.getouterframes(run_frame)[2] caller, = res[:1] info = inspect.getframeinfo(caller) caller_module = caller.f_globals.get('__name__', '') return ( caller_module == 'distutils.dist' and info.function == 'run_commands' ) def do_egg_install(self): easy_install = self.distribution.get_command_class('easy_install') cmd = easy_install( self.distribution, args="x", root=self.root, record=self.record, ) cmd.ensure_finalized() # finalize before bdist_egg munges install cmd cmd.always_copy_from = '.' # make sure local-dir eggs get installed # pick up setup-dir .egg files only: no .egg-info cmd.package_index.scan(glob.glob('*.egg')) self.run_command('bdist_egg') args = [self.distribution.get_command_obj('bdist_egg').egg_output] if setuptools.bootstrap_install_from: # Bootstrap self-installation of setuptools args.insert(0, setuptools.bootstrap_install_from) cmd.args = args cmd.run() setuptools.bootstrap_install_from = None # XXX Python 3.1 doesn't see _nc if this is inside the class install.sub_commands = ( [cmd for cmd in orig.install.sub_commands if cmd[0] not in install._nc] + install.new_commands ) develop.py000064400000017556147210141470006573 0ustar00from distutils.util import convert_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError import os import glob import io from setuptools.extern import six from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install from setuptools import namespaces import setuptools class develop(namespaces.DevelopInstaller, easy_install): """Set up package for development""" description = "install package in 'development mode'" user_options = easy_install.user_options + [ ("uninstall", "u", "Uninstall this source package"), ("egg-path=", None, "Set the path to be used in the .egg-link file"), ] boolean_options = easy_install.boolean_options + ['uninstall'] command_consumes_arguments = False # override base def run(self): if self.uninstall: self.multi_version = True self.uninstall_link() self.uninstall_namespaces() else: self.install_for_development() self.warn_deprecated_options() def initialize_options(self): self.uninstall = None self.egg_path = None easy_install.initialize_options(self) self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: template = "Please rename %r to %r before using 'develop'" args = ei.egg_info, ei.broken_egg_info raise DistutilsError(template % args) self.args = [ei.egg_name] easy_install.finalize_options(self) self.expand_basedirs() self.expand_dirs() # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) egg_link_fn = ei.egg_name + '.egg-link' self.egg_link = os.path.join(self.install_dir, egg_link_fn) self.egg_base = ei.egg_base if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) target = normalize_path(self.egg_base) egg_path = normalize_path(os.path.join(self.install_dir, self.egg_path)) if egg_path != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" " directory to " + target ) # Make a distribution for the package's source self.dist = Distribution( target, PathMetadata(target, os.path.abspath(ei.egg_info)), project_name=ei.egg_name ) self.setup_path = self._resolve_setup_path( self.egg_base, self.install_dir, self.egg_path, ) @staticmethod def _resolve_setup_path(egg_base, install_dir, egg_path): """ Generate a path from egg_base back to '.' where the setup script resides and ensure that path points to the setup path from $install_dir/$egg_path. """ path_to_setup = egg_base.replace(os.sep, '/').rstrip('/') if path_to_setup != os.curdir: path_to_setup = '../' * (path_to_setup.count('/') + 1) resolved = normalize_path( os.path.join(install_dir, egg_path, path_to_setup) ) if resolved != normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" " installation directory", resolved, normalize_path(os.curdir)) return path_to_setup def install_for_development(self): if six.PY3 and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date self.reinitialize_command('build_py', inplace=0) self.run_command('build_py') bpy_cmd = self.get_finalized_command("build_py") build_path = normalize_path(bpy_cmd.build_lib) # Build extensions self.reinitialize_command('egg_info', egg_base=build_path) self.run_command('egg_info') self.reinitialize_command('build_ext', inplace=0) self.run_command('build_ext') # Fixup egg-link and easy-install.pth ei_cmd = self.get_finalized_command("egg_info") self.egg_path = build_path self.dist.location = build_path # XXX self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) else: # Without 2to3 inplace works fine: self.run_command('egg_info') # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) setuptools.bootstrap_install_from = None self.install_namespaces() # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: with open(self.egg_link, "w") as f: f.write(self.egg_path + "\n" + self.setup_path) # postprocess the installed distro, fixing up .pth, installing scripts, # and handling requirements self.process_distribution(None, self.dist, not self.no_deps) def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) egg_link_file = open(self.egg_link) contents = [line.rstrip() for line in egg_link_file] egg_link_file.close() if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return if not self.dry_run: os.unlink(self.egg_link) if not self.dry_run: self.update_pth(self.dist) # remove any .pth link to us if self.distribution.scripts: # XXX should also check for entry point scripts! log.warn("Note: you must uninstall or replace scripts manually!") def install_egg_scripts(self, dist): if dist is not self.dist: # Installing a dependency, so fall back to normal behavior return easy_install.install_egg_scripts(self, dist) # create wrapper scripts in the script dir, pointing to dist.scripts # new-style... self.install_wrapper_scripts(dist) # ...and old-style for script_name in self.distribution.scripts or []: script_path = os.path.abspath(convert_path(script_name)) script_name = os.path.basename(script_path) with io.open(script_path) as strm: script_text = strm.read() self.install_script(dist, script_name, script_text, script_path) def install_wrapper_scripts(self, dist): dist = VersionlessRequirement(dist) return easy_install.install_wrapper_scripts(self, dist) class VersionlessRequirement(object): """ Adapt a pkg_resources.Distribution to simply return the project name as the 'requirement' so that scripts will work across multiple versions. >>> dist = Distribution(project_name='foo', version='1.0') >>> str(dist.as_requirement()) 'foo==1.0' >>> adapted_dist = VersionlessRequirement(dist) >>> str(adapted_dist.as_requirement()) 'foo' """ def __init__(self, dist): self.__dist = dist def __getattr__(self, name): return getattr(self.__dist, name) def as_requirement(self): return self.project_name sdist.py000064400000015067147210141470006256 0ustar00from distutils import log import distutils.command.sdist as orig import os import sys import io import contextlib from setuptools.extern import six from .py36compat import sdist_add_defaults import pkg_resources _default_revctrl = list def walk_revctrl(dirname=''): """Find all files under revision control""" for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): for item in ep.load()(dirname): yield item class sdist(sdist_add_defaults, orig.sdist): """Smart sdist that finds anything supported by revision control""" user_options = [ ('formats=', None, "formats for source distribution (comma-separated list)"), ('keep-temp', 'k', "keep the distribution tree around after creating " + "archive file(s)"), ('dist-dir=', 'd', "directory to put the source distribution archive(s) in " "[default: dist]"), ] negative_opt = {} README_EXTENSIONS = ['', '.rst', '.txt', '.md'] READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS) def run(self): self.run_command('egg_info') ei_cmd = self.get_finalized_command('egg_info') self.filelist = ei_cmd.filelist self.filelist.append(os.path.join(ei_cmd.egg_info, 'SOURCES.txt')) self.check_readme() # Run sub commands for cmd_name in self.get_sub_commands(): self.run_command(cmd_name) self.make_distribution() dist_files = getattr(self.distribution, 'dist_files', []) for file in self.archive_files: data = ('sdist', '', file) if data not in dist_files: dist_files.append(data) def initialize_options(self): orig.sdist.initialize_options(self) self._default_to_gztar() def _default_to_gztar(self): # only needed on Python prior to 3.6. if sys.version_info >= (3, 6, 0, 'beta', 1): return self.formats = ['gztar'] def make_distribution(self): """ Workaround for #516 """ with self._remove_os_link(): orig.sdist.make_distribution(self) @staticmethod @contextlib.contextmanager def _remove_os_link(): """ In a context, remove and restore os.link if it exists """ class NoValue: pass orig_val = getattr(os, 'link', NoValue) try: del os.link except Exception: pass try: yield finally: if orig_val is not NoValue: setattr(os, 'link', orig_val) def __read_template_hack(self): # This grody hack closes the template file (MANIFEST.in) if an # exception occurs during read_template. # Doing so prevents an error when easy_install attempts to delete the # file. try: orig.sdist.read_template(self) except Exception: _, _, tb = sys.exc_info() tb.tb_next.tb_frame.f_locals['template'].close() raise # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle # has been fixed, so only override the method if we're using an earlier # Python. has_leaky_handle = ( sys.version_info < (2, 7, 2) or (3, 0) <= sys.version_info < (3, 1, 4) or (3, 2) <= sys.version_info < (3, 2, 1) ) if has_leaky_handle: read_template = __read_template_hack def _add_defaults_python(self): """getting python files""" if self.distribution.has_pure_modules(): build_py = self.get_finalized_command('build_py') self.filelist.extend(build_py.get_source_files()) # This functionality is incompatible with include_package_data, and # will in fact create an infinite recursion if include_package_data # is True. Use of include_package_data will imply that # distutils-style automatic handling of package_data is disabled if not self.distribution.include_package_data: for _, src_dir, _, filenames in build_py.data_files: self.filelist.extend([os.path.join(src_dir, filename) for filename in filenames]) def _add_defaults_data_files(self): try: if six.PY2: sdist_add_defaults._add_defaults_data_files(self) else: super()._add_defaults_data_files() except TypeError: log.warn("data_files contains unexpected objects") def check_readme(self): for f in self.READMES: if os.path.exists(f): return else: self.warn( "standard file not found: should have one of " + ', '.join(self.READMES) ) def make_release_tree(self, base_dir, files): orig.sdist.make_release_tree(self, base_dir, files) # Save any egg_info command line options used to create this sdist dest = os.path.join(base_dir, 'setup.cfg') if hasattr(os, 'link') and os.path.exists(dest): # unlink and re-copy, since it might be hard-linked, and # we don't want to change the source version os.unlink(dest) self.copy_file('setup.cfg', dest) self.get_finalized_command('egg_info').save_version_info(dest) def _manifest_is_not_generated(self): # check for special comment used in 2.7.1 and higher if not os.path.isfile(self.manifest): return False with io.open(self.manifest, 'rb') as fp: first_line = fp.readline() return (first_line != '# file GENERATED by distutils, do NOT edit\n'.encode()) def read_manifest(self): """Read the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source distribution. """ log.info("reading manifest file '%s'", self.manifest) manifest = open(self.manifest, 'rb') for line in manifest: # The manifest must contain UTF-8. See #303. if six.PY3: try: line = line.decode('UTF-8') except UnicodeDecodeError: log.warn("%r not UTF-8 decodable -- skipping" % line) continue # ignore comments and blank lines line = line.strip() if line.startswith('#') or not line: continue self.filelist.append(line) manifest.close()