Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c39bd00

Browse files
committed
don’t store minified css in development
- setup css defaults to non-minified css - build minified css and jsversion on sdist/wheel
1 parent b03e27b commit c39bd00

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

IPython/html/fabfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
min_less_version = '1.7.0'
1414
max_less_version = '1.8.0' # exclusive
1515

16-
def css(minify=True, verbose=False):
16+
def css(minify=False, verbose=False):
1717
"""generate the css from less files"""
1818
for name in ('style', 'ipython'):
1919
source = pjoin('style', "%s.less" % name)

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
get_bdist_wheel,
7373
CompileCSS,
7474
JavascriptVersion,
75+
css_js_prerelease,
7576
install_symlinked,
7677
install_lib_symlink,
7778
install_scripts_for_symlink,
@@ -228,7 +229,7 @@ def run(self):
228229

229230
setup_args['cmdclass'] = {
230231
'build_py': check_package_data_first(git_prebuild('IPython')),
231-
'sdist' : git_prebuild('IPython', sdist),
232+
'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)),
232233
'upload_wininst' : UploadWindowsInstallers,
233234
'submodule' : UpdateSubmodules,
234235
'css' : CompileCSS,
@@ -302,7 +303,7 @@ def run(self):
302303
# setup.py develop should check for submodules
303304
from setuptools.command.develop import develop
304305
setup_args['cmdclass']['develop'] = require_submodules(develop)
305-
setup_args['cmdclass']['bdist_wheel'] = get_bdist_wheel()
306+
setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel())
306307

307308
setuptools_extra_args['zip_safe'] = False
308309
setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()}

setupbase.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from distutils.cmd import Command
2626
from fnmatch import fnmatch
2727
from glob import glob
28-
from subprocess import call
28+
from subprocess import check_call
2929

3030
from setupext import install_data_ext
3131

@@ -666,16 +666,22 @@ class CompileCSS(Command):
666666
Requires various dev dependencies, such as fabric and lessc.
667667
"""
668668
description = "Recompile Notebook CSS"
669-
user_options = []
669+
user_options = [
670+
('minify', 'x', "minify CSS"),
671+
]
670672

671673
def initialize_options(self):
672-
pass
674+
self.minify = False
673675

674676
def finalize_options(self):
675-
pass
677+
self.minify = bool(self.minify)
676678

677679
def run(self):
678-
call("fab css", shell=True, cwd=pjoin(repo_root, "IPython", "html"))
680+
check_call("fab css:minify=%s" % self.minify,
681+
shell=True,
682+
cwd=pjoin(repo_root, "IPython", "html"),
683+
)
684+
679685

680686
class JavascriptVersion(Command):
681687
"""write the javascript version to notebook javascript"""
@@ -697,4 +703,15 @@ def run(self):
697703
if line.startswith("IPython.version"):
698704
line = 'IPython.version = "{0}";\n'.format(version)
699705
f.write(line)
700-
706+
707+
708+
def css_js_prerelease(command):
709+
"""decorator for building js/minified css prior to a release"""
710+
class DecoratedCommand(command):
711+
def run(self):
712+
self.distribution.run_command('jsversion')
713+
css = self.distribution.get_command_obj('css')
714+
css.minify = True
715+
self.distribution.run_command('css')
716+
command.run(self)
717+
return DecoratedCommand

0 commit comments

Comments
 (0)