2011-10-10 02:28:13 +08:00
|
|
|
#!/usr/bin/env python
|
2011-12-09 06:34:22 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""Setup script for IPython.
|
|
|
|
|
|
|
|
Under Posix environments it works like a typical setup.py script.
|
|
|
|
Under Windows, the command sdist is not supported, since IPython
|
|
|
|
requires utilities which are not available under Windows."""
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Copyright (c) 2008-2011, IPython Development Team.
|
|
|
|
# Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
|
|
|
|
# Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
|
|
|
|
# Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
|
|
|
|
#
|
|
|
|
# Distributed under the terms of the Modified BSD License.
|
|
|
|
#
|
2014-03-26 04:55:08 +08:00
|
|
|
# The full license is in the file COPYING.rst, distributed with this software.
|
2011-12-09 06:34:22 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Minimal Python version sanity check
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
from __future__ import print_function
|
2010-01-17 08:57:22 +08:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
# This check is also made in IPython/__init__, don't forget to update both when
|
|
|
|
# changing Python version requirements.
|
2014-04-03 02:59:27 +08:00
|
|
|
v = sys.version_info
|
|
|
|
if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
|
|
|
|
error = "ERROR: IPython requires Python version 2.7 or 3.3 or above."
|
2013-09-10 02:13:28 +08:00
|
|
|
print(error, file=sys.stderr)
|
|
|
|
sys.exit(1)
|
2011-12-09 06:34:22 +08:00
|
|
|
|
|
|
|
PY3 = (sys.version_info[0] >= 3)
|
|
|
|
|
|
|
|
# At least we're on the python version we need, move on.
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Imports
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Stdlib imports
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
from glob import glob
|
|
|
|
|
|
|
|
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
|
|
|
|
# update it when the contents of directories change.
|
|
|
|
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
|
|
|
|
|
|
|
|
from distutils.core import setup
|
|
|
|
|
|
|
|
# Our own imports
|
|
|
|
from setupbase import target_update
|
|
|
|
|
|
|
|
from setupbase import (
|
|
|
|
setup_args,
|
|
|
|
find_packages,
|
|
|
|
find_package_data,
|
2014-02-08 06:12:53 +08:00
|
|
|
check_package_data_first,
|
2013-11-01 08:38:34 +08:00
|
|
|
find_entry_points,
|
|
|
|
build_scripts_entrypt,
|
2011-12-09 06:34:22 +08:00
|
|
|
find_data_files,
|
|
|
|
check_for_dependencies,
|
2013-05-01 07:18:52 +08:00
|
|
|
git_prebuild,
|
2013-05-04 06:42:10 +08:00
|
|
|
check_submodule_status,
|
2013-05-01 07:18:52 +08:00
|
|
|
update_submodules,
|
|
|
|
require_submodules,
|
|
|
|
UpdateSubmodules,
|
2014-01-31 10:46:23 +08:00
|
|
|
get_bdist_wheel,
|
2013-09-15 03:21:05 +08:00
|
|
|
CompileCSS,
|
2013-10-26 05:01:31 +08:00
|
|
|
JavascriptVersion,
|
2014-07-24 05:19:27 +08:00
|
|
|
css_js_prerelease,
|
2013-11-01 08:38:34 +08:00
|
|
|
install_symlinked,
|
|
|
|
install_lib_symlink,
|
|
|
|
install_scripts_for_symlink,
|
2013-12-17 07:12:39 +08:00
|
|
|
unsymlink,
|
2011-12-09 06:34:22 +08:00
|
|
|
)
|
|
|
|
from setupext import setupext
|
|
|
|
|
|
|
|
isfile = os.path.isfile
|
|
|
|
pjoin = os.path.join
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function definitions
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def cleanup():
|
|
|
|
"""Clean up the junk left around by the build process"""
|
2012-08-13 22:19:45 +08:00
|
|
|
if "develop" not in sys.argv and "egg_info" not in sys.argv:
|
2011-12-09 06:34:22 +08:00
|
|
|
try:
|
|
|
|
shutil.rmtree('ipython.egg-info')
|
|
|
|
except:
|
|
|
|
try:
|
|
|
|
os.unlink('ipython.egg-info')
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Handle OS specific things
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2013-03-31 02:51:32 +08:00
|
|
|
if os.name in ('nt','dos'):
|
2011-12-09 06:34:22 +08:00
|
|
|
os_name = 'windows'
|
2008-02-29 02:30:23 +08:00
|
|
|
else:
|
2013-03-31 02:51:32 +08:00
|
|
|
os_name = os.name
|
2011-12-09 06:34:22 +08:00
|
|
|
|
|
|
|
# Under Windows, 'sdist' has not been supported. Now that the docs build with
|
|
|
|
# Sphinx it might work, but let's not turn it on until someone confirms that it
|
|
|
|
# actually works.
|
|
|
|
if os_name == 'windows' and 'sdist' in sys.argv:
|
|
|
|
print('The sdist command is not available under Windows. Exiting.')
|
|
|
|
sys.exit(1)
|
|
|
|
|
2013-05-01 07:18:52 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Make sure we aren't trying to run without submodules
|
|
|
|
#-------------------------------------------------------------------------------
|
2013-05-04 06:42:10 +08:00
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
2013-05-01 07:18:52 +08:00
|
|
|
|
2013-05-04 06:42:10 +08:00
|
|
|
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.
|
2013-05-01 07:18:52 +08:00
|
|
|
"""
|
2013-05-30 18:17:51 +08:00
|
|
|
# PACKAGERS: Add a return here to skip checks for git submodules
|
|
|
|
|
2013-05-01 07:18:52 +08:00
|
|
|
# don't do anything if nothing is actually supposed to happen
|
2013-05-04 06:42:10 +08:00
|
|
|
for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'):
|
2013-05-01 07:18:52 +08:00
|
|
|
if do_nothing in sys.argv:
|
|
|
|
return
|
|
|
|
|
2013-05-04 06:42:10 +08:00
|
|
|
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()
|
2013-05-01 07:18:52 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Things related to the IPython documentation
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# update the manuals when building a source dist
|
|
|
|
if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
|
|
|
|
|
|
|
|
# List of things to be updated. Each entry is a triplet of args for
|
|
|
|
# target_update()
|
|
|
|
to_update = [
|
|
|
|
# FIXME - Disabled for now: we need to redo an automatic way
|
|
|
|
# of generating the magic info inside the rst.
|
|
|
|
#('docs/magic.tex',
|
|
|
|
#['IPython/Magic.py'],
|
|
|
|
#"cd doc && ./update_magic.sh" ),
|
|
|
|
|
|
|
|
('docs/man/ipcluster.1.gz',
|
|
|
|
['docs/man/ipcluster.1'],
|
|
|
|
'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
|
|
|
|
|
|
|
|
('docs/man/ipcontroller.1.gz',
|
|
|
|
['docs/man/ipcontroller.1'],
|
|
|
|
'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
|
|
|
|
|
|
|
|
('docs/man/ipengine.1.gz',
|
|
|
|
['docs/man/ipengine.1'],
|
|
|
|
'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
|
|
|
|
|
|
|
|
('docs/man/ipython.1.gz',
|
|
|
|
['docs/man/ipython.1'],
|
|
|
|
'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
[ target_update(*t) for t in to_update ]
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# Find all the packages, package data, and data_files
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
packages = find_packages()
|
|
|
|
package_data = find_package_data()
|
2014-02-06 13:36:49 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
data_files = find_data_files()
|
|
|
|
|
|
|
|
setup_args['packages'] = packages
|
|
|
|
setup_args['package_data'] = package_data
|
|
|
|
setup_args['data_files'] = data_files
|
|
|
|
|
2012-07-01 04:41:30 +08:00
|
|
|
#---------------------------------------------------------------------------
|
2012-07-01 06:17:46 +08:00
|
|
|
# custom distutils commands
|
2012-07-01 04:41:30 +08:00
|
|
|
#---------------------------------------------------------------------------
|
2012-07-01 06:17:46 +08:00
|
|
|
# imports here, so they are after setuptools import if there was one
|
|
|
|
from distutils.command.sdist import sdist
|
|
|
|
from distutils.command.upload import upload
|
2012-07-01 04:41:30 +08:00
|
|
|
|
|
|
|
class UploadWindowsInstallers(upload):
|
2012-12-01 08:21:57 +08:00
|
|
|
|
2012-07-01 04:41:30 +08:00
|
|
|
description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
|
|
|
|
user_options = upload.user_options + [
|
|
|
|
('files=', 'f', 'exe file (or glob) to upload')
|
|
|
|
]
|
|
|
|
def initialize_options(self):
|
|
|
|
upload.initialize_options(self)
|
|
|
|
meta = self.distribution.metadata
|
|
|
|
base = '{name}-{version}'.format(
|
|
|
|
name=meta.get_name(),
|
|
|
|
version=meta.get_version()
|
|
|
|
)
|
|
|
|
self.files = os.path.join('dist', '%s.*.exe' % base)
|
2012-12-01 08:21:57 +08:00
|
|
|
|
2012-07-01 04:41:30 +08:00
|
|
|
def run(self):
|
|
|
|
for dist_file in glob(self.files):
|
|
|
|
self.upload_file('bdist_wininst', 'any', dist_file)
|
|
|
|
|
2012-07-01 06:17:46 +08:00
|
|
|
setup_args['cmdclass'] = {
|
2014-07-24 06:33:08 +08:00
|
|
|
'build_py': css_js_prerelease(
|
|
|
|
check_package_data_first(git_prebuild('IPython')),
|
|
|
|
strict=False),
|
2014-07-24 05:19:27 +08:00
|
|
|
'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)),
|
2012-07-01 06:17:46 +08:00
|
|
|
'upload_wininst' : UploadWindowsInstallers,
|
2013-05-01 07:18:52 +08:00
|
|
|
'submodule' : UpdateSubmodules,
|
2013-09-15 03:21:05 +08:00
|
|
|
'css' : CompileCSS,
|
2013-11-01 08:38:34 +08:00
|
|
|
'symlink': install_symlinked,
|
|
|
|
'install_lib_symlink': install_lib_symlink,
|
|
|
|
'install_scripts_sym': install_scripts_for_symlink,
|
2013-12-17 07:12:39 +08:00
|
|
|
'unsymlink': unsymlink,
|
2013-10-26 05:01:31 +08:00
|
|
|
'jsversion' : JavascriptVersion,
|
2012-07-01 06:17:46 +08:00
|
|
|
}
|
2012-07-01 04:41:30 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# Handle scripts, dependencies, and setuptools specific things
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# For some commands, use setuptools. Note that we do NOT list install here!
|
|
|
|
# If you want a setuptools-enhanced install, just run 'setupegg.py install'
|
|
|
|
needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
|
2014-01-31 10:46:23 +08:00
|
|
|
'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
|
|
|
|
'egg_info', 'easy_install', 'upload', 'install_egg_info',
|
2011-12-09 06:34:22 +08:00
|
|
|
))
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
# Depend on setuptools for install on *Windows only*
|
|
|
|
# If we get script-installation working without setuptools,
|
|
|
|
# then we can back off, but until then use it.
|
|
|
|
# See Issue #369 on GitHub for more
|
|
|
|
needs_setuptools.add('install')
|
|
|
|
|
|
|
|
if len(needs_setuptools.intersection(sys.argv)) > 0:
|
|
|
|
import setuptools
|
|
|
|
|
|
|
|
# This dict is used for passing extra arguments that are setuptools
|
|
|
|
# specific to setup
|
|
|
|
setuptools_extra_args = {}
|
|
|
|
|
2014-01-31 10:46:23 +08:00
|
|
|
# setuptools requirements
|
|
|
|
|
|
|
|
extras_require = dict(
|
2014-02-04 09:26:31 +08:00
|
|
|
parallel = ['pyzmq>=2.1.11'],
|
2014-01-31 10:46:23 +08:00
|
|
|
qtconsole = ['pyzmq>=2.1.11', 'pygments'],
|
2014-02-04 09:26:31 +08:00
|
|
|
zmq = ['pyzmq>=2.1.11'],
|
2014-01-31 10:46:23 +08:00
|
|
|
doc = ['Sphinx>=1.1', 'numpydoc'],
|
2014-02-04 09:26:31 +08:00
|
|
|
test = ['nose>=0.10.1'],
|
2014-04-10 06:52:59 +08:00
|
|
|
terminal = [],
|
2014-06-04 05:37:23 +08:00
|
|
|
nbformat = ['jsonschema>=2.0', 'jsonpointer>=1.3'],
|
2014-08-01 02:52:57 +08:00
|
|
|
notebook = ['tornado>=3.1', 'pyzmq>=2.1.11', 'jinja2', 'pygments', 'mistune>=0.3.1'],
|
|
|
|
nbconvert = ['pygments', 'jinja2', 'mistune>=0.3.1']
|
2014-01-31 10:46:23 +08:00
|
|
|
)
|
2014-06-04 05:37:23 +08:00
|
|
|
|
2014-02-21 10:13:34 +08:00
|
|
|
if sys.version_info < (3, 3):
|
|
|
|
extras_require['test'].append('mock')
|
|
|
|
|
2014-06-04 05:37:23 +08:00
|
|
|
extras_require['notebook'].extend(extras_require['nbformat'])
|
|
|
|
extras_require['nbconvert'].extend(extras_require['nbformat'])
|
|
|
|
|
2014-01-31 10:46:23 +08:00
|
|
|
everything = set()
|
|
|
|
for deps in extras_require.values():
|
2014-02-04 09:26:31 +08:00
|
|
|
everything.update(deps)
|
2014-01-31 10:46:23 +08:00
|
|
|
extras_require['all'] = everything
|
2014-02-21 10:13:34 +08:00
|
|
|
|
2014-01-31 10:46:23 +08:00
|
|
|
install_requires = []
|
2014-04-10 06:52:59 +08:00
|
|
|
|
|
|
|
# add readline
|
2014-01-31 10:46:23 +08:00
|
|
|
if sys.platform == 'darwin':
|
2014-02-21 17:57:14 +08:00
|
|
|
if any(arg.startswith('bdist') for arg in sys.argv) or not setupext.check_for_readline():
|
|
|
|
install_requires.append('gnureadline')
|
2014-01-31 10:46:23 +08:00
|
|
|
elif sys.platform.startswith('win'):
|
2014-04-10 06:52:59 +08:00
|
|
|
extras_require['terminal'].append('pyreadline>=2.0')
|
2014-03-27 10:44:43 +08:00
|
|
|
|
2014-01-31 10:46:23 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
if 'setuptools' in sys.modules:
|
2013-05-01 07:18:52 +08:00
|
|
|
# setup.py develop should check for submodules
|
|
|
|
from setuptools.command.develop import develop
|
|
|
|
setup_args['cmdclass']['develop'] = require_submodules(develop)
|
2014-07-24 05:19:27 +08:00
|
|
|
setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel())
|
2013-05-01 07:18:52 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
setuptools_extra_args['zip_safe'] = False
|
2013-11-01 08:38:34 +08:00
|
|
|
setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()}
|
2014-01-31 10:46:23 +08:00
|
|
|
setup_args['extras_require'] = extras_require
|
|
|
|
requires = setup_args['install_requires'] = install_requires
|
2011-12-09 06:34:22 +08:00
|
|
|
|
|
|
|
# Script to be run by the windows binary installer after the default setup
|
|
|
|
# routine, to add shortcuts and similar windows-only things. Windows
|
|
|
|
# post-install scripts MUST reside in the scripts/ dir, otherwise distutils
|
|
|
|
# doesn't find them.
|
|
|
|
if 'bdist_wininst' in sys.argv:
|
|
|
|
if len(sys.argv) > 2 and \
|
|
|
|
('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
|
|
|
|
print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
|
|
|
|
sys.exit(1)
|
2012-12-01 08:21:57 +08:00
|
|
|
setup_args['data_files'].append(
|
|
|
|
['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
|
2011-12-09 06:34:22 +08:00
|
|
|
setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
|
|
|
|
setup_args['options'] = {"bdist_wininst":
|
|
|
|
{"install_script":
|
|
|
|
"ipython_win_post_install.py"}}
|
2012-12-01 08:21:57 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
else:
|
2014-02-01 04:20:31 +08:00
|
|
|
# If we are installing without setuptools, call this function which will
|
2011-12-09 06:34:22 +08:00
|
|
|
# check for dependencies an inform the user what is needed. This is
|
|
|
|
# just to make life easy for users.
|
2014-02-01 04:20:31 +08:00
|
|
|
for install_cmd in ('install', 'symlink'):
|
|
|
|
if install_cmd in sys.argv:
|
|
|
|
check_for_dependencies()
|
|
|
|
break
|
2013-11-01 08:38:34 +08:00
|
|
|
# scripts has to be a non-empty list, or install_scripts isn't called
|
|
|
|
setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
|
|
|
|
|
|
|
|
setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
|
2011-12-09 06:34:22 +08:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# Do the actual setup now
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
setup_args.update(setuptools_extra_args)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
setup(**setup_args)
|
|
|
|
cleanup()
|
2010-01-13 13:03:16 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|