Skip to content

Commit

Permalink
fixing python setup.py clean
Browse files Browse the repository at this point in the history
  • Loading branch information
soumith committed Oct 22, 2016
1 parent 98f67e9 commit 140c65e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ torch/csrc/nn/THNN.cwrap
torch/csrc/nn/THNN.cpp
torch/csrc/nn/THCUNN.cwrap
torch/csrc/nn/THCUNN.cpp
*/*.pyc
*/**/*.pyc
*/**/**/*.pyc
*/**/**/**/*.pyc
*/**/**/**/**/*.pyc
*/*.so*
*/**/*.so*
*/**/*.dylib*
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ def run(self):

class clean(distutils.command.clean.clean):
def run(self):
import glob
with open('.gitignore', 'r') as f:
ignores = f.read()
for glob in filter(bool, ignores.split('\n')):
shutil.rmtree(glob, ignore_errors=True)
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)

Expand Down

0 comments on commit 140c65e

Please sign in to comment.