-
-
Save ckandoth/f25c7469f23e63e34bee346fcb10ec29 to your computer and use it in GitHub Desktop.
# Create a folder where you want to install different Pythons, and cd into it: | |
# Note that it doesn't need to be your home folder. Put it wherever you want to maintain such software: | |
export PYTHON_BASE="$HOME/python" | |
mkdir -p $PYTHON_BASE | |
cd $PYTHON_BASE | |
# Download source tarball into a subfolder named src, and untar: | |
curl --create-dirs -L -o src/Python-2.7.10.tgz https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz | |
cd src | |
tar -zxf Python-2.7.10.tgz | |
# Configure, build, and install into a properly versioned subdirectory: | |
cd Python-2.7.10 | |
./configure --prefix=$PYTHON_BASE/python-2.7.10 --enable-shared --enable-unicode=ucs4 LDFLAGS="-Wl,-rpath=$PYTHON_PREFIX/lib" | |
make | |
make install | |
# Make sure the latest setuptools and pip are installed: | |
$PYTHON_BASE/python-2.7.10/bin/python -m ensurepip | |
$PYTHON_BASE/python-2.7.10/bin/pip install --upgrade setuptools pip | |
# Install all the various packages we use here at MSKCC: | |
$PYTHON_BASE/python-2.7.10/bin/pip install --upgrade alabaster ansi argparse azure babel biopython drmaa filemagic fireworks fusepy ipython lockfile markerlib nose powerline-status pygments pyvcf sh snowballstemmer sphinx virtualenv wheel | |
$PYTHON_BASE/python-2.7.10/bin/pip install --upgrade pysam matplotlib pandas cython scipy |
But you didn't set PYTHON_PREFIX
...
./configure --prefix=$PYTHON_BASE/python-2.7.10 --enable-shared --enable-unicode=ucs4 LDFLAGS="-Wl,-rpath=$PYTHON_PREFIX/lib"
)!
becomes
./configure --prefix=$PYTHON_BASE/python-2.7.10 --enable-shared --enable-unicode=ucs4 LDFLAGS="-Wl,-rpath=/lib"
)!
So shouldn't PYTHON_PREFIX
be set to something in $PYTHON_BASE/python-2.7.10
?? If it is not set, /lib
will be used as shown above.
:edit: Apparently yes, since python/cpython#80840 says rpath is runtime path and it needs to be the correct directory to find libpython, but I'm not sure where libpython will end up.
./configure --enable-shared --prefix=/opt/python LDFLAGS=-Wl,-rpath=/opt/python/lib
./configure --enable-shared --prefix=/opt/python LDFLAGS=-Wl,-rpath=/opt/python/lib
Thanks, that clarifies it should be nested. But...if you want multiple versions of Python installed (which is already assumed by installing Python 2), putting a version in the path will make it more maintainable (So your programs can require that version, instead of using the wrong version on a different computer or after reinstall). In other words, if that directory structure works:
- The original script which specifies the version can be fixed simply by setting
export PYTHON_PREFIX=$PYTHON_BASE/python-2.7.10
afterexport PYTHON_BASE="$HOME/python"
, then:./configure --prefix=$PYTHON_PREFIX --enable-shared --enable-unicode=ucs4 LDFLAGS="-Wl,-rpath=$PYTHON_PREFIX/lib"
- I'd even use
$PYTHON_BASE/python-2.7
forPYTHON_PREFIX
(and for-prefix
) instead, so programs can find still find it after updating Python 2 (and there probably aren't API changes between subminor versions such as between 2.7.10 and 2.7.11. If you really need to distinguish between them, you could make $PYTHON_BASE/python2 a symlink to the one you want to use for your programs).
normal not use make install for python
for python use online
make altinstall
and for pip install not use
$PYTHON_BASE/python-2.7.10/bin/python -m ensurepip
use online
$PYTHON_BASE/python-2.7.10/bin/python -m ensurepip --altinstall