diff options
author | Bibo Hao <haobibo@users.noreply.github.com> | 2017-09-13 11:47:12 +0800 |
---|---|---|
committer | Bibo Hao <haobibo@users.noreply.github.com> | 2017-09-15 09:49:22 +0800 |
commit | ee33fa23dcdb7f9a0e89e2df3a50706b75678a36 (patch) | |
tree | b1c9c88c1de1a7206d40c4665d4766f65ee993f1 /setuptools/command | |
parent | 024139f0dad1609138330efd2363b8855b798d32 (diff) | |
download | external_python_setuptools-ee33fa23dcdb7f9a0e89e2df3a50706b75678a36.tar.gz external_python_setuptools-ee33fa23dcdb7f9a0e89e2df3a50706b75678a36.tar.bz2 external_python_setuptools-ee33fa23dcdb7f9a0e89e2df3a50706b75678a36.zip |
python 3 bdist_egg --exclude-source-files __pycache__ issue
Diffstat (limited to 'setuptools/command')
-rw-r--r-- | setuptools/command/bdist_egg.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 51755d52..5bfc7ba2 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -8,6 +8,7 @@ from distutils import log from types import CodeType import sys import os +import re import textwrap import marshal @@ -238,6 +239,8 @@ class bdist_egg(Command): def zap_pyfiles(self): log.info("Removing .py files from temporary directory") + py3 = sys.version_info >= (3, 0) + re_pycache_file = re.compile('(.+)\.cpython-3\d(.pyc)$') for base, dirs, files in walk_egg(self.bdist_dir): for name in files: if name.endswith('.py'): @@ -245,6 +248,17 @@ class bdist_egg(Command): log.debug("Deleting %s", path) os.unlink(path) + if py3 and base.endswith('__pycache__'): + path_old = os.path.join(base, name) + + m = re_pycache_file.match(name) + path_new = os.path.join(base, os.pardir, m.group(1) + m.group(2)) + log.info("Renaming Python 3 .pyc file from [%s] to [%s]" % (path_old, path_new)) + if os.path.exists(path_new): + os.unlink(path_new) + os.rename(path_old, path_new) + + def zip_safe(self): safe = getattr(self.distribution, 'zip_safe', None) if safe is not None: |