diff --git a/IPython/utils/submodule.py b/IPython/utils/submodule.py deleted file mode 100644 index 5310a43..0000000 --- a/IPython/utils/submodule.py +++ /dev/null @@ -1,105 +0,0 @@ -"""utilities for checking submodule status""" - -#----------------------------------------------------------------------------- -# Copyright (C) 2013 The IPython Development Team -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- - -import os -import subprocess -import sys - -#----------------------------------------------------------------------------- -# Globals -#----------------------------------------------------------------------------- - -pjoin = os.path.join - -#----------------------------------------------------------------------------- -# Code -#----------------------------------------------------------------------------- - -def ipython_parent(): - """return IPython's parent (i.e. root if run from git)""" - from IPython.utils.path import get_ipython_package_dir - return os.path.abspath(os.path.dirname(get_ipython_package_dir())) - -def ipython_submodules(root): - """return IPython submodules relative to root""" - return [ - pjoin(root, 'IPython', 'html', 'static', 'components'), - ] - -def is_repo(d): - """is d a git repo?""" - if not os.path.exists(pjoin(d, '.git')): - return False - proc = subprocess.Popen('git status', - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=True, - cwd=d, - ) - status, _ = proc.communicate() - return status == 0 - -def check_submodule_status(root=None): - """check submodule status - - Has three return values: - - 'missing' - submodules are absent - 'unclean' - submodules have unstaged changes - 'clean' - all submodules are up to date - """ - - if hasattr(sys, "frozen"): - # frozen via py2exe or similar, don't bother - return 'clean' - - if not root: - root = ipython_parent() - - if not is_repo(root): - # not in git, assume clean - return 'clean' - - submodules = ipython_submodules(root) - - for submodule in submodules: - if not os.path.exists(submodule): - return 'missing' - - # Popen can't handle unicode cwd on Windows Python 2 - if sys.platform == 'win32' and sys.version_info[0] < 3 \ - and not isinstance(root, bytes): - root = root.encode(sys.getfilesystemencoding() or 'ascii') - # check with git submodule status - proc = subprocess.Popen('git submodule status', - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=True, - cwd=root, - ) - status, _ = proc.communicate() - status = status.decode("ascii", "replace") - - for line in status.splitlines(): - if line.startswith('-'): - return 'missing' - elif line.startswith('+'): - return 'unclean' - - return 'clean' - -def update_submodules(repo_dir): - """update submodules in a repo""" - subprocess.check_call("git submodule init", cwd=repo_dir, shell=True) - subprocess.check_call("git submodule update --recursive", cwd=repo_dir, shell=True) - diff --git a/git-hooks/README.md b/git-hooks/README.md deleted file mode 100644 index 9444272..0000000 --- a/git-hooks/README.md +++ /dev/null @@ -1,10 +0,0 @@ -git hooks for IPython - -add these to your `.git/hooks` - -For now, we just have `post-checkout` and `post-merge`, -both of which update submodules and attempt to rebuild css sourcemaps, -so make sure that you have a fully synced repo whenever you checkout or pull. - -To use these hooks, run `./install-hooks.sh`. -If you havn't initialised and updated the submodules manually, you will then need to run `git checkout master` to activate the hooks (even if you already have `master` checked out). diff --git a/git-hooks/install-hooks.sh b/git-hooks/install-hooks.sh deleted file mode 100755 index 60ea641..0000000 --- a/git-hooks/install-hooks.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -DOTGIT=`git rev-parse --git-dir` -TOPLEVEL=`git rev-parse --show-toplevel` -TO=${DOTGIT}/hooks -FROM=${TOPLEVEL}/git-hooks - -ln -s ${FROM}/post-checkout ${TO}/post-checkout -ln -s ${FROM}/post-merge ${TO}/post-merge diff --git a/git-hooks/post-checkout b/git-hooks/post-checkout deleted file mode 100755 index 12c8ee6..0000000 --- a/git-hooks/post-checkout +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -git submodule init -git submodule update - -if [[ "$(basename $0)" == "post-merge" ]]; then - PREVIOUS_HEAD=ORIG_HEAD -else - PREVIOUS_HEAD=$1 -fi - -# if style changed (and less/invoke available), rebuild sourcemaps -if [[ - ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/ipython.min.css)" - && ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/style.min.css)" - && ! -z $(which 2>/dev/null lessc) - && ! -z $(which 2>/dev/null invoke) -]]; then - echo "rebuilding sourcemaps" - cd IPython/html - invoke css || echo "failed to compile css" -fi diff --git a/git-hooks/post-merge b/git-hooks/post-merge deleted file mode 120000 index 5513d1d..0000000 --- a/git-hooks/post-merge +++ /dev/null @@ -1 +0,0 @@ -post-checkout \ No newline at end of file diff --git a/setup.py b/setup.py index 7be7a69..0e47fdf 100755 --- a/setup.py +++ b/setup.py @@ -65,14 +65,7 @@ from setupbase import ( find_data_files, check_for_readline, git_prebuild, - check_submodule_status, - update_submodules, - require_submodules, - UpdateSubmodules, get_bdist_wheel, - CompileCSS, - JavascriptVersion, - css_js_prerelease, install_symlinked, install_lib_symlink, install_scripts_for_symlink, @@ -98,42 +91,6 @@ if os_name == 'windows' and 'sdist' in sys.argv: print('The sdist command is not available under Windows. Exiting.') sys.exit(1) -#------------------------------------------------------------------------------- -# Make sure we aren't trying to run without submodules -#------------------------------------------------------------------------------- -here = os.path.abspath(os.path.dirname(__file__)) - -def require_clean_submodules(): - """Check on git submodules before distutils can do anything - - Since distutils cannot be trusted to update the tree - after everything has been set in motion, - this is not a distutils command. - """ - # PACKAGERS: Add a return here to skip checks for git submodules - - # don't do anything if nothing is actually supposed to happen - for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'): - if do_nothing in sys.argv: - return - - status = check_submodule_status(here) - - if status == "missing": - print("checking out submodules for the first time") - update_submodules(here) - elif status == "unclean": - print('\n'.join([ - "Cannot build / install IPython with unclean submodules", - "Please update submodules with", - " python setup.py submodule", - "or", - " git submodule update", - "or commit any submodule changes you have made." - ])) - sys.exit(1) - -require_clean_submodules() #------------------------------------------------------------------------------- # Things related to the IPython documentation @@ -193,17 +150,14 @@ class UploadWindowsInstallers(upload): self.upload_file('bdist_wininst', 'any', dist_file) setup_args['cmdclass'] = { - 'build_py': css_js_prerelease( - check_package_data_first(git_prebuild('IPython'))), - 'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)), + 'build_py': \ + check_package_data_first(git_prebuild('IPython')), + 'sdist' : git_prebuild('IPython', sdist), 'upload_wininst' : UploadWindowsInstallers, - 'submodule' : UpdateSubmodules, - 'css' : CompileCSS, 'symlink': install_symlinked, 'install_lib_symlink': install_lib_symlink, 'install_scripts_sym': install_scripts_for_symlink, 'unsymlink': unsymlink, - 'jsversion' : JavascriptVersion, } ### Temporarily disable install while it's broken during the big split @@ -254,20 +208,13 @@ extras_require = dict( terminal = [], kernel = ['ipython_kernel'], nbformat = ['jupyter_nbformat'], - notebook = ['tornado>=4.0', pyzmq, 'jinja2', 'pygments', 'mistune>=0.5'], - nbconvert = ['pygments', 'jinja2', 'mistune>=0.3.1'] + notebook = ['jupyter_notebook'], + nbconvert = ['jupyter_nbconvert'] ) -if not sys.platform.startswith('win'): - extras_require['notebook'].append('terminado>=0.3.3') - if sys.version_info < (3, 3): extras_require['test'].append('mock') -extras_require['nbconvert'].extend(extras_require['nbformat']) -extras_require['notebook'].extend(extras_require['kernel']) -extras_require['notebook'].extend(extras_require['nbconvert']) - install_requires = [ 'decorator', 'pickleshare', @@ -292,10 +239,7 @@ for deps in extras_require.values(): extras_require['all'] = everything 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'] = css_js_prerelease(get_bdist_wheel()) + setup_args['cmdclass']['bdist_wheel'] = get_bdist_wheel() setuptools_extra_args['zip_safe'] = False setuptools_extra_args['entry_points'] = { diff --git a/setupbase.py b/setupbase.py index bdfed1f..d5b7144 100644 --- a/setupbase.py +++ b/setupbase.py @@ -124,73 +124,11 @@ def find_package_data(): # This is not enough for these things to appear in an sdist. # We need to muck with the MANIFEST to get this to work - # exclude components and less from the walk; - # we will build the components separately - # excludes = [ - # pjoin('static', 'components'), - # pjoin('static', '*', 'less'), - # ] - # - # # walk notebook resources: - # cwd = os.getcwd() - # os.chdir(os.path.join('IPython', 'html')) - # static_data = [] - # for parent, dirs, files in os.walk('static'): - # if any(fnmatch(parent, pat) for pat in excludes): - # # prevent descending into subdirs - # dirs[:] = [] - # continue - # for f in files: - # static_data.append(pjoin(parent, f)) - # - # components = pjoin("static", "components") - # # select the components we actually need to install - # # (there are lots of resources we bundle for sdist-reasons that we don't actually use) - # static_data.extend([ - # pjoin(components, "backbone", "backbone-min.js"), - # pjoin(components, "bootstrap", "js", "bootstrap.min.js"), - # pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"), - # pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"), - # pjoin(components, "es6-promise", "*.js"), - # pjoin(components, "font-awesome", "fonts", "*.*"), - # pjoin(components, "google-caja", "html-css-sanitizer-minified.js"), - # pjoin(components, "jquery", "jquery.min.js"), - # pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"), - # pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"), - # pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"), - # pjoin(components, "marked", "lib", "marked.js"), - # pjoin(components, "requirejs", "require.js"), - # pjoin(components, "underscore", "underscore-min.js"), - # pjoin(components, "moment", "moment.js"), - # pjoin(components, "moment", "min", "moment.min.js"), - # pjoin(components, "term.js", "src", "term.js"), - # pjoin(components, "text-encoding", "lib", "encoding.js"), - # ]) - # - # # Ship all of Codemirror's CSS and JS - # for parent, dirs, files in os.walk(pjoin(components, 'codemirror')): - # for f in files: - # if f.endswith(('.js', '.css')): - # static_data.append(pjoin(parent, f)) - # - # os.chdir(os.path.join('tests',)) - # js_tests = glob('*.js') + glob('*/*.js') - - # os.chdir(cwd) - package_data = { 'IPython.core' : ['profile/README*'], 'IPython.core.tests' : ['*.png', '*.jpg'], 'IPython.lib.tests' : ['*.wav'], 'IPython.testing.plugin' : ['*.txt'], - # 'IPython.html' : ['templates/*'] + static_data, - # 'IPython.html.tests' : js_tests, - # 'IPython.nbformat' : [ - # 'tests/*.ipynb', - # 'v3/nbformat.v3.schema.json', - # 'v4/nbformat.v4.schema.json', - # ], - # 'IPython.kernel': ['resources/*.*'], } return package_data @@ -497,36 +435,6 @@ def check_for_readline(): # VCS related #--------------------------------------------------------------------------- -# utils.submodule has checks for submodule status -execfile(pjoin('IPython','utils','submodule.py'), globals()) - -class UpdateSubmodules(Command): - """Update git submodules - - IPython's external javascript dependencies live in a separate repo. - """ - description = "Update git submodules" - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - failure = False - try: - self.spawn('git submodule init'.split()) - self.spawn('git submodule update --recursive'.split()) - except Exception as e: - failure = e - print(e) - - if not check_submodule_status(repo_root) == 'clean': - print("submodules could not be checked out") - sys.exit(1) - def git_prebuild(pkg_dir, build_cmd=build_py): """Return extended build or sdist command class for recording commit @@ -534,8 +442,6 @@ def git_prebuild(pkg_dir, build_cmd=build_py): records git commit in IPython.utils._sysinfo.commit for use in IPython.utils.sysinfo.sys_info() calls after installation. - - Also ensures that submodules exist prior to running """ class MyBuildPy(build_cmd): @@ -577,18 +483,9 @@ def git_prebuild(pkg_dir, build_cmd=build_py): '# GENERATED BY setup.py\n', 'commit = u"%s"\n' % repo_commit, ]) - return require_submodules(MyBuildPy) + return MyBuildPy -def require_submodules(command): - """decorator for instructing a command to check for submodules before running""" - class DecoratedCommand(command): - def run(self): - if not check_submodule_status(repo_root) == 'clean': - print("submodules missing! Run `setup.py submodule` and try again") - sys.exit(1) - command.run(self) - return DecoratedCommand #--------------------------------------------------------------------------- # bdist related @@ -644,8 +541,6 @@ def get_bdist_wheel(): for pkg in ("gnureadline", "pyreadline", "mock", "terminado", "appnope", "pexpect"): _remove_startswith(requires, pkg) requires.append("gnureadline; sys.platform == 'darwin' and platform.python_implementation == 'CPython'") - requires.append("terminado (>=0.3.3); extra == 'notebook' and sys.platform != 'win32'") - requires.append("terminado (>=0.3.3); extra == 'all' and sys.platform != 'win32'") requires.append("pyreadline (>=2.0); extra == 'terminal' and sys.platform == 'win32' and platform.python_implementation == 'CPython'") requires.append("pyreadline (>=2.0); extra == 'all' and sys.platform == 'win32' and platform.python_implementation == 'CPython'") requires.append("mock; extra == 'test' and python_version < '3.3'") @@ -657,85 +552,3 @@ def get_bdist_wheel(): return bdist_wheel_tag -#--------------------------------------------------------------------------- -# Notebook related -#--------------------------------------------------------------------------- - -class CompileCSS(Command): - """Recompile Notebook CSS - - Regenerate the compiled CSS from LESS sources. - - Requires various dev dependencies, such as invoke and lessc. - """ - description = "Recompile Notebook CSS" - user_options = [ - ('minify', 'x', "minify CSS"), - ('force', 'f', "force recompilation of CSS"), - ] - - def initialize_options(self): - self.minify = False - self.force = False - - def finalize_options(self): - self.minify = bool(self.minify) - self.force = bool(self.force) - - def run(self): - cmd = ['invoke', 'css'] - if self.minify: - cmd.append('--minify') - if self.force: - cmd.append('--force') - try: - p = Popen(cmd, cwd=pjoin(repo_root, "jupyter_notebook"), stderr=PIPE) - except OSError: - raise DistutilsExecError("invoke is required to rebuild css (pip install invoke)") - out, err = p.communicate() - if p.returncode: - if sys.version_info[0] >= 3: - err = err.decode('utf8', 'replace') - raise DistutilsExecError(err.strip()) - - -class JavascriptVersion(Command): - """write the javascript version to notebook javascript""" - description = "Write IPython version to javascript" - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - nsfile = pjoin(repo_root, "jupyter_notebook", "static", "base", "js", "namespace.js") - with open(nsfile) as f: - lines = f.readlines() - with open(nsfile, 'w') as f: - found = False - for line in lines: - if line.strip().startswith("IPython.version"): - line = ' IPython.version = "{0}";\n'.format(version) - found = True - f.write(line) - if not found: - raise RuntimeError("Didn't find IPython.version line in %s" % nsfile) - - -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 - try: - self.distribution.run_command('css') - except Exception as e: - log.warn("rebuilding css and sourcemaps failed (not a problem)") - log.warn(str(e)) - command.run(self) - return DecoratedCommand