diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2017-11-19 21:39:41 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-11-19 21:39:41 -0500 |
commit | e4572e8c828cf5c82e072e01672283b5f27396a4 (patch) | |
tree | e8cc8df65484f1f29d9e6bd0a27a362eadddd068 /setuptools/command/bdist_egg.py | |
parent | dcb24ad15465c266a3f258471766fbbe8fc8a42e (diff) | |
parent | d1cef0c5aa0ca473d4b5fef6b11e5508a37663a2 (diff) | |
download | external_python_setuptools-e4572e8c828cf5c82e072e01672283b5f27396a4.tar.gz external_python_setuptools-e4572e8c828cf5c82e072e01672283b5f27396a4.tar.bz2 external_python_setuptools-e4572e8c828cf5c82e072e01672283b5f27396a4.zip |
Merge branch 'master' into drop-py26
Diffstat (limited to 'setuptools/command/bdist_egg.py')
-rw-r--r-- | setuptools/command/bdist_egg.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 51755d52..5fdb62d9 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 @@ -240,11 +241,26 @@ class bdist_egg(Command): 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'): - path = os.path.join(base, name) log.debug("Deleting %s", path) os.unlink(path) + if base.endswith('__pycache__'): + path_old = path + + pattern = r'(?P<name>.+)\.(?P<magic>[^.]+)\.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: |