From 535aab8c8f65487bac508808075ed27302ed0189 Mon Sep 17 00:00:00 2001 From: Tommy Yu Date: Fri, 9 Jun 2017 18:47:12 +1200 Subject: [PATCH] Be less aggressive about calling that - Only do so if the command was called, and do so on the top level as the methods are executed separately, so the atexit registration must be done on construction. --- .flake8 | 1 + setup.py | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.flake8 b/.flake8 index d34cc7a..94b9207 100644 --- a/.flake8 +++ b/.flake8 @@ -19,5 +19,6 @@ include = exclude = src/calmjs/parse/parsers/*tab*.py, .git, + .eggs, .env*, env* diff --git a/setup.py b/setup.py index f5a09e4..c331c10 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,27 @@ +import atexit import sys from setuptools import setup, find_packages +from setuptools.command.develop import develop +from setuptools.command.install import install from subprocess import call + +class DevelopHook(develop): + """For hooking the optimizer when setup exits""" + def __init__(self, *a, **kw): + develop.__init__(self, *a, **kw) + atexit.register( + call, [sys.executable, '-m', 'calmjs.parse.parsers.optimize']) + + +class InstallHook(install): + """For hooking the optimizer when setup exits""" + def __init__(self, *a, **kw): + install.__init__(self, *a, **kw) + atexit.register( + call, [sys.executable, '-m', 'calmjs.parse.parsers.optimize']) + + version = '0.9.0' classifiers = """ @@ -41,13 +61,14 @@ namespace_packages=['calmjs'], include_package_data=True, zip_safe=False, + cmdclass={ + 'develop': DevelopHook, + 'install': InstallHook, + }, install_requires=[ 'ply>=3.6', ], - entry_points=""" - # -*- Entry points: -*- - """, + entry_points={ + }, test_suite="calmjs.parse.tests.make_suite", ) - -call([sys.executable, '-m', 'calmjs.parse.parsers.optimize'])