Skip to content

Instantly share code, notes, and snippets.

@arnobaer
Last active September 10, 2019 17:51
Show Gist options
  • Save arnobaer/4cb75fc4ed7b6c51aec714fe8a0ad3b6 to your computer and use it in GitHub Desktop.
Save arnobaer/4cb75fc4ed7b6c51aec714fe8a0ad3b6 to your computer and use it in GitHub Desktop.
#
# Build script for self containing binary wheels for UTM
#
# Install Docker
#
# sudo apt install docker
# sudo usermod -a -G docker $USER # logout required
#
# Pull manylinux image
#
# docker pull quay.io/pypa/manylinux1_x86_64
#
# Run manylinux image
#
# docker run -i -t -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /bin/bash
# $ cd /io
# $ bash start_build.sh
#
UTM_VERSION="0.7.3"
PYTHON_VERSIONS="3.5.7 3.6.8 3.7.4"
PERL_VERSION="5.30.0"
SSL_VERSION="1.1.1c"
XERCES_VERSION="3.2.2"
SWIG_VERSION="4.0.1"
BOOST_VERSION="1.71.0"
BUILD_DIR=build
set -e
function _info {
echo -e "\033[33;1m:: $@\033[0m"
}
function bootstrap {
fname=$(basename -- "$1")
if [ ! -f "$fname" ]
then
curl -L $1 --output $fname
fi
}
mkdir -p $BUILD_DIR
cd $BUILD_DIR
_info "installing dependencies..."
yum install -y zlib-devel pcre-devel libffi-devel
if [ ! -f /tmp/PERL.LOCK ]
then
# Perl
bootstrap https://www.cpan.org/src/5.0/perl-$PERL_VERSION.tar.gz
if [ ! -d perl-$PERL_VERSION ]
then
tar xzf perl-$PERL_VERSION.tar.gz
fi
cd perl-$PERL_VERSION
if [ ! -f BUILD.LOCK ]
then
./Configure -des
make
touch BUILD.LOCK
fi
make install
cd ..
touch /tmp/PERL.LOCK
fi
if [ ! -f /tmp/OPENSSL.LOCK ]
then
# openssl
bootstrap https://www.openssl.org/source/openssl-$SSL_VERSION.tar.gz
if [ ! -d openssl-$SSL_VERSION ]
then
tar xzf openssl-$SSL_VERSION.tar.gz
fi
cd openssl-$SSL_VERSION
if [ ! -f BUILD.LOCK ]
then
./config
make
touch BUILD.LOCK
fi
make install
cd ..
touch /tmp/OPENSSL.LOCK
fi
# create openssl links for python3
cd /usr/local/ssl
if [ ! -e include ]
then
ln -s /usr/local/include include
fi
if [ ! -e lib ]
then
ln -s /usr/local/lib64 lib
fi
cd -
if [ ! -f /tmp/BOOST.LOCK ]
then
# build boost
BOOST_VERSION_STR=${BOOST_VERSION//./_}
bootstrap https://dl.bintray.com/boostorg/release/$BOOST_VERSION/source/boost_$BOOST_VERSION_STR.tar.gz
if [ ! -d boost_$BOOST_VERSION_STR ]
then
tar xzf boost_$BOOST_VERSION_STR.tar.gz
fi
cd boost_$BOOST_VERSION_STR
if [ ! -f BUILD.LOCK ]
then
./bootstrap.sh --without-libraries=python
./b2 --with-filesystem --with-system
touch BUILD.LOCK
fi
./b2 install
cd ..
touch /tmp/BOOST.LOCK
fi
if [ ! -f /tmp/XERCES.LOCK ]
then
# build xerces
XERCES_VERSION_STR=${XERCES_VERSION//./_}
bootstrap https://github.com/apache/xerces-c/archive/Xerces-C_$XERCES_VERSION_STR.tar.gz
if [ ! -d xerces-c-Xerces-C_$XERCES_VERSION_STR ]
then
tar xzf Xerces-C_$XERCES_VERSION_STR.tar.gz
fi
cd xerces-c-Xerces-C_$XERCES_VERSION_STR
if [ ! -f BUILD.LOCK ]
then
./reconf
./configure
make
touch BUILD.LOCK
fi
make install
cd ..
touch /tmp/XERCES.LOCK
fi
if [ ! -f /tmp/SWIG.LOCK ]
then
# swig
bootstrap https://github.com/swig/swig/archive/rel-$SWIG_VERSION.tar.gz
if [ ! -d swig-rel-$SWIG_VERSION ]
then
tar xzf rel-$SWIG_VERSION.tar.gz
fi
cd swig-rel-$SWIG_VERSION
if [ ! -f BUILD.LOCK ]
then
./autogen.sh
./configure
make
touch BUILD.LOCK
fi
make install
cd ..
touch /tmp/SWIG.LOCK
fi
# Python
for version in $PYTHON_VERSIONS
do
if [ ! -e /usr/local/bin/python${version%.*} ]
then
bootstrap https://www.python.org/ftp/python/$version/Python-$version.tgz
if [ ! -d Python-$version ]
then
tar xzf Python-$version.tgz
fi
cd Python-$version
if [ ! -f BUILD.LOCK ]
then
./configure
make
touch BUILD.LOCK
fi
make altinstall
cd ..
fi
done
export BOOST_BASE=/io/boost_$BOOST_VERSION_STR
export XERCES_C_BASE=/io/xerces-c-Xerces-C_$XERCES_VERSION
export XERCES_LIB_DIR=$XERCES_C_BASE/lib
if [ ! -f /tmp/UTM.LOCK ]
then
# utm
rm -rf utm
git clone https://gitlab.cern.ch/cms-l1t-utm/utm.git
cd utm
git checkout utm_$UTM_VERSION
make all
cd ..
touch /tmp/UTM.LOCK
fi
cd utm
. setup.sh # source utm libraries
cd ..
for version in $PYTHON_VERSIONS
do
version="${version%.*}"
_info "building wheels for python $version"
rm -rf bindings_$version
mkdir bindings_$version
cd bindings_$version
python$version -m venv env_$version
. env_$version/bin/activate
pip install --upgrade pip
pip install auditwheel
for module in tm-table tm-grammar tm-eventsetup
do
_info "cloning $module"
git clone https://github.com/cms-l1-globaltrigger/$module.git
cd $module
_info "building $module"
python setup.py bdist_wheel
auditwheel repair dist/*linux_x86_64.whl
cd ..
done
deactivate
cd ..
done
_info "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment