forked from rootpy/rootpy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall_python_and_root.sh
More file actions
executable file
·141 lines (101 loc) · 3.46 KB
/
Copy pathinstall_python_and_root.sh
File metadata and controls
executable file
·141 lines (101 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#! /usr/bin/env bash
# This script assumes that the following repositories are checked out:
# https://github.com/akheron/cpython
# https://github.com/bbannier/ROOT
# https://github.com/pwaller/thisprefix
# It also assumes that it's running as sudo, although it will run everything
# except "make install" as the user you're sudoing from
set -e -u
# Place to install everything
DEST=/soft
# If we're inside sudo, run this as the normal user so as not to mess up
# permissions
function run-as-user() {
if [[ -n "${SUDO_USER-}" ]]; then
sudo -u "${SUDO_USER}" "$@"
return
fi
"$@"
}
function build-python() {
VERSION=${1}
local INSTDIR=${DEST}/python/${VERSION}-dbg/
if [[ -d "${INSTDIR}" ]]; then
echo "Python ${VERSION} already available at ${INSTDIR}"
echo " (delete if if you want to rebuild)"
return
fi
(cd cpython && git checkout ${VERSION})
BDIR="cpython/build-${VERSION}-dbg"
run-as-user mkdir -p $BDIR
pushd $BDIR &> /dev/null
run-as-user ../configure --enable-shared --with-pydebug --without-pymalloc --prefix=${INSTDIR}
run-as-user make -j3
make -j3 install
if [[ -e "${DEST}/this.sh" ]]; then
ln -s "${DEST}/this.sh" "${INSTDIR}/"
fi
sudo bash -c "source ${INSTDIR}/this.sh && python /soft/python/distribute-0.6.32/setup.py install && easy_install pip && pip install ipython nose virtualenv"
popd &> /dev/null
}
function build-root() {
local ROOT_VER="${1}"
local ROOT_VER_NAME="${2}"
local PYTHON_VER_NAME="${3}"
local VERDIR="${ROOT_VER_NAME}-dbg-py${PYTHON_VER_NAME}"
local INSTDIR=${DEST}/root/${VERDIR}
if [[ -d "${INSTDIR}" ]]; then
echo "ROOT ${ROOT_VER} already available at ${INSTDIR}"
echo " (delete if if you want to rebuild)"
return
fi
(cd ROOT && git checkout ${ROOT_VER})
BDIR="ROOT/build-${VERDIR}"
run-as-user mkdir -p $BDIR
pushd $BDIR &> /dev/null
# --enable-fink
ROOT_CONFIG="
--build=debug
--gminimal
--with-cc=clang
--with-cxx=clang++
--prefix=${INSTDIR}
--etcdir=${INSTDIR}/etc
--enable-soversion
--enable-rpath
--enable-reflex
--enable-xml
--enable-python
--with-python-libdir=/soft/python/${PYTHON_VER_NAME}-dbg/lib
--enable-minuit2
"
run-as-user ../configure ${ROOT_CONFIG}
run-as-user make -j3
sudo make -j3 install
sudo mkdir -p ${INSTDIR}
sudo tee ${INSTDIR}/this.sh &> /dev/null <<EOF
source ${DEST}/python/${PYTHON_VER_NAME}-dbg/this.sh
function setup-root-cUF9F() {
local THIS_DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
source \${THIS_DIR}/bin/thisroot.sh
echo "\${BASH_SOURCE[0]}: using prefix"
}
setup-root-cUF9F
unset setup-root-cUF9F7
EOF
popd &> /dev/null
}
# Note: this checks out a version according to ${*_VER} and installs it to ${*_VER_NAME}
function build-python-and-root() {
PYTHON_VER="${1}"
PYTHON_VER_NAME="${2}"
ROOT_VER="${3}"
ROOT_VER_NAME="${4}"
shift 2
build-python "$PYTHON_VER"
source ${DEST}/python/${PYTHON_VER}-dbg/this.sh
build-root "$ROOT_VER" "$ROOT_VER_NAME" "$PYTHON_VER_NAME"
source ${DEST}/python/${PYTHON_VER}-dbg/this.sh remove
}
# Example invocation:
# build-python-and-root v2.7.3 2.7.3 v5-28-00 5.28