##// END OF EJS Templates
Revert "use testpath.tempdir for utils.tempdir"
Revert "use testpath.tempdir for utils.tempdir"

File last commit:

r21102:3abb325f
r21102:3abb325f
Show More
setup.py
360 lines | 12.3 KiB | text/x-python | PythonLexer
Fernando Perez
Fix setup.py script to be executable (other tools expect this)
r4924 #!/usr/bin/env python
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 # -*- 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.
#
Jonathan Frederic
s/COPYING.txt/COPYING.rst
r15990 # The full license is in the file COPYING.rst, distributed with this software.
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 #-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Minimal Python version sanity check
#-----------------------------------------------------------------------------
from __future__ import print_function
Fernando Perez
Inform user at install time of minimal python requirements if not met....
r2493
import sys
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 # This check is also made in IPython/__init__, don't forget to update both when
# changing Python version requirements.
MinRK
check for Python 3.2...
r16173 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."
MinRK
update version-check message in setup.py and IPython.__init__...
r12473 print(error, file=sys.stderr)
sys.exit(1)
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829
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,
MinRK
run check_package_data as part of build_py...
r15165 check_package_data_first,
Thomas Kluyver
Rework setup to allow installing on Python 2 and 3....
r13452 find_entry_points,
build_scripts_entrypt,
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 find_data_files,
MinRK
remove non-setuptools dependency checks
r20817 check_for_readline,
MinRK
ensure submodules exist prior to doing anything...
r10484 git_prebuild,
MinRK
use utils/submodule in setup.py...
r10556 check_submodule_status,
MinRK
ensure submodules exist prior to doing anything...
r10484 update_submodules,
require_submodules,
UpdateSubmodules,
MinRK
always construct requirements
r15030 get_bdist_wheel,
MinRK
add `setup.py css` command...
r12531 CompileCSS,
MinRK
add `setup.py jsversion`...
r13536 JavascriptVersion,
MinRK
don’t store minified css in development...
r17333 css_js_prerelease,
Thomas Kluyver
Rework setup to allow installing on Python 2 and 3....
r13452 install_symlinked,
install_lib_symlink,
install_scripts_for_symlink,
Thomas Kluyver
Add 'unsymlink command to remove the symlink
r13862 unsymlink,
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 )
isfile = os.path.isfile
pjoin = os.path.join
#-------------------------------------------------------------------------------
# Handle OS specific things
#-------------------------------------------------------------------------------
MinRK
don't give up on weird os names...
r10087 if os.name in ('nt','dos'):
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 os_name = 'windows'
Ville M. Vainio
more crlf
r1033 else:
MinRK
don't give up on weird os names...
r10087 os_name = os.name
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829
# 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)
#-------------------------------------------------------------------------------
MinRK
ensure submodules exist prior to doing anything...
r10484 # Make sure we aren't trying to run without submodules
#-------------------------------------------------------------------------------
MinRK
use utils/submodule in setup.py...
r10556 here = os.path.abspath(os.path.dirname(__file__))
MinRK
ensure submodules exist prior to doing anything...
r10484
MinRK
use utils/submodule in setup.py...
r10556 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.
MinRK
ensure submodules exist prior to doing anything...
r10484 """
Thomas Kluyver
Make submodule checks work under Python 3....
r10815 # PACKAGERS: Add a return here to skip checks for git submodules
MinRK
ensure submodules exist prior to doing anything...
r10484 # don't do anything if nothing is actually supposed to happen
MinRK
use utils/submodule in setup.py...
r10556 for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'):
MinRK
ensure submodules exist prior to doing anything...
r10484 if do_nothing in sys.argv:
return
MinRK
use utils/submodule in setup.py...
r10556 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()
MinRK
ensure submodules exist prior to doing anything...
r10484
#-------------------------------------------------------------------------------
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 # 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()
MinRK
only validate package_data when it might be used...
r15114
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 data_files = find_data_files()
setup_args['packages'] = packages
setup_args['package_data'] = package_data
setup_args['data_files'] = data_files
#---------------------------------------------------------------------------
MinRK
record sysinfo in sdist...
r7794 # custom distutils commands
MinRK
enable uploading wininst to PyPI with tools/release_windows.py...
r7792 #---------------------------------------------------------------------------
MinRK
record sysinfo in sdist...
r7794 # imports here, so they are after setuptools import if there was one
from distutils.command.sdist import sdist
from distutils.command.upload import upload
MinRK
enable uploading wininst to PyPI with tools/release_windows.py...
r7792
class UploadWindowsInstallers(upload):
Christoph Gohlke
Improve Windows start menu shortcuts
r8814
MinRK
enable uploading wininst to PyPI with tools/release_windows.py...
r7792 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)
Christoph Gohlke
Improve Windows start menu shortcuts
r8814
MinRK
enable uploading wininst to PyPI with tools/release_windows.py...
r7792 def run(self):
for dist_file in glob(self.files):
self.upload_file('bdist_wininst', 'any', dist_file)
MinRK
record sysinfo in sdist...
r7794 setup_args['cmdclass'] = {
MinRK
add strict arg to css_js setup decorator...
r17343 'build_py': css_js_prerelease(
Min RK
remove strict arg from css_js_prerelease
r19853 check_package_data_first(git_prebuild('IPython'))),
'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)),
MinRK
record sysinfo in sdist...
r7794 'upload_wininst' : UploadWindowsInstallers,
MinRK
ensure submodules exist prior to doing anything...
r10484 'submodule' : UpdateSubmodules,
MinRK
add `setup.py css` command...
r12531 'css' : CompileCSS,
Thomas Kluyver
Rework setup to allow installing on Python 2 and 3....
r13452 'symlink': install_symlinked,
'install_lib_symlink': install_lib_symlink,
'install_scripts_sym': install_scripts_for_symlink,
Thomas Kluyver
Add 'unsymlink command to remove the symlink
r13862 'unsymlink': unsymlink,
MinRK
add `setup.py jsversion`...
r13536 'jsversion' : JavascriptVersion,
MinRK
record sysinfo in sdist...
r7794 }
MinRK
enable uploading wininst to PyPI with tools/release_windows.py...
r7792
Min RK
disable install from master...
r21036 ### Temporarily disable install while it's broken during the big split
from textwrap import dedent
from distutils.command.install import install
class DisabledInstall(install):
def run(self):
msg = dedent("""
While we are in the midst of The Big Split,
IPython cannot be installed from master.
You can use `pip install -e .` for an editable install,
which still works.
""")
print(msg, file=sys.stderr)
raise SystemExit(1)
setup_args['cmdclass']['install'] = DisabledInstall
MinRK
enable uploading wininst to PyPI with tools/release_windows.py...
r7792 #---------------------------------------------------------------------------
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 # 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',
MinRK
always construct requirements
r15030 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
'egg_info', 'easy_install', 'upload', 'install_egg_info',
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 ))
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 = {}
MinRK
always construct requirements
r15030 # setuptools requirements
Min RK
bump pyzmq version dependency to 13...
r20354 pyzmq = 'pyzmq>=13'
MinRK
always construct requirements
r15030 extras_require = dict(
Min RK
bump pyzmq version dependency to 13...
r20354 parallel = [pyzmq],
qtconsole = [pyzmq, 'pygments'],
MinRK
always construct requirements
r15030 doc = ['Sphinx>=1.1', 'numpydoc'],
Min RK
Revert "use testpath.tempdir for utils.tempdir"
r21102 test = ['nose>=0.10.1', 'requests'],
MinRK
add ipython[terminal] dependency group...
r16386 terminal = [],
MinRK
Use Draft4 JSON Schema for both v3 and v4...
r18243 nbformat = ['jsonschema>=2.0'],
Min RK
bump pyzmq version dependency to 13...
r20354 notebook = ['tornado>=4.0', pyzmq, 'jinja2', 'pygments', 'mistune>=0.5'],
MinRK
require mistune 0.3.1...
r17522 nbconvert = ['pygments', 'jinja2', 'mistune>=0.3.1']
MinRK
always construct requirements
r15030 )
MinRK
remove jsonschema and jsonpointer from external...
r16907
Min RK
add terminado as [notebook] dep on non-Windows
r20257 if not sys.platform.startswith('win'):
extras_require['notebook'].append('terminado>=0.3.3')
Thomas Kluyver
Add mock to requirements for testing
r15598 if sys.version_info < (3, 3):
extras_require['test'].append('mock')
MinRK
remove jsonschema and jsonpointer from external...
r16907 extras_require['notebook'].extend(extras_require['nbformat'])
extras_require['nbconvert'].extend(extras_require['nbformat'])
MinRK
remove path from external
r20811 install_requires = [
MinRK
remove decorator from external
r20813 'decorator',
Min RK
remove pickleshare from external
r20844 'pickleshare',
MinRK
remove simplegeneric from external...
r20816 'simplegeneric>0.8',
MinRK
remove path from external
r20811 ]
MinRK
add ipython[terminal] dependency group...
r16386
MinRK
remove pexpect from external...
r20815 # add platform-specific dependencies
MinRK
always construct requirements
r15030 if sys.platform == 'darwin':
MinRK
remove appnope from external...
r20814 install_requires.append('appnope')
MinRK
remove non-setuptools dependency checks
r20817 if 'bdist_wheel' in sys.argv[1:] or not check_for_readline():
MinRK
adjust dependency check for gnureadline on OS X...
r15404 install_requires.append('gnureadline')
MinRK
remove pexpect from external...
r20815
if sys.platform.startswith('win'):
MinRK
add ipython[terminal] dependency group...
r16386 extras_require['terminal'].append('pyreadline>=2.0')
MinRK
remove pexpect from external...
r20815 else:
install_requires.append('pexpect')
cgohlke
Remove PyReadline as a install requirement on Windows
r16244
Min RK
calculate 'all' dependency set after finishing the rest...
r20256 everything = set()
for deps in extras_require.values():
everything.update(deps)
extras_require['all'] = everything
MinRK
always construct requirements
r15030
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 if 'setuptools' in sys.modules:
MinRK
ensure submodules exist prior to doing anything...
r10484 # setup.py develop should check for submodules
from setuptools.command.develop import develop
setup_args['cmdclass']['develop'] = require_submodules(develop)
Min RK
remove strict arg from css_js_prerelease
r19853 setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel())
MinRK
ensure submodules exist prior to doing anything...
r10484
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 setuptools_extra_args['zip_safe'] = False
Lev Abalkin
Closes #7558: Added pygments entry points for ipython lexers.
r20117 setuptools_extra_args['entry_points'] = {
'console_scripts': find_entry_points(),
'pygments.lexers': [
Thomas Kluyver
Move IPython lexers module to lib...
r20625 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
'ipython = IPython.lib.lexers:IPythonLexer',
'ipython3 = IPython.lib.lexers:IPython3Lexer',
Lev Abalkin
Closes #7558: Added pygments entry points for ipython lexers.
r20117 ],
}
MinRK
always construct requirements
r15030 setup_args['extras_require'] = extras_require
requires = setup_args['install_requires'] = install_requires
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829
# 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):
Matthias Bussonnier
Some code cleanup in javascript and python...
r19739 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 sys.exit(1)
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 setup_args['data_files'].append(
['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
setup_args['options'] = {"bdist_wininst":
{"install_script":
"ipython_win_post_install.py"}}
Christoph Gohlke
Improve Windows start menu shortcuts
r8814
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 else:
Thomas Kluyver
Rework setup to allow installing on Python 2 and 3....
r13452 # 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
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829
#---------------------------------------------------------------------------
# Do the actual setup now
#---------------------------------------------------------------------------
setup_args.update(setuptools_extra_args)
def main():
setup(**setup_args)
Fernando Perez
Move cleanup to main setup.py, where it belongs....
r2460
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 if __name__ == '__main__':
main()