Add setup clean option 09/71509/2
authorSam Hague <shague@redhat.com>
Fri, 27 Apr 2018 01:16:08 +0000 (21:16 -0400)
committerSam Hague <shague@redhat.com>
Sat, 28 Apr 2018 14:09:35 +0000 (14:09 +0000)
JIRA: NETVIRT-1232
Change-Id: I1eb28dfd2c1e70ff284ddf6f63eba28c816d0d1b
Signed-off-by: Sam Hague <shague@redhat.com>
resources/tools/odltools/setup.py

index 9a0f650e4d4ba9f7522a61d21c871eec316d6b79..f7764c7de00a89857a4a28c016fa245b2950cdc2 100644 (file)
@@ -1,34 +1,50 @@
 import io
+import os
+from setuptools import Command
 from setuptools import find_packages
 from setuptools import setup
 import textwrap
 from odltools import __version__
 
 
-with io.open("README.rst", "rt", encoding="utf8") as f:
+with io.open('README.rst', 'rt', encoding='utf8') as f:
     readme = f.read()
 
-with open("requirements.txt") as f:
+with open('requirements.txt') as f:
     requirements = f.read().splitlines()
 
+
+class CleanCommand(Command):
+    """Custom clean command to tidy up the project root."""
+    user_options = []
+
+    def initialize_options(self):
+        pass
+
+    def finalize_options(self):
+        pass
+
+    def run(self):
+        os.system('rm -vrf ./build ./dist ./*.pyc ./*.tgz ./*.egg-info')
+
 setup(
-    name="odltools",
+    name='odltools',
     version=__version__,
-    description="NetVirt tools for troubleshooting OpenDaylight and "
-                "OpenStack integration",
+    description='NetVirt tools for troubleshooting OpenDaylight and '
+                'OpenStack integration',
     long_description=readme,
-    long_description_content_type="text/x-rst; charset=UTF-8",
-    url="http://github.com/shague/odltools",
-    author="Sam Hague, Vishal Thapar",
-    author_email="shague@gmail.com, thapar@gmail.com",
-    license="Eclipse Public License",
-    packages=find_packages(exclude=["tests"]),
+    long_description_content_type='text/x-rst; charset=UTF-8',
+    url='http://github.com/shague/odltools',
+    author='Sam Hague, Vishal Thapar',
+    author_email='shague@gmail.com, thapar@gmail.com',
+    license='Eclipse Public License',
+    packages=find_packages(exclude=['tests']),
     install_requires=requirements,
-    platforms=["All"],
-    python_requires=">=2.7",
-    keywords="development",
+    platforms=['All'],
+    python_requires='>=2.7',
+    keywords='development',
     zip_safe=False,
-    # entry_points={"console_scripts": ["odltools=odltools.__main__:main"]},
+    # entry_points={'console_scripts': ['odltools=odltools.__main__:main']},
     classifiers=textwrap.dedent("""
         Development Status :: 1 - Planning
         Intended Audience :: Developers
@@ -39,5 +55,8 @@ setup(
         Programming Language :: Python :: 2.7
         Topic :: Software Development
         Topic :: Utilities
-        """).strip().splitlines()
+        """).strip().splitlines(),
+    cmdclass={
+        'clean': CleanCommand,
+    }
 )