forked from fermi-lat/Fermitools-conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·127 lines (94 loc) · 4.05 KB
/
build.sh
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
export condaname="fermitools"
# REPOMAN! #
# Syntax Help:
# To checkout master instead of the release tag add '--develop' after checkout
# To checkout arbitrary other refs (Tag, Branch, Commit) add them as a space
# delimited list after 'conda' in the order of priority.
# e.g. ScienceTools highest_priority_commit middle_priority_ref branch1 branch2 ... lowest_priority
repoman --remote-base https://github.com/fermi-lat checkout --force --develop ScienceTools conda throw_update mpl_plotting
# repoman --remote-base https://github.com/fermi-lat checkout --force --develop ScienceTools conda STGEN-182
# condaforge fftw is in a different spot
mkdir -p ${PREFIX}/include/fftw
if [ ! -e ${PREFIX}/include/fftw/fftw3.h ] ; then
ln -s ${PREFIX}/include/fftw3.* ${PREFIX}/include/fftw
fi
#CXXFLAGS=${CXXFLAGS//c++17/c++11}
# Add optimization
export CFLAGS="-O2 ${CFLAGS}"
export CXXFLAGS="-O2 ${CXXFLAGS}"
# Add rpaths needed for our compilation
export LDFLAGS="${LDFLAGS} -Wl,-rpath,${PREFIX}/lib,-rpath,${PREFIX}/lib/root,-rpath,${PREFIX}/lib/${condaname}"
if [ "$(uname)" == "Darwin" ]; then
#std=c++11 required for use with the Mac version of CLHEP in conda-forge
export CXXFLAGS="-std=c++11 ${CXXFLAGS}"
export LDFLAGS="${LDFLAGS} -headerpad_max_install_names"
echo "Compiling without openMP, not supported on Mac"
else
# This is needed on Linux
export CXXFLAGS="-std=c++11 ${CXXFLAGS}"
export LDFLAGS="${LDFLAGS} -fopenmp"
fi
ln -s ${cc} ${PREFIX}/bin/gcc
ln -s ${CXX} ${PREFIX}/bin/g++
scons -C ScienceTools \
--site-dir=../SConsShared/site_scons \
--conda=${PREFIX} \
--use-path \
-j ${CPU_COUNT} \
--with-cc="${CC}" \
--with-cxx="${CXX}" \
--ccflags="${CFLAGS}" \
--cxxflags="${CXXFLAGS}" \
--ldflags="${LDFLAGS}" \
all
rm -rf ${PREFIX}/bin/gcc
rm -rf ${PREFIX}/bin/g++
# Remove the links to fftw3
rm -rf ${PREFIX}/include/fftw
# Install in a place where conda will find the ST
# Libraries
mkdir -p $PREFIX/lib/${condaname}
cp -R lib/*/* $PREFIX/lib/${condaname}
# Headers
mkdir -p $PREFIX/include/${condaname}
cp -R include/* $PREFIX/include/${condaname}
# Binaries
mkdir -p $PREFIX/bin/${condaname}
cp -R exe/*/* $PREFIX/bin/${condaname}
# Python packages
# Figure out the path to the site-package directory
export sitepackagesdir=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
# Create our package there
mkdir -p $sitepackagesdir/${condaname}
# Making an empty __init__.py makes our directory a python package
echo "" > $sitepackagesdir/${condaname}/__init__.py
# Copy all our stuff there
cp -R python/* $sitepackagesdir/${condaname}
# There are python libraries that are actually under /lib, so let's
# add a .pth file so that it is not necessary to setup PYTHONPATH
# (which is discouraged by conda)
echo "$PREFIX/lib/${condaname}" > $sitepackagesdir/${condaname}.pth
# In order to support things like "import UnbinnedAnalysis" instead of
# "from fermitools import UnbinnedAnalysis" we need to
# also add the path to the fermitools package
echo "${sitepackagesdir}/fermitools" >> $sitepackagesdir/${condaname}.pth
# Pfiles
mkdir -p $PREFIX/share/${condaname}/syspfiles
cp -R syspfiles/* $PREFIX/share/${condaname}/syspfiles
# Xml
mkdir -p $PREFIX/share/${condaname}/xml
cp -R xml/* $PREFIX/share/${condaname}/xml
# Data
mkdir -p $PREFIX/share/${condaname}/data
cp -R data/* $PREFIX/share/${condaname}/data
# fhelp
mkdir -p $PREFIX/share/${condaname}/help
cp -R fermitools-fhelp/* $PREFIX/share/${condaname}/help
rm -f $PREFIX/share/${condaname}/help/README.md #Remove the git repo README
# Copy also the activate and deactivate scripts
mkdir -p $PREFIX/etc/conda/activate.d
mkdir -p $PREFIX/etc/conda/deactivate.d
cp $RECIPE_DIR/activate.sh $PREFIX/etc/conda/activate.d/activate_${condaname}.sh
cp $RECIPE_DIR/deactivate.sh $PREFIX/etc/conda/deactivate.d/deactivate_${condaname}.sh
cp $RECIPE_DIR/activate.csh $PREFIX/etc/conda/activate.d/activate_${condaname}.csh
cp $RECIPE_DIR/deactivate.csh $PREFIX/etc/conda/deactivate.d/deactivate_${condaname}.csh