Skip to content

Commit

Permalink
adding feature of python setup.py clean where it will delete the desi…
Browse files Browse the repository at this point in the history
…gnated build files stated in .clean which is Build/ build/ and others
  • Loading branch information
dendisuhubdy committed Sep 14, 2017
1 parent fdf790b commit 93493d8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .clean
@@ -0,0 +1,21 @@
Build
build
Debug
Release
lib
__pycache__
.idea
.*.sw[po]
*~
*.pyc
*.pyd
*.pyo
*.egg-info
dist
setuptools*egg
setuptools.pth
distribute*egg
distribute*tar.gz
*.so
*.o
*.log
19 changes: 19 additions & 0 deletions versioneer.py
Expand Up @@ -1647,6 +1647,25 @@ def make_release_tree(self, base_dir, files):
self._versioneer_generated_versions)
cmds["sdist"] = cmd_sdist

import distutils.command.clean
import shutil

class cmd_clean(distutils.command.clean.clean):
def run(self):
import glob
with open('.clean', 'r') as f:
ignores = f.read()
for wildcard in filter(bool, ignores.split('\n')):
for filename in glob.glob(wildcard):
try:
os.remove(filename)
except OSError:
shutil.rmtree(filename, ignore_errors=True)

# It's an old-style class in Python 2.7...
distutils.command.clean.clean.run(self)
cmds["clean"] = cmd_clean

return cmds


Expand Down

0 comments on commit 93493d8

Please sign in to comment.