From a38b6913cef1ac8a418d0330e8d6f6eca3cfec4c Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 25 Sep 2017 19:33:54 +0530 Subject: [PATCH] added a Makefile for faster dev, and clean command to remove eggs, wheels, builds, dist - anything that clutters devspace --- Makefile | 2 ++ setup.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..f30645229e --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +clean: + python setup.py clean \ No newline at end of file diff --git a/setup.py b/setup.py index bbcf6cfb37..797d8e4826 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,7 @@ +# imports - standard imports +import os, shutil +from distutils.command.clean import clean as Clean + from setuptools import setup, find_packages from pip.req import parse_requirements import re, ast @@ -11,6 +15,34 @@ with open('frappe/__init__.py', 'rb') as f: requirements = parse_requirements("requirements.txt", session="") +class CleanCommand(Clean): + def run(self): + Clean.run(self) + + basedir = os.path.abspath(os.path.dirname(__file__)) + + for relpath in ['build', '.cache', '.coverage', 'dist', 'frappe.egg-info']: + abspath = os.path.join(basedir, relpath) + + if os.path.exists(abspath): + if os.path.isfile(abspath): + os.remove(abspath) + else: + shutil.rmtree(abspath) + + for dirpath, dirnames, filenames in os.walk(basedir): + for filename in filenames: + _, extension = os.path.splitext(filename) + + if extension in ['.pyc']: + abspath = os.path.join(dirpath, filename) + os.remove(abspath) + + for dirname in dirnames: + if dirname in ['__pycache__']: + abspath = os.path.join(dirpath, dirname) + shutil.rmtree(abspath) + setup( name='frappe', version=version, @@ -21,5 +53,9 @@ setup( zip_safe=False, include_package_data=True, install_requires=[str(ir.req) for ir in requirements], - dependency_links=[str(ir._link) for ir in requirements if ir._link] + dependency_links=[str(ir._link) for ir in requirements if ir._link], + cmdclass = \ + { + 'clean': CleanCommand + } )