Skip to content

Commit

Permalink
Add tools for self-contained distribution and installation.
Browse files Browse the repository at this point in the history
  • Loading branch information
fperez committed Oct 3, 2008
1 parent adc8950 commit af0aa7a
Show file tree
Hide file tree
Showing 4 changed files with 385 additions and 0 deletions.
130 changes: 130 additions & 0 deletions tools/alldeps/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Simple makefile to rapidly deploy IPython with all its dependencies.

# Configuration section. The version numbers and paths declared here may
# change with each release.

# IPython version
IPYTHON_VER=0.9.1

# Declare here version numbers of all the dependencies
PYOPENSSL_VER=0.6
ZOPE_INTERFACE_VER=3.4.1
TWISTED_VER=8.1.0
FOOLSCAP_VER=0.3.1
NOSE_VER=0.10.3

# Repository URLs for all packages. Make sure these are correct for each
# release, since projects may change paths!
IPYTHON_REPO=http://ipython.scipy.org/dist
PYOPENSSL_REPO=http://downloads.sourceforge.net/pyopenssl
ZOPE_INTERFACE_REPO=http://pypi.python.org/packages/source/z/zope.interface
TWISTED_REPO=http://tmrc.mit.edu/mirror/twisted/Twisted/8.1
FOOLSCAP_REPO=http://foolscap.lothar.com/releases
NOSE_REPO=http://somethingaboutorange.com/mrl/projects/nose

#-----------------------------------------------------------------------------
# Main code begins. There shouldn't be much to change here with each release.
#

# Hand-written files to ship in self-contained tarball
SOURCES=pkginstall pkginstall.cfg Makefile README.txt README.html

# Versions of tarballs we ship
IPYTHON=ipython-$(IPYTHON_VER).tar.gz
IP_ALLDEPS=ipython-alldeps-$(IPYTHON_VER)

PYOPENSSL=pyOpenSSL-$(PYOPENSSL_VER).tar.gz
ZOPE_INTERFACE=zope.interface-$(ZOPE_INTERFACE_VER).tar.gz
NOSE=nose-$(NOSE_VER).tar.gz
TWISTED=Twisted-$(TWISTED_VER).tar.bz2
FOOLSCAP=foolscap-$(FOOLSCAP_VER).tar.gz

TARBALLS=$(PYOPENSSL) $(ZOPE_INTERFACE) $(TWISTED) $(FOOLSCAP) \
$(NOSE) $(IPYTHON)

# URLs for downloads

#-----------------------------------------------------------------------------
# Target declaration
#

# Targets to install, in correct dependency order
install: pyopenssl zope.interface twisted foolscap nose ipython
echo
echo "IPython Installation finished."
echo "You can now run the ipython test suite by running:"
echo "iptest"
echo "If all tests pass, you can delete this entire directory."
echo

# Download targets
download: $(TARBALLS)

$(IPYTHON):
wget $(IPYTHON_REPO)/$(IPYTHON)

$(PYOPENSSL):
wget $(PYOPENSSL_REPO)/$(PYOPENSSL)

$(ZOPE_INTERFACE):
wget $(ZOPE_INTERFACE_REPO)/$(ZOPE_INTERFACE)

$(TWISTED):
wget $(TWISTED_REPO)/$(TWISTED)

$(FOOLSCAP):
wget $(FOOLSCAP_REPO)/$(FOOLSCAP)

$(NOSE):
wget $(NOSE_REPO)/$(NOSE)


# The calls to pkginstall must use the actual Python package name
nose: $(NOSE)
./pkginstall nose

zope.interface: $(ZOPE_INTERFACE)
./pkginstall zope.interface zope

pyopenssl: $(PYOPENSSL)
./pkginstall pyOpenSSL OpenSSL

twisted: $(TWISTED)
./pkginstall Twisted

foolscap: $(FOOLSCAP)
./pkginstall foolscap

ipython: $(IPYTHON)
./pkginstall ipython IPython

# Distribution targets
dist: $(IP_ALLDEPS).tar

$(IP_ALLDEPS).tar: download readme
-mkdir $(IP_ALLDEPS)
-ln $(SOURCES) $(TARBALLS) $(IP_ALLDEPS)/
tar cf $(IP_ALLDEPS).tar $(IP_ALLDEPS)
rm -rf $(IP_ALLDEPS)

readme: README.html

