diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-26 11:27:58 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-26 11:27:58 -0400 |
commit | ad0047bdc836e58fd3700d48e6ce2ea4ace88000 (patch) | |
tree | c4bc3fbbe3b952642f47a2968bfeec5eb9d2afcf | |
parent | 07f47bd1fb3cc37cba770c5e8445569556ddb766 (diff) | |
parent | 985860672fe60758efe7da3661b229298754518b (diff) | |
download | python-setuptools-bitbucket-ad0047bdc836e58fd3700d48e6ce2ea4ace88000.tar.gz |
Merged in stevedower/setuptools (pull request #83)
Adds monkeypatching for msvc9compiler.find_vcvarsall() to look for a standalone compiler installation and improves the error message for missing VC installation.
-rw-r--r-- | CHANGES.txt | 6 | ||||
-rwxr-xr-x | setuptools/command/egg_info.py | 2 | ||||
-rwxr-xr-x | setuptools/command/install_egg_info.py | 2 | ||||
-rw-r--r-- | setuptools/command/install_lib.py | 83 |
4 files changed, 76 insertions, 17 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index a6e27372..3a0e6936 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -23,6 +23,12 @@ CHANGES Any users producing distributions with filenames that match those above case-insensitively, but not case-sensitively, should rename those files in their repository for better portability. +* Pull Request #72: When using ``single_version_externally_managed``, the + exclusion list now includes Python 3.2 ``__pycache__`` entries. +* Pull Request #76 and Pull Request #78: lines in top_level.txt are now + ordered deterministically. +* Issue #118: The egg-info directory is now no longer included in the list + of outputs. --- 5.8 diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 72493d0b..06764a17 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -389,7 +389,7 @@ def write_toplevel_names(cmd, basename, filename): for k in cmd.distribution.iter_distribution_names() ] ) - cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n') + cmd.write_file("top-level names", filename, '\n'.join(sorted(pkgs)) + '\n') def overwrite_arg(cmd, basename, filename): diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index fd0f118b..992709f1 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -27,7 +27,7 @@ class install_egg_info(Command): ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) - self.outputs = [self.target] + self.outputs = [] def run(self): self.run_command('egg_info') diff --git a/setuptools/command/install_lib.py b/setuptools/command/install_lib.py index d7e117f0..3cd16a8f 100644 --- a/setuptools/command/install_lib.py +++ b/setuptools/command/install_lib.py @@ -1,6 +1,7 @@ -import distutils.command.install_lib as orig import 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""" @@ -13,19 +14,71 @@ class install_lib(orig.install_lib): self.byte_compile(outfiles) def get_exclusions(self): - exclude = {} - nsp = self.distribution.namespace_packages - svem = (nsp and self.get_finalized_command('install') - .single_version_externally_managed) - if svem: - for pkg in nsp: - parts = pkg.split('.') - while parts: - pkgdir = os.path.join(self.install_dir, *parts) - for f in '__init__.py', '__init__.pyc', '__init__.pyo': - exclude[os.path.join(pkgdir, f)] = 1 - parts.pop() - return exclude + """ + 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.partition('.') + + 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' def copy_tree( self, infile, outfile, |