added a Makefile for faster dev, and clean command to remove eggs, wheels, builds, dist - anything that clutters devspace

This commit is contained in:
Achilles Rasquinha 2017-09-25 19:33:54 +05:30
parent dae76e27a8
commit a38b6913ce
2 changed files with 39 additions and 1 deletions

2
Makefile Normal file
View file

@ -0,0 +1,2 @@
clean:
python setup.py clean

View file

@ -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
}
)