2008-02-29 02:30:23 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- 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
|
2008-05-29 11:15:04 +08:00
|
|
|
requires utilities which are not available under Windows."""
|
2008-02-29 02:30:23 +08:00
|
|
|
|
2010-10-27 14:11:20 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Copyright (c) 2008-2010, 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>
|
2008-02-29 02:30:23 +08:00
|
|
|
#
|
2010-10-27 14:11:20 +08:00
|
|
|
# Distributed under the terms of the Modified BSD License.
|
|
|
|
#
|
|
|
|
# The full license is in the file COPYING.txt, distributed with this software.
|
|
|
|
#-----------------------------------------------------------------------------
|
2008-06-07 06:16:36 +08:00
|
|
|
|
2010-01-17 08:57:22 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Minimal Python version sanity check
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# This check is also made in IPython/__init__, don't forget to update both when
|
|
|
|
# changing Python version requirements.
|
2010-10-27 07:48:15 +08:00
|
|
|
if sys.version[0:3] < '2.6':
|
2010-01-17 08:57:22 +08:00
|
|
|
error = """\
|
2010-10-27 07:48:15 +08:00
|
|
|
ERROR: 'IPython requires Python Version 2.6 or above.'
|
2010-01-17 08:57:22 +08:00
|
|
|
Exiting."""
|
|
|
|
print >> sys.stderr, error
|
|
|
|
sys.exit(1)
|
|
|
|
|
2010-10-27 07:48:15 +08:00
|
|
|
# At least we're on the python version we need, move on.
|
2010-01-17 08:57:22 +08:00
|
|
|
|
2008-06-07 06:16:36 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Imports
|
|
|
|
#-------------------------------------------------------------------------------
|
2008-02-29 02:30:23 +08:00
|
|
|
|
|
|
|
# Stdlib imports
|
|
|
|
import os
|
2010-01-13 13:03:16 +08:00
|
|
|
import shutil
|
2008-02-29 02:30:23 +08:00
|
|
|
|
|
|
|
from glob import glob
|
2008-05-29 11:15:04 +08:00
|
|
|
|
|
|
|
# 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
|
2008-02-29 02:30:23 +08:00
|
|
|
|
2010-01-17 08:57:22 +08:00
|
|
|
# Our own imports
|
2010-01-30 08:24:13 +08:00
|
|
|
from IPython.utils.path import target_update
|
2008-05-29 11:15:04 +08:00
|
|
|
|
2008-06-07 06:16:36 +08:00
|
|
|
from setupbase import (
|
|
|
|
setup_args,
|
|
|
|
find_packages,
|
|
|
|
find_package_data,
|
|
|
|
find_scripts,
|
|
|
|
find_data_files,
|
2010-10-27 14:11:20 +08:00
|
|
|
check_for_dependencies,
|
|
|
|
record_commit_info,
|
2008-06-07 06:16:36 +08:00
|
|
|
)
|
2011-04-12 02:56:47 +08:00
|
|
|
from setupext import setupext
|
2008-06-07 06:16:36 +08:00
|
|
|
|
2008-02-29 02:30:23 +08:00
|
|
|
isfile = os.path.isfile
|
2009-07-03 05:35:36 +08:00
|
|
|
pjoin = os.path.join
|
2008-06-07 06:16:36 +08:00
|
|
|
|
2010-01-13 13:03:16 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function definitions
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def cleanup():
|
|
|
|
"""Clean up the junk left around by the build process"""
|
|
|
|
if "develop" not in sys.argv:
|
|
|
|
try:
|
|
|
|
shutil.rmtree('ipython.egg-info')
|
|
|
|
except:
|
|
|
|
try:
|
|
|
|
os.unlink('ipython.egg-info')
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2008-06-07 06:16:36 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Handle OS specific things
|
|
|
|
#-------------------------------------------------------------------------------
|
2008-02-29 02:30:23 +08:00
|
|
|
|
|
|
|
if os.name == 'posix':
|
|
|
|
os_name = 'posix'
|
|
|
|
elif os.name in ['nt','dos']:
|
|
|
|
os_name = 'windows'
|
|
|
|
else:
|
|
|
|
print 'Unsupported operating system:',os.name
|
|
|
|
sys.exit(1)
|
|
|
|
|
2008-05-29 11:15:04 +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.
|
2008-02-29 02:30:23 +08:00
|
|
|
if os_name == 'windows' and 'sdist' in sys.argv:
|
|
|
|
print 'The sdist command is not available under Windows. Exiting.'
|
|
|
|
sys.exit(1)
|
|
|
|
|
2008-06-07 06:16:36 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Things related to the IPython documentation
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2008-02-29 02:30:23 +08:00
|
|
|
# update the manuals when building a source dist
|
|
|
|
if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
|
2008-05-23 00:44:30 +08:00
|
|
|
import textwrap
|
2008-05-29 11:15:04 +08:00
|
|
|
|
|
|
|
# List of things to be updated. Each entry is a triplet of args for
|
2008-02-29 02:30:23 +08:00
|
|
|
# target_update()
|
2008-06-09 06:25:02 +08:00
|
|
|
to_update = [
|
2008-05-29 11:15:04 +08:00
|
|
|
# FIXME - Disabled for now: we need to redo an automatic way
|
|
|
|
# of generating the magic info inside the rst.
|
2008-08-15 10:33:53 +08:00
|
|
|
#('docs/magic.tex',
|
2008-05-29 11:15:04 +08:00
|
|
|
#['IPython/Magic.py'],
|
|
|
|
#"cd doc && ./update_magic.sh" ),
|
2009-07-31 09:16:44 +08:00
|
|
|
|
|
|
|
('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'),
|
|
|
|
|
2008-08-15 10:33:53 +08:00
|
|
|
('docs/man/ipython.1.gz',
|
|
|
|
['docs/man/ipython.1'],
|
2009-07-31 09:16:44 +08:00
|
|
|
'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
|
|
|
|
|
|
|
|
('docs/man/ipython-wx.1.gz',
|
|
|
|
['docs/man/ipython-wx.1'],
|
|
|
|
'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'),
|
|
|
|
|
|
|
|
('docs/man/ipythonx.1.gz',
|
|
|
|
['docs/man/ipythonx.1'],
|
|
|
|
'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'),
|
|
|
|
|
|
|
|
('docs/man/irunner.1.gz',
|
|
|
|
['docs/man/irunner.1'],
|
|
|
|
'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
|
2008-05-29 11:15:04 +08:00
|
|
|
|
2008-08-15 10:33:53 +08:00
|
|
|
('docs/man/pycolor.1.gz',
|
|
|
|
['docs/man/pycolor.1'],
|
2009-07-31 09:16:44 +08:00
|
|
|
'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'),
|
2008-05-29 11:15:04 +08:00
|
|
|
]
|
|
|
|
|
2008-08-29 07:34:53 +08:00
|
|
|
# Only build the docs if sphinx is present
|
2008-06-09 06:25:02 +08:00
|
|
|
try:
|
|
|
|
import sphinx
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
2008-08-29 07:34:53 +08:00
|
|
|
# The Makefile calls the do_sphinx scripts to build html and pdf, so
|
|
|
|
# just one target is enough to cover all manual generation
|
|
|
|
|
|
|
|
# First, compute all the dependencies that can force us to rebuild the
|
|
|
|
# docs. Start with the main release file that contains metadata
|
2009-07-03 05:35:36 +08:00
|
|
|
docdeps = ['IPython/core/release.py']
|
2008-08-29 07:34:53 +08:00
|
|
|
# Inculde all the reST sources
|
|
|
|
pjoin = os.path.join
|
|
|
|
for dirpath,dirnames,filenames in os.walk('docs/source'):
|
|
|
|
if dirpath in ['_static','_templates']:
|
|
|
|
continue
|
|
|
|
docdeps += [ pjoin(dirpath,f) for f in filenames
|
|
|
|
if f.endswith('.txt') ]
|
|
|
|
# and the examples
|
|
|
|
for dirpath,dirnames,filenames in os.walk('docs/example'):
|
|
|
|
docdeps += [ pjoin(dirpath,f) for f in filenames
|
|
|
|
if not f.endswith('~') ]
|
|
|
|
# then, make them all dependencies for the main PDF (the html will get
|
|
|
|
# auto-generated as well).
|
|
|
|
to_update.append(
|
|
|
|
('docs/dist/ipython.pdf',
|
|
|
|
docdeps,
|
|
|
|
"cd docs && make dist")
|
|
|
|
)
|
2008-08-15 18:21:15 +08:00
|
|
|
|
2008-05-29 11:15:04 +08:00
|
|
|
[ target_update(*t) for t in to_update ]
|
2008-08-15 18:21:15 +08:00
|
|
|
|
2008-06-07 06:16:36 +08:00
|
|
|
#---------------------------------------------------------------------------
|
2011-04-08 13:51:31 +08:00
|
|
|
# Find all the packages, package data, and data_files
|
2008-06-07 06:16:36 +08:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
packages = find_packages()
|
|
|
|
package_data = find_package_data()
|
|
|
|
data_files = find_data_files()
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
2011-04-08 13:51:31 +08:00
|
|
|
# Handle scripts, dependencies, and setuptools specific things
|
2008-06-07 06:16:36 +08:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2010-01-10 11:31:46 +08:00
|
|
|
# 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'
|
|
|
|
if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm',
|
|
|
|
'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info',
|
|
|
|
'build_sphinx', 'egg_info', 'easy_install', 'upload',
|
|
|
|
)).intersection(sys.argv)) > 0:
|
|
|
|
import setuptools
|
|
|
|
|
2008-06-07 06:16:36 +08:00
|
|
|
# This dict is used for passing extra arguments that are setuptools
|
|
|
|
# specific to setup
|
|
|
|
setuptools_extra_args = {}
|
2008-02-29 02:30:23 +08:00
|
|
|
|
|
|
|
if 'setuptools' in sys.modules:
|
2008-06-07 06:16:36 +08:00
|
|
|
setuptools_extra_args['zip_safe'] = False
|
|
|
|
setuptools_extra_args['entry_points'] = {
|
2011-04-08 13:51:31 +08:00
|
|
|
'console_scripts': find_scripts(True)
|
2008-06-07 06:16:36 +08:00
|
|
|
}
|
2008-08-24 13:29:14 +08:00
|
|
|
setup_args['extras_require'] = dict(
|
2011-04-07 12:34:12 +08:00
|
|
|
parallel = 'pyzmq>=2.1.4',
|
2011-04-07 05:54:33 +08:00
|
|
|
zmq = 'pyzmq>=2.0.10.1',
|
2008-08-24 13:29:14 +08:00
|
|
|
doc='Sphinx>=0.3',
|
2008-06-07 06:16:36 +08:00
|
|
|
test='nose>=0.10.1',
|
|
|
|
)
|
2011-04-09 08:04:24 +08:00
|
|
|
requires = setup_args.setdefault('install_requires', [])
|
2011-04-12 02:56:47 +08:00
|
|
|
setupext.display_status = False
|
|
|
|
if not setupext.check_for_readline():
|
2011-04-12 01:54:50 +08:00
|
|
|
if sys.platform == 'darwin':
|
2011-04-12 02:56:47 +08:00
|
|
|
requires.append('readline')
|
2011-04-12 01:54:50 +08:00
|
|
|
elif sys.platform.startswith('win'):
|
|
|
|
requires.append('pyreadline')
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
# do we want to install readline here?
|
2011-04-08 13:51:31 +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)
|
|
|
|
setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
|
2008-02-29 02:30:23 +08:00
|
|
|
else:
|
2008-06-07 06:16:36 +08:00
|
|
|
# If we are running without setuptools, call this function which will
|
|
|
|
# check for dependencies an inform the user what is needed. This is
|
|
|
|
# just to make life easy for users.
|
|
|
|
check_for_dependencies()
|
2011-04-08 13:51:31 +08:00
|
|
|
setup_args['scripts'] = find_scripts(False)
|
2008-06-07 06:16:36 +08:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# Do the actual setup now
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2010-10-27 14:11:20 +08:00
|
|
|
setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')}
|
2008-06-07 06:16:36 +08:00
|
|
|
setup_args['packages'] = packages
|
|
|
|
setup_args['package_data'] = package_data
|
|
|
|
setup_args['data_files'] = data_files
|
|
|
|
setup_args.update(setuptools_extra_args)
|
|
|
|
|
2010-01-13 13:03:16 +08:00
|
|
|
|
2008-06-07 06:16:36 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
setup(**setup_args)
|
2010-01-13 13:03:16 +08:00
|
|
|
cleanup()
|