diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2017-11-09 20:00:34 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-11-09 20:00:34 -0500 |
| commit | a5add17b554709e6b808e85a9cdbb1785717d2d5 (patch) | |
| tree | cd36077eb3362811afa966d68f86fff79b820eab /setuptools/command | |
| parent | 542b6b0b583348c3de84ddcf515a29fca7287bc7 (diff) | |
| parent | 7874d4e0980265937b6957ba05805e00bacc0ed8 (diff) | |
| download | python-setuptools-git-a5add17b554709e6b808e85a9cdbb1785717d2d5.tar.gz | |
Merge other edits
Diffstat (limited to 'setuptools/command')
| -rw-r--r-- | setuptools/command/bdist_egg.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 5bfc7ba2..5fdb62d9 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -239,23 +239,25 @@ 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: + 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 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) + 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) |
