Skip to content

Commit 93493d8

Browse files
committed
adding feature of python setup.py clean where it will delete the designated build files stated in .clean which is Build/ build/ and others
1 parent fdf790b commit 93493d8

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

.clean

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Build
2+
build
3+
Debug
4+
Release
5+
lib
6+
__pycache__
7+
.idea
8+
.*.sw[po]
9+
*~
10+
*.pyc
11+
*.pyd
12+
*.pyo
13+
*.egg-info
14+
dist
15+
setuptools*egg
16+
setuptools.pth
17+
distribute*egg
18+
distribute*tar.gz
19+
*.so
20+
*.o
21+
*.log

versioneer.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,25 @@ def make_release_tree(self, base_dir, files):
16471647
self._versioneer_generated_versions)
16481648
cmds["sdist"] = cmd_sdist
16491649

1650+
import distutils.command.clean
1651+
import shutil
1652+
1653+
class cmd_clean(distutils.command.clean.clean):
1654+
def run(self):
1655+
import glob
1656+
with open('.clean', 'r') as f:
1657+
ignores = f.read()
1658+
for wildcard in filter(bool, ignores.split('\n')):
1659+
for filename in glob.glob(wildcard):
1660+
try:
1661+
os.remove(filename)
1662+
except OSError:
1663+
shutil.rmtree(filename, ignore_errors=True)
1664+
1665+
# It's an old-style class in Python 2.7...
1666+
distutils.command.clean.clean.run(self)
1667+
cmds["clean"] = cmd_clean
1668+
16501669
return cmds
16511670

16521671

0 commit comments

Comments
 (0)