Skip to content

Instantly share code, notes, and snippets.

@aodag
Created May 3, 2014 13:57
Show Gist options
  • Save aodag/eeadd3200436010e5285 to your computer and use it in GitHub Desktop.
Save aodag/eeadd3200436010e5285 to your computer and use it in GitHub Desktop.
veriy simple python installer
#!/bin/sh
# -*- mode:sh -*-
version=$1
if [ "x$1" = "x" ] ; then
exit 1
fi
major=$(echo $version | awk -F "." '{print $1}')
minor=$(echo $version | awk -F "." '{print $2}')
micro=$(echo $version | awk -F "." '{print $3}')
echo major $major
echo mimor $minor
echo micro $micro
if [ "x$major" = "x" ] ; then
exit 1
fi
if [ "x$minor" = "x" ] ; then
exit 1
fi
if [ "x$micro" = "x" ] ; then
micro=0
fi
suffix=tar.bz2
echo start install $version
download_filename=Python-$version.$suffix
url="https://www.python.org/ftp/python/$version/$download_filename"
srcdir="/tmp/paison/$version"
destdir="/opt/python-$version"
mkdir -p $srcdir
echo downloading $url
curl $url -o $srcdir/$download_filename
cd $srcdir
echo unpacking $download_filename
tar xvf $download_filename
cd $(basename -s .$suffix $download_filename)
echo buidging
./configure --prefix=$destdir
make
echo install python-${major}.${minor}.${micro}
sudo make install
echo set up path
mkdir -p $HOME/bin
cd $HOME/bin
ln -s $destdir/bin/python${major}.${minor} .
@kwatch
Copy link

kwatch commented May 9, 2014

Python3.3.4以降はtar.bz2を用意しないようになった(かわりにtar.xzをダウンロードしろとのこと)ので、このスクリプトだと3.4.0もインストールできないでしょう。
自分も似たようなスクリプトを作ってたので、困りました。tar.bz2も用意してほしいと言ったのですが、拒絶されました・・・
#チラシの裏コメント

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment