From c39bd00f9fe8d958d6df6a70c8160b5defa621e2 2014-07-23 21:19:27 From: MinRK Date: 2014-07-23 21:19:27 Subject: [PATCH] don’t store minified css in development - setup css defaults to non-minified css - build minified css and jsversion on sdist/wheel --- diff --git a/IPython/html/fabfile.py b/IPython/html/fabfile.py index 6497ff2..580df3e 100644 --- a/IPython/html/fabfile.py +++ b/IPython/html/fabfile.py @@ -13,7 +13,7 @@ components_dir = os.path.join(static_dir, 'components') min_less_version = '1.7.0' max_less_version = '1.8.0' # exclusive -def css(minify=True, verbose=False): +def css(minify=False, verbose=False): """generate the css from less files""" for name in ('style', 'ipython'): source = pjoin('style', "%s.less" % name) diff --git a/setup.py b/setup.py index d244709..c38b4fa 100755 --- a/setup.py +++ b/setup.py @@ -72,6 +72,7 @@ from setupbase import ( get_bdist_wheel, CompileCSS, JavascriptVersion, + css_js_prerelease, install_symlinked, install_lib_symlink, install_scripts_for_symlink, @@ -228,7 +229,7 @@ class UploadWindowsInstallers(upload): setup_args['cmdclass'] = { 'build_py': check_package_data_first(git_prebuild('IPython')), - 'sdist' : git_prebuild('IPython', sdist), + 'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)), 'upload_wininst' : UploadWindowsInstallers, 'submodule' : UpdateSubmodules, 'css' : CompileCSS, @@ -302,7 +303,7 @@ if 'setuptools' in sys.modules: # setup.py develop should check for submodules from setuptools.command.develop import develop setup_args['cmdclass']['develop'] = require_submodules(develop) - setup_args['cmdclass']['bdist_wheel'] = get_bdist_wheel() + setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel()) setuptools_extra_args['zip_safe'] = False setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()} diff --git a/setupbase.py b/setupbase.py index 7c5fe05..bcefe79 100644 --- a/setupbase.py +++ b/setupbase.py @@ -25,7 +25,7 @@ from distutils.command.install_scripts import install_scripts from distutils.cmd import Command from fnmatch import fnmatch from glob import glob -from subprocess import call +from subprocess import check_call from setupext import install_data_ext @@ -666,16 +666,22 @@ class CompileCSS(Command): Requires various dev dependencies, such as fabric and lessc. """ description = "Recompile Notebook CSS" - user_options = [] + user_options = [ + ('minify', 'x', "minify CSS"), + ] def initialize_options(self): - pass + self.minify = False def finalize_options(self): - pass + self.minify = bool(self.minify) def run(self): - call("fab css", shell=True, cwd=pjoin(repo_root, "IPython", "html")) + check_call("fab css:minify=%s" % self.minify, + shell=True, + cwd=pjoin(repo_root, "IPython", "html"), + ) + class JavascriptVersion(Command): """write the javascript version to notebook javascript""" @@ -697,4 +703,15 @@ class JavascriptVersion(Command): if line.startswith("IPython.version"): line = 'IPython.version = "{0}";\n'.format(version) f.write(line) - + + +def css_js_prerelease(command): + """decorator for building js/minified css prior to a release""" + class DecoratedCommand(command): + def run(self): + self.distribution.run_command('jsversion') + css = self.distribution.get_command_obj('css') + css.minify = True + self.distribution.run_command('css') + command.run(self) + return DecoratedCommand