Bug 1636797 - Purge __pycache__ in 'mach clobber python'; r=firefox-build-system-reviewers,rstewart
authorGeoff Brown <gbrown@mozilla.com>
Sat, 23 May 2020 19:37:09 +0000
changeset 531889 7737a0e2861806ce37f2764eedfe73aadddff5cd
parent 531888 be7a56eeccc3a8e70dffd4f419b090ad4d44f651
child 531890 1b566534d59fc10d2ba1062287c217603d56f73c
push id37447
push usernbeleuzu@mozilla.com
push dateMon, 25 May 2020 15:42:48 +0000
treeherdermozilla-central@e7641c1071ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, rstewart
bugs1636797
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1636797 - Purge __pycache__ in 'mach clobber python'; r=firefox-build-system-reviewers,rstewart Differential Revision: https://phabricator.services.mozilla.com/D76560
python/mozbuild/mozbuild/mach_commands.py
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -226,26 +226,29 @@ class Clobber(MachCommandBase):
                                  "Could not clobber because a file was in use. If the "
                                  "application is running, try closing it. {error}")
                         return 1
                 raise
 
         if 'python' in what:
             if conditions.is_hg(self):
                 cmd = ['hg', '--config', 'extensions.purge=', 'purge', '--all',
-                       '-I', 'glob:**.py[cdo]', '-I', 'path:python/', '-I',
-                       'path:third_party/python/']
+                       '-I', 'glob:**.py[cdo]', '-I', 'glob:**/__pycache__',
+                       '-I', 'path:python/', '-I', 'path:third_party/python/']
             elif conditions.is_git(self):
-                cmd = ['git', 'clean', '-f', '-x', '*.py[cdo]', 'python/',
-                       'third_party/python/']
+                cmd = ['git', 'clean', '-d', '-f', '-x', '*.py[cdo]', '*/__pycache__',
+                       'python/', 'third_party/python/']
             else:
                 # We don't know what is tracked/untracked if we don't have VCS.
                 # So we can't clean python/ and third_party/python/.
                 cmd = ['find', '.', '-type', 'f', '-name', '*.py[cdo]',
                        '-delete']
+                subprocess.call(cmd, cwd=self.topsrcdir)
+                cmd = ['find', '.', '-type', 'd', '-name', '__pycache__',
+                       '-empty', '-delete']
             ret = subprocess.call(cmd, cwd=self.topsrcdir)
 
         if 'gradle' in what:
             shutil.rmtree(mozpath.join(self.topobjdir, 'gradle'))
 
         return ret
 
     @property