Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
Improve setup.py clean target
Browse files Browse the repository at this point in the history
Now also deletes *.so, *.pkl, *.json
  • Loading branch information
ceholden committed Dec 7, 2015
1 parent ec0d06e commit bb86892
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion setup.py
@@ -1,13 +1,39 @@
import logging
import os
import shutil
import sys

from distutils.command.clean import clean as Clean
from setuptools import find_packages, setup
from setuptools.extension import Extension

logging.basicConfig(level=logging.INFO)
log = logging.getLogger()

# Extra cleaning with MyClean
class MyClean(Clean):
description = 'Remove files generated during build process'
def run(self):
Clean.run(self)
if os.path.exists('build'):
shutil.rmtree('build')
for dirpath, dirnames, filenames in os.walk('yatsm'):
for filename in filenames:
if any(filename.endswith(suffix) for suffix in
('.c', '.so', '.pyd', '.pyc')):
os.unlink(os.path.join(dirpath, filename))
continue
if (any(filename.endswith(suffix) for suffix in
('.pkl', '.json')) and
os.path.basename(dirpath) == 'pickles'):
os.unlink(os.path.join(dirpath, filename))
for dirname in dirnames:
if dirname == '__pycache__':
shutil.rmtree(os.path.join(dirpath, dirname))

cmdclass = {'clean': MyClean}


# Get version
with open('yatsm/version.py') as f:
for line in f:
Expand Down Expand Up @@ -113,7 +139,8 @@
zip_safe=False,
long_description=readme,
ext_modules=ext_modules,
install_requires=install_requires
install_requires=install_requires,
cmdclass=cmdclass
)

setup(**setup_dict)

0 comments on commit bb86892

Please sign in to comment.