Skip to content

Commit 51b5e8a

Browse files
author
abergeron
authored
Merge pull request #529 from dendisuhubdy/feature_setup_clean
Adding feature python setup.py clean
2 parents 3d1c382 + 7c639b7 commit 51b5e8a

3 files changed

Lines changed: 43 additions & 2 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

setup.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import sys
22
import os
33
import versioneer
4+
import distutils.command.clean
5+
import shutil
46

57
have_cython = False
68

@@ -82,6 +84,22 @@ def __init__(self, *args, **kwargs):
8284
raise RuntimeError('default binary dir {} does not exist, you may need to build the C library in release mode'.format(default_bin_dir))
8385
library_dirs += [default_bin_dir]
8486

87+
class cmd_clean(distutils.command.clean.clean):
88+
def run(self):
89+
import glob
90+
with open('.clean', 'r') as f:
91+
ignores = f.read()
92+
for wildcard in filter(bool, ignores.split('\n')):
93+
for filename in glob.glob(wildcard):
94+
try:
95+
os.remove(filename)
96+
except OSError:
97+
shutil.rmtree(filename, ignore_errors=True)
98+
99+
# It's an old-style class in Python 2.7...
100+
distutils.command.clean.clean.run(self)
101+
102+
85103
ea = []
86104
if sys.platform in ('darwin', 'linux'):
87105
# Silence unused stuff warnings
@@ -120,9 +138,12 @@ def __init__(self, *args, **kwargs):
120138
define_macros=[('GPUARRAY_SHARED', None)]
121139
)]
122140

141+
cmds=versioneer.get_cmdclass()
142+
cmds["clean"] = cmd_clean
143+
123144
setup(name='pygpu',
124145
version=versioneer.get_version(),
125-
cmdclass=versioneer.get_cmdclass(),
146+
cmdclass=cmds,
126147
description='numpy-like wrapper on libgpuarray for GPU computations',
127148
packages=['pygpu', 'pygpu/tests'],
128149
include_package_data=True,

versioneer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,6 @@ def make_release_tree(self, base_dir, files):
16461646
write_to_version_file(target_versionfile,
16471647
self._versioneer_generated_versions)
16481648
cmds["sdist"] = cmd_sdist
1649-
16501649
return cmds
16511650

16521651

0 commit comments

Comments
 (0)