|
1 | 1 | import sys
|
2 | 2 | import os
|
3 | 3 | import versioneer
|
| 4 | +import distutils.command.clean |
| 5 | +import shutil |
4 | 6 |
|
5 | 7 | have_cython = False
|
6 | 8 |
|
@@ -82,6 +84,22 @@ def __init__(self, *args, **kwargs):
|
82 | 84 | raise RuntimeError('default binary dir {} does not exist, you may need to build the C library in release mode'.format(default_bin_dir))
|
83 | 85 | library_dirs += [default_bin_dir]
|
84 | 86 |
|
| 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 | + |
85 | 103 | ea = []
|
86 | 104 | if sys.platform in ('darwin', 'linux'):
|
87 | 105 | # Silence unused stuff warnings
|
@@ -120,9 +138,12 @@ def __init__(self, *args, **kwargs):
|
120 | 138 | define_macros=[('GPUARRAY_SHARED', None)]
|
121 | 139 | )]
|
122 | 140 |
|
| 141 | +cmds=versioneer.get_cmdclass() |
| 142 | +cmds["clean"] = cmd_clean |
| 143 | + |
123 | 144 | setup(name='pygpu',
|
124 | 145 | version=versioneer.get_version(),
|
125 |
| - cmdclass=versioneer.get_cmdclass(), |
| 146 | + cmdclass=cmds, |
126 | 147 | description='numpy-like wrapper on libgpuarray for GPU computations',
|
127 | 148 | packages=['pygpu', 'pygpu/tests'],
|
128 | 149 | include_package_data=True,
|
|
0 commit comments