Skip to content

Instantly share code, notes, and snippets.

@paridin
Last active September 5, 2018 17:55
Show Gist options
  • Save paridin/40a8cfb87db895280dc5 to your computer and use it in GitHub Desktop.
Save paridin/40a8cfb87db895280dc5 to your computer and use it in GitHub Desktop.
a simple script for install python3.7 on *nix systems
#!/bin/bash
# Copyright (c) 2015, Roberto Estrada
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# First relase 27 Aug 2015
# A simple script who help to install a devel enviroment on nix system, it works without root permissions
# dependencies/pre requisites:
# yum install openssl openssl-devel
# (RH, Centos, Fedora)
# yum group install "Development Tools"
# yum install libxslt-devel libxml2-devel
# yum install bzip2-devel ncurses-devel gdbm-devel sqlite-devel readline-devel xz-devel zlib-devel openssl-devel libxslt-devel libxml2-devel libjpeg-turbo
# (Debian/Ubuntu)
# sudo apt install libssl-dev openssl
# sudo apt install build-essential
# sudo apt install libncurses5-dev libbz2-dev libgdbm-dev lzma-dev liblzma-dev libsqlite3-dev libreadline-dev
# sudo apt install tk-dev # only if you want develop with tk
# updated 7 Oct 2015 - Add BSD License
# updated 24 Sep 2017 - To work with docker.
# updated 5 Sep 2018 - To python 3.7.0
# SETUP
VERSION=3.7.0
INSTALL_DIR=$HOME/.local/tmp;
DEVEL_DIR=$HOME/Devel/python;
VIRTUAL_DIR=$HOME/.virtualenvs
LAST_STABLE_PYTHON=Python-${VERSION}.tgz
LOCAL_DIR=$HOME/.local
mkdir -p $INSTALL_DIR $DEVEL_DIR;
cd $INSTALL_DIR;
# get last version of python and install it
wget https://www.python.org/ftp/python/${VERSION}/${LAST_STABLE_PYTHON}
tar -xvzf Python-${VERSION}.tgz
cd Python-${VERSION}
./configure --prefix=$LOCAL_DIR --enable-shared --enable-optimizations
make -j8 build_all
make -j8 install
# linking python3 as python for easy control
cd $LOCAL_DIR/bin
ln -s python3 python
cd -
# INSTALL
# setting variables in bash_profile
# virtualenv was removed since we can use venv or pipenv to work with virtual envs the pipenv had a lot improvements
echo "export PATH=$HOME/.local/bin:\$PATH" >> ~/.bash_profile
echo "export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH" >> ~/.bash_profile
echo "export VIRTUALENVWRAPPER_PYTHON=$HOME/.local/bin/python" >> ~/.bash_profile
echo "export WORKON_HOME=$VIRTUAL_DIR" >> ~/.bash_profile
echo "export PROJECT_HOME=$DEVEL_DIR" >> ~/.bash_profile
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
cd -
# cleaning tmps
rm -rf $INSTALL_DIR/*
source ~/.bash_profile
@paridin
Copy link
Author

paridin commented Sep 24, 2015

Install

wget http://bit.ly/install_py3_6_2 -O install_py3.6.sh
bash install_py3.6.sh
source ~/.bash_profile

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