##// END OF EJS Templates
Merge pull request #4174 from minrk/markup-templates...
Merge pull request #4174 from minrk/markup-templates various issues in markdown and rst templates - remove prompts from default output - add missing HTML block - remove double-wrapping of latex - use plain-markdown indentation for code blocks (could use GFM ``` ` ` `python```) - images didn't work in either one at all - markdown extracts output closes #4024

File last commit:

r11490:005301bb
r12461:8c88aec6 merge
Show More
setup.py
356 lines | 13.0 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.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# 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.
#~ if sys.version[0:3] < '2.6':
#~ error = """\
#~ ERROR: 'IPython requires Python Version 2.6 or above.'
#~ Exiting."""
#~ print >> sys.stderr, error
#~ sys.exit(1)
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
# On Python 3, we need distribute (new setuptools) to do the 2to3 conversion
if PY3:
import setuptools
# Our own imports
from setupbase import target_update
from setupbase import (
setup_args,
find_packages,
find_package_data,
find_scripts,
find_data_files,
check_for_dependencies,
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,
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 )
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"""
Benjie Chen
allow pip install from github repository directly
r8214 if "develop" not in sys.argv and "egg_info" not in sys.argv:
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 try:
shutil.rmtree('ipython.egg-info')
except:
try:
os.unlink('ipython.egg-info')
except:
pass
#-------------------------------------------------------------------------------
# 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'):
import textwrap
# 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/iplogger.1.gz',
['docs/man/iplogger.1'],
'cd docs/man && gzip -9c iplogger.1 > iplogger.1.gz'),
('docs/man/ipython.1.gz',
['docs/man/ipython.1'],
'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
('docs/man/irunner.1.gz',
['docs/man/irunner.1'],
'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
('docs/man/pycolor.1.gz',
['docs/man/pycolor.1'],
'cd docs/man && gzip -9c pycolor.1 > pycolor.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()
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
ensure submodules exist prior to doing anything...
r10484 'build_py': git_prebuild('IPython'),
'sdist' : 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
record sysinfo in sdist...
r7794 }
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',
'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info',
'egg_info', 'easy_install', 'upload',
))
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 = {}
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)
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 setuptools_extra_args['zip_safe'] = False
setuptools_extra_args['entry_points'] = find_scripts(True)
setup_args['extras_require'] = dict(
MinRK
bump minimum pyzmq version to 2.1.11...
r9336 parallel = 'pyzmq>=2.1.11',
qtconsole = ['pyzmq>=2.1.11', 'pygments'],
zmq = 'pyzmq>=2.1.11',
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 doc = 'Sphinx>=0.3',
test = 'nose>=0.10.1',
MinRK
bump minimum pyzmq version to 2.1.11...
r9336 notebook = ['tornado>=2.0', 'pyzmq>=2.1.11', 'jinja2'],
Paul Ivanov
check for markdown no longer needed, closes #3610...
r11296 nbconvert = ['pygments', 'jinja2', 'Sphinx>=0.3']
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 )
MinRK
add 'all' extras...
r11490 everything = set()
for deps in setup_args['extras_require'].values():
if not isinstance(deps, list):
deps = [deps]
for dep in deps:
everything.add(dep)
setup_args['extras_require']['all'] = everything
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 requires = setup_args.setdefault('install_requires', [])
setupext.display_status = False
if not setupext.check_for_readline():
if sys.platform == 'darwin':
requires.append('readline')
Nathan Rice
pyreadline dependency pushed to 1.7.1 for all versions of windows. Also, solves an issue that has been observed when IPython is used with some older versions of pyreadline.
r5930 elif sys.platform.startswith('win'):
# Pyreadline 64 bit windows issue solved in versions >=1.7.1
# Also solves issues with some older versions of pyreadline that
# satisfy the unconstrained depdendency.
requires.append('pyreadline>=1.7.1')
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 else:
pass
# do we want to install readline here?
# 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)
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 if PY3:
setuptools_extra_args['use_2to3'] = True
Matthias BUSSONNIER
disable some specific 2to3 fixes whith setup.py...
r7808 # we try to make a 2.6, 2.7, and 3.1 to 3.3 python compatible code
Matthias BUSSONNIER
fix english in comment
r7809 # so we explicitly disable some 2to3 fixes to be sure we aren't forgetting
Matthias BUSSONNIER
disable some specific 2to3 fixes whith setup.py...
r7808 # anything.
setuptools_extra_args['use_2to3_exclude_fixers'] = [
Matthias BUSSONNIER
deactivate 2to3 apply fix when using setup.py
r7814 'lib2to3.fixes.fix_apply',
Bradley M. Froehle
Skip `has_key` when running 2to3.
r7860 'lib2to3.fixes.fix_except',
'lib2to3.fixes.fix_has_key',
Bradley M. Froehle
Apply 2to3 `next` fix....
r7847 'lib2to3.fixes.fix_next',
Bradley M. Froehle
Skip `has_key` when running 2to3.
r7860 'lib2to3.fixes.fix_repr',
Matthias BUSSONNIER
remove tuple_params fix from 2to3 in setup.py
r7883 'lib2to3.fixes.fix_tuple_params',
Matthias BUSSONNIER
disable some specific 2to3 fixes whith setup.py...
r7808 ]
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 from setuptools.command.build_py import build_py
MinRK
ensure submodules exist prior to doing anything...
r10484 setup_args['cmdclass'] = {'build_py': git_prebuild('IPython', build_cmd=build_py)}
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 setuptools_extra_args['entry_points'] = find_scripts(True, suffix='3')
Thomas Kluyver
Force setuptools to skip byte compilation when installing on Python 3....
r6546 setuptools._dont_write_bytecode = True
Thomas Kluyver
Remove separate setup.py file for Python 3.
r5829 else:
# 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()
setup_args['scripts'] = find_scripts(False)
#---------------------------------------------------------------------------
# Do the actual setup now
#---------------------------------------------------------------------------
setup_args.update(setuptools_extra_args)
def main():
setup(**setup_args)
cleanup()
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()