README.html: README.txt
rst2html README.txt > README.html

# Auxiliary targets
upload: dist
rsync -e ssh -av README.html $(IP_ALLDEPS).tar \
[email protected]:www/dist/alldeps

clean:
ls -p | grep /$ | xargs rm -rf
rm -f $(IP_ALLDEPS)* *~

distclean: clean
rm -f $(TARBALLS)
rm README.html

info:
echo "TARBALLS"
echo $(TARBALLS)
109 changes: 109 additions & 0 deletions tools/alldeps/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
===========================================================
Self-contained IPython installation with all dependencies
===========================================================

This is a self-contained source distribution of IPython with all its
*non-graphical* dependencies, that installs in a single ``make`` call to your
home directory (by default) or any location of your choice.

This distribution is meant for developer-type usage in Unix environments, it is
*not* an easy way to get IPython working on Windows, since it assumes the
presence of a working compiler and development tools.

Currently, the distribution contains::

ipython-0.9.1.tar.gz
pyOpenSSL-0.6.tar.gz
zope.interface-3.4.1.tar.gz
Twisted-8.1.0.tar.bz2
foolscap-0.3.1.tar.gz
nose-0.10.3.tar.gz


Usage
=====

Download the single tarball where this README file lives and unpack it. If
your system is already configured as described below, these lines will do the
whole job::

wget http://ipython.scipy.org/dist/alldeps/ipython-alldeps-0.9.1.tar
tar xf ipython-alldeps-0.9.1.tar
cd ipython-alldeps-0.9.1
make

If all goes well, then just type::

iptest

to run IPython's test suite.


It is meant to be used in an environment where you have your ``$PATH``,
``$PYTHONPATH``, etc variables properly configured, so that the installation of
packages can be made with (using ``~/usr/local`` as an example)::

python setup.py install --prefix=~/usr/local

For an explanation of how to do this, see below.

You can configure the default prefix used by editing the file
``pkginstall.cfg``, where you can also override the python version used for the
process. If your system is configured in this manner, you can simply type::

make

and this will build and install all of IPython's non-graphical dependencies on
your system, assuming you have Python, a compiler, the Python headers and the
SSL headers available.


.. _environment_configuration:

Environment configuration
=========================

Below is an example of what to put in your ``~/.bashrc`` file to configure your
environment as described in this document, in a reasonably portable manner that
takes 64-bit operating systems into account::

# For processor dependent config
MACHINE=$(uname -m)

