Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix system python and added yum wrapper #14

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions scripts/base/install_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,54 @@

set -ex

# Create script to allow use of system python
cat <<EOF > /usr/local/bin/run-with-system-python
#!/bin/sh
# Unsets all environment variables so that the system python can function normally
# To use, just prefix any command with run-with-system-python
unset PYTHONPATH
unset LIBRARY_PATH
unset PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/rh/devtoolset-6/root/usr/lib64:/opt/rh/devtoolset-6/root/usr/lib
export PATH=/opt/rh/devtoolset-6/root/usr/bin:/opt/app-root/src/bin:/opt/rh/devtoolset-6/root/usr/bin/:/usr/sbin:/usr/bin:/sbin:/bin
exec "\$@"
EOF
chmod a+x /usr/local/bin/run-with-system-python

# Create a yum wrapper that uses the system python
cat <<EOF > /usr/local/bin/yum
#!/bin/sh
# This runs yum with system python
exec /usr/local/bin/run-with-system-python /usr/bin/yum "\$@"
EOF
chmod a+x /usr/local/bin/yum

curl --location https://www.python.org/ftp/python/${PYTHON_VERSION_FULL}/Python-${PYTHON_VERSION_FULL}.tgz -o Python.tgz
tar xf Python.tgz && rm Python.tgz
cd Python-${PYTHON_VERSION_FULL}

./configure \
# Ensure configure, build and install is done with no reference to /usr/local as this somehow messes up the system install
run-with-system-python ./configure \
--prefix=/usr/local \
--enable-unicode=ucs4 \
--enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make -j4
--enable-shared
run-with-system-python make -j4

sudo make install
run-with-system-python make altinstall

if [[ $PYTHON_VERSION == 3* ]]; then
# Create symlink from python3 to python
ln -s /usr/local/bin/python3 /usr/local/bin/python
sudo ln -s /usr/local/bin/python3 /usr/local/bin/python
fi

cd ../..
cd ..
rm -rf Python-${PYTHON_VERSION_FULL}

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" &&\
python get-pip.py
rm get-pip.py

pip install \
nose \
epydoc
epydoc \
coverage