Created
August 16, 2013 16:39
-
-
Save jaberg/6251456 to your computer and use it in GitHub Desktop.
Bootstrap a gcc-based Python environment on Sharcnet (tested on Monk)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script installs Python and various site packages on sharcnet using gcc. | |
# It will create something similar to virtualenv, but with Python itself built | |
# from scratch. Also, this is not as sophisticated as virtualenv, in particular | |
# it has no `deactivate` function. | |
# | |
# --turn on tracing | |
set -x | |
# --exit on error | |
set -e | |
PREFIX=${PWD} | |
# --------------------------------------------------------------------------- | |
# | |
# Build up the fake_venv.sh environment-activation script | |
# | |
# This script is meant to be re-sourced every time you want | |
# to reactivate your intallation. It removes conflicting sharcnet modules | |
# and adjusts some environment variables. | |
# | |
FAKE_VENV_SH=fake_venv.sh | |
echo "module rm python intel openmpi mkl" > ${FAKE_VENV_SH} | |
# -- could choose to leave PATH variable in line rather than unpacking it | |
# in this script... choosing to hard-code it here | |
echo "export PATH=${PWD}/bin:${PATH}" >> ${FAKE_VENV_SH} | |
echo "export LD_LIBRARY_PATH=${PWD}/lib:${LD_LIBRARY_PATH}" >> ${FAKE_VENV_SH} | |
# -- Re: LDFLAGS, they are by numpy.distutils, and if they are not set up with | |
# numpy distutils in mind (currently the sharcnet default is that they are | |
# not) they have the effect of breaking numpy's fortran compiler calling | |
# convention (e.g. no -shared argument when building .so libs) | |
# | |
# -- If the LDFLAGS are important for other things, consider just hiding them | |
# during pip install calls. | |
echo "export -n LDFLAGS" >> ${FAKE_VENV_SH} | |
echo "Remember to source '${FAKE_VENV_SH}' to activate this installation" | |
source ${FAKE_VENV_SH} | |
# --------------------------------------------------------------------------- | |
# Bootstrap Python | |
PYTHON_NAME=Python-2.7.5 | |
wget "http://python.org/ftp/python/2.7.5/${PYTHON_NAME}.tar.bz2" | |
tar xjf ${PYTHON_NAME}.tar.bz2 | |
(cd ${PYTHON_NAME} \ | |
&& ./configure --prefix=${PREFIX} --enable-shared \ | |
&& make \ | |
&& make install) | |
# -- from https://pypi.python.org/pypi/setuptools/0.9.8 | |
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python | |
# -- http://www.pip-installer.org/en/latest/installing.html | |
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py | |
python get-pip.py | |
# --------------------------------------------------------------------------- | |
# Install some standard site-packages | |
for pkg in numpy scipy matplotlib nose tornado pyzmq ipython pycuda; do | |
pip install ${pkg} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment