diff --git a/setup.py b/setup.py index 8bc52968552..3ccf0bec4fd 100755 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ from __future__ import with_statement import os import sys from distutils.cmd import Command +from distutils.command.clean import clean from distutils.sysconfig import get_python_lib, PREFIX # Use setuptools only if the user opts-in by setting the USE_SETUPTOOLS env var @@ -64,6 +65,22 @@ class TestCommand(Command): test_process.communicate() sys.exit(test_process.returncode) + +class Clean(clean): + def run(self): + clean.run(self) + # Let's clean compiled *.py[c,o] + remove_extensions = ('.pyc', '.pyo') + for subdir in ('salt', 'tests'): + root = os.path.join(os.path.dirname(__file__), subdir) + for dirname, dirnames, filenames in os.walk(root): + for filename in filenames: + for ext in remove_extensions: + if filename.endswith(ext): + os.remove(os.path.join(dirname, filename)) + break + + NAME = 'salt' VER = __version__ DESC = ('Portable, distributed, remote execution and ' @@ -91,7 +108,7 @@ setup_kwargs = {'name': NAME, 'author': 'Thomas S Hatch', 'author_email': 'thatch45@gmail.com', 'url': 'http://saltstack.org', - 'cmdclass': {'test': TestCommand}, + 'cmdclass': {'test': TestCommand, 'clean': Clean}, 'classifiers': ['Programming Language :: Python', 'Programming Language :: Cython', 'Programming Language :: Python :: 2.6',