Skip to content

Commit

Permalink
Merge pull request #529 from dendisuhubdy/feature_setup_clean
Browse files Browse the repository at this point in the history
Adding feature python setup.py clean
  • Loading branch information
abergeron authored Sep 15, 2017
2 parents 3d1c382 + 7c639b7 commit 51b5e8a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .clean
Original file line number Diff line number Diff line change
@@ -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
23 changes: 22 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
import os
import versioneer
import distutils.command.clean
import shutil

have_cython = False

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

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)


ea = []
if sys.platform in ('darwin', 'linux'):
# Silence unused stuff warnings
Expand Down Expand Up @@ -120,9 +138,12 @@ def __init__(self, *args, **kwargs):
define_macros=[('GPUARRAY_SHARED', None)]
)]

cmds=versioneer.get_cmdclass()
cmds["clean"] = cmd_clean

setup(name='pygpu',
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
cmdclass=cmds,
description='numpy-like wrapper on libgpuarray for GPU computations',
packages=['pygpu', 'pygpu/tests'],
include_package_data=True,
Expand Down
1 change: 0 additions & 1 deletion versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,6 @@ def make_release_tree(self, base_dir, files):
write_to_version_file(target_versionfile,
self._versioneer_generated_versions)
cmds["sdist"] = cmd_sdist

return cmds


Expand Down

0 comments on commit 51b5e8a

Please sign in to comment.