# Python version information
PYVER=$(python -ESV 2>&1)
PYVER_MINOR=${PYVER#Python }
PYVER_MAJOR=${PYVER_MINOR:0:3}

function export_paths {
# Export useful paths based on a common prefix

# Input: a path prefix

local prefix=$1
local pp
local lp
local pypath=python${PYVER_MAJOR}/site-packages

# Compute paths with 64-bit specifics
if [[ $MACHINE == "x86_64" ]]; then
lp=$prefix/lib64:$prefix/lib
pp=$prefix/lib64/$pypath:$prefix/lib/$pypath
else
lp=$prefix/lib
pp=$prefix/lib/$pypath
fi

# Set paths based on given prefix
export PATH=$prefix/bin:$PATH
export CPATH=$prefix/include:$CPATH
export LD_LIBRARY_PATH=$lp:$LD_LIBRARY_PATH
export LIBRARY_PATH=$lp:$LIBRARY_PATH
export PYTHONPATH=$pp:$PYTHONPATH
}

# Actually call the export function to set the paths. If you want more than
# one such prefix, note that the call *prepends* the new prefix to the
# existing paths, so later calls take priority.

export_paths $HOME/usr/local
119 changes: 119 additions & 0 deletions tools/alldeps/pkginstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash
#
# Simple installation shell script for Python packages.
#
# Usage:
# pkginstall PAKPREFIX [PYPACKAGE]
#
# PAKPREFIX: prefix of the package as distributed in the tarball.
#
# PYPACKAGE: name of the Python package as it will end up installed. If not
# given, it defaults to PAKPREFIX.
#

#-----------------------------------------------------------------------------
# Process command-line args
#
PAKPREFIX=$1
PYPACKAGE=${2:-$PAKPREFIX}

#-----------------------------------------------------------------------------
# Configure main variables
#
# Defaults for variables that the .cfg file may override.
PYTHON_DEFAULT=python
PREFIX_DEFAULT=$HOME/usr/local

# Read config file which may declare user values for these variables.
source ./pkginstall.cfg

# Set the variables we'll actually use, either from the config file or from our
# defaults.
PYTHON=${PYTHON-${PYTHON_DEFAULT}}
PREFIX=${PREFIX-${PREFIX_DEFAULT}}

#-----------------------------------------------------------------------------
# 'Main' code begins
#

# Find the actual python executable path
PYTHONX=$(which $PYTHON)
if [[ ! -x $PYTHONX ]]; then
echo "ERROR: no python executable found at given path: $PYTHON"
echo "Aborting."
exit 1
fi

# Python version information. PYTHONV holds a versioned string used to build
# the site-packages path for the actual Python version we'll use.
PYVER=$($PYTHONX -ESV 2>&1)
PYVER_MINOR=${PYVER#Python }
PYVER_MAJOR=${PYVER_MINOR:0:3}
PYTHONV=python${PYVER_MAJOR}

# Set prefixes and other variables for the installation path.
SITEPKG=${PREFIX}/lib/${PYTHONV}/site-packages
SITEPKG64=${PREFIX}/lib64/${PYTHONV}/site-packages

# User diagnostics of current config
echo "Configuration:"
echo " PYTHON : $PYTHON"
echo " PYTHONX : $PYTHONX"
echo " PREFIX : $PREFIX"
echo " SITEPKG : $SITEPKG"
echo " SITEPKG64: $SITEPKG64"

# Find tarball
tarball=$(ls *$PAKPREFIX*.tar.*)

if [[ -z $tarball ]]; then
echo "ERROR: tarball not found for $PYPACKAGE"
exit 1
fi

# Figure out the name of the directory and compression format to use to unpack
pakdir=$(echo $tarball | awk -F '.tar.' '{print $1}')
tarfmt=$(echo $tarball | awk -F '.tar.' '{print $2}')

if [[ $tarfmt == "gz" ]]; then
tarflag="z"
else
tarflag="j"
fi

# Unpack the tarball if needed
if [[ ! -d $pakdir ]]; then
echo "Unpacking tarball: $tarball"
tar -x -${tarflag} -f $tarball

if [[ ! -d $pakdir ]]; then
echo "Tarball $tarball unpacked to unexpected path, aborting"
exit 1
fi
fi

# Remove existing ${PYPACKAGE} to make sure the build doesn't pick up spurious
# things. We don't touch the bin/ dir or anything else because it's hard to
# know what goes there in advance. But this should prevent most serious
# problems.
rm -rf $SITEPKG/${PYPACKAGE}
rm -rf $SITEPKG/${PYPACKAGE}*.egg
rm -rf $SITEPKG/${PYPACKAGE}*.egg-info

rm -rf $SITEPKG64/${PYPACKAGE}
rm -rf $SITEPKG64/${PYPACKAGE}*.egg
rm -rf $SITEPKG64/${PYPACKAGE}*.egg-info

# Make/install phase

# Set python search path correctly
export PYTHONPATH=$SITEPKG:$SITEPKG64:$PYTHONPATH

# Ensure install dirs exist
mkdir -p $SITEPKG
mkdir -p $SITEPKG64

cd ${pakdir}
rm -rf build dist
$PYTHONX setup.py clean
time $PYTHONX setup.py install --prefix=$PREFIX
27 changes: 27 additions & 0 deletions tools/alldeps/pkginstall.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- sh -*-
#
# Configuration for the pkginstall script.
# This script uses bash syntax, as it will be sourced by a bash script.

# Uncomment and set the variables you want, otherwise pkginstall has sensible
# defaults predefined. These can also be declared either as environment
# variables (which can be done by the makefile calling this script).

#-----------------------------------------------------------------------------
#
# Executable for Python.
#
# You can set this to an explicit full path if you don't want the default
# (simply 'python') to be the version used to install this package.

#PYTHON=python

#-----------------------------------------------------------------------------
#
# Default prefix.
#
# This should be a valid input the setup.py script as the --prefix argument.
# That is, your $PYTHONPATH should contain $PREFIX/lib/pythonX.Y/site-packages,
# your $PATH should contain $PREFIX/bin, etc.

#PREFIX=$HOME/usr/local

0 comments on commit af0aa7a

Please sign in to comment.