Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I ran into a situation where I needed to use Python3 rather then Python 2.7 so I cooked up a Makefile so I could do it whenever I needed to again. This way I can keep my older Python installs and not break some Linux packages as I can refer to my new alias python3 at the command-line while still being able to call python at any time for older versions.
- It should work on any YUM or APT-GET based Linux OS, Tested it on Centos6 and Ubuntu14.
- Changing the value of PYTHON_BRANCH lets you pull down any specific branch from the cPython GitHub (latest as of writing this is 3.5), changing the value of CORES to be -j4, or -j8 lets you use more cores when compiling from source (4 cores, and 8 cores respectively.)
- Enjoy.
- #NEED PYTHON 3
- PYTHON_BRANCH=3.4
- CORES=-j2
- YUM=$(shell which yum)
- APT=$(shell which apt-get)
- TOOLS=git gcc
- INSTALL_ROOT:=$(shell echo $$PWD/dist/)
- git:
- ifneq ($(YUM),)
- which $(TOOLS) || yum -y install git \
- gcc gcc-c++ \
- zlib-devel openssl-devel
- endif
- ifneq ($(APT),)
- which $(TOOLS) || apt-get install -y git gcc g++ man zlib1g-dev libssl-dev
- endif
- python-src:
- git clone --branch $(PYTHON_BRANCH) https://github.com/python/cpython.git python3
- python-build:
- (cd python3/; \
- ./configure; \
- make -s $(CORES); \
- make -s $(CORES) altinstall)
- install: git python-src python-build
Advertisement
Add Comment
Please, Sign In to add comment