1 from distutils.command.install_lib import install_lib as _install_lib
4 class install_lib(_install_lib):
5 """Don't add compiled flags to filenames of non-Python files"""
7 def _bytecode_filenames (self, py_filenames):
9 for py_file in py_filenames:
10 if not py_file.endswith('.py'):
13 bytecode_files.append(py_file + "c")
15 bytecode_files.append(py_file + "o")
21 outfiles = self.install()
22 if outfiles is not None:
23 # always compile, in case we have any extension stubs to deal with
24 self.byte_compile(outfiles)
26 def get_exclusions(self):
28 nsp = self.distribution.namespace_packages
30 if (nsp and self.get_finalized_command('install')
31 .single_version_externally_managed
34 parts = pkg.split('.')
36 pkgdir = os.path.join(self.install_dir, *parts)
37 for f in '__init__.py', '__init__.pyc', '__init__.pyo':
38 exclude[os.path.join(pkgdir,f)] = 1
43 self, infile, outfile,
44 preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1
46 assert preserve_mode and preserve_times and not preserve_symlinks
47 exclude = self.get_exclusions()
50 return _install_lib.copy_tree(self, infile, outfile)
52 # Exclude namespace package __init__.py* files from the output
54 from setuptools.archive_util import unpack_directory
55 from distutils import log
61 log.warn("Skipping installation of %s (namespace package)",dst)
64 log.info("copying %s -> %s", src, os.path.dirname(dst))
68 unpack_directory(infile, outfile, pf)
71 def get_outputs(self):
72 outputs = _install_lib.get_outputs(self)
73 exclude = self.get_exclusions()
75 return [f for f in outputs if f not in exclude]