summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelvyn Sopacua <melvyn@magemana.nl>2014-07-05 17:43:39 +0200
committerMelvyn Sopacua <melvyn@magemana.nl>2014-07-05 17:43:39 +0200
commit0239a4da1d74ac9b5ff948ab88fabf8a59fbb6d4 (patch)
treeee0110f5fc197103ea3acd2a3a4bb3c4fee45168
parente0885a0f90ccf73ca2b7e219514ec7dd3259b865 (diff)
downloadpython-setuptools-bitbucket-0239a4da1d74ac9b5ff948ab88fabf8a59fbb6d4.tar.gz
Fix exclude list on python 3.2+
imp.get_tag() is only available on 3.2+. Since 2<x<3.2 are EOL we shall not worry. We could implement a local get_tag(), but the point is moot: this compilation tactic with __pycache__ subdirs and versioned import files is new to python 3.x, so hasattr() is sufficient.
-rw-r--r--setuptools/command/install_lib.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/setuptools/command/install_lib.py b/setuptools/command/install_lib.py
index d7e117f0..cf5375f6 100644
--- a/setuptools/command/install_lib.py
+++ b/setuptools/command/install_lib.py
@@ -1,6 +1,5 @@
import distutils.command.install_lib as orig
-import os
-
+import os, imp
class install_lib(orig.install_lib):
"""Don't add compiled flags to filenames of non-Python files"""
@@ -17,12 +16,24 @@ class install_lib(orig.install_lib):
nsp = self.distribution.namespace_packages
svem = (nsp and self.get_finalized_command('install')
.single_version_externally_managed)
+ exclude_names = ['__init__.py', '__init__.pyc', '__init__.pyo']
+ if hasattr(imp, 'get_tag') :
+ exclude_names.extend(
+ os.path.join(
+ '__pycache__',
+ '__init__.' + imp.get_tag() + '.pyc'
+ ),
+ os.path.join(
+ '__pycache__',
+ '__init__.' + imp.get_tag() + '.pyo'
+ ),
+ )
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':
+ for f in exclude_names :
exclude[os.path.join(pkgdir, f)] = 1
parts.pop()
return exclude