This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
spkg-install
executable file
·161 lines (134 loc) · 4.54 KB
/
spkg-install
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env bash
###########################################
## Python
###########################################
CUR=`pwd`
if [ -z "$SAGE_LOCAL" ]; then
echo >&2 "SAGE_LOCAL undefined ... exiting"
echo >&2 "Maybe run 'sage -sh'?"
exit 1
fi
# It is best to unset these environment variables, as they might confuse
# the Python installer.
unset PYTHONHOME
unset PYTHONPATH
# Prevent use of the system hg and svn as it might make the installation fail
export HAS_HG=no
export SVNVERSION=no
cd src
if [ "$SAGE_DEBUG" = "yes" ]; then
echo "Building Python with pydebug"
PYTHON_CONFIGURE="$PYTHON_CONFIGURE --with-pydebug"
fi
# pymalloc screws with valgrind, so let's disable it
if [ "$SAGE_VALGRIND" = "yes" ]; then
echo "Building Python without pymalloc"
PYTHON_CONFIGURE="$PYTHON_CONFIGURE --without-pymalloc"
fi
if [ "$UNAME" = Darwin ]; then
PYTHON_CONFIGURE="--disable-toolbox-glue $PYTHON_CONFIGURE"
if [ $MACOSX_VERSION -ge 16 ]; then
echo "OS X 10.$[$MACOSX_VERSION-4] Building with clang."
CC=clang
fi
elif [ "$UNAME" = SunOS ]; then
# Enable some C99 features on Solaris. This in particular enables
# the isinf() and isfinite() functions. It works both for C and
# C++ code (which is not true for -std=c99). See
# http://trac.sagemath.org/sage_trac/ticket/14265
export CFLAGS="-D__C99FEATURES__ $CFLAGS"
fi
if [ "$SAGE64" = yes ]; then
echo "64 bit build of Python enabled"
export CC="$CC -m64"
fi
build()
{
./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \
--enable-unicode=ucs4 --enable-shared $PYTHON_CONFIGURE
if [ $? -ne 0 ]; then
echo >&2 "Error configuring Python."
exit 1
fi
$MAKE
if [ $? -ne 0 ]; then
echo >&2 "Error building Python."
exit 1
fi
# On OS X, test to see if _scproxy built before installing.
if [ "$UNAME" = "Darwin" ]; then
if [ -z `find build -name _scproxy*.so` ]; then
echo >&2 "Error: the _scproxy module failed to build."
exit 1
fi
fi
# Remove old libraries
rm -f "$SAGE_LOCAL"/lib/libpython3*
# Running 'make install' in parallel is a bad idea, so we use
# only 1 job.
# The "-i" option to ignore errors is crucial, especially in the
# case of upgrades.
$MAKE -i -j1 install
if [ $? -ne 0 ]; then
echo >&2 "Error installing Python."
exit 1
fi
echo "Installing valgrind suppression file..."
mkdir -p "$SAGE_EXTCODE/valgrind"
cp Misc/valgrind-python.supp "$SAGE_EXTCODE/valgrind/python.supp"
if [ $? -ne 0 ]; then
echo >&2 "Error installing valgrind suppression file."
exit 1
fi
}
# Remove old symbolic link: it is not needed and its presence can
# interfere with the Python build.
rm -f "$SAGE_LOCAL/lib/python"
build
# Make symbolic link (after removing old link first)
if [ "$SAGE_PYTHON3" = yes ]; then
rm -f "$SAGE_LOCAL/bin/python"
ln -s python3 "$SAGE_LOCAL/bin/python"
if [ $? -ne 0 ]; then
echo >&2 "Error creating symbolic link"
exit 1
fi
fi
PYTHON_VERSION=$("$SAGE_LOCAL/bin/python3" -c 'import sys; print("%d.%d" % sys.version_info[:2])')
# On OS X with XCode 4, the presence of
# $SAGE_LOCAL/lib/python/config/libpython3.x.a causes problems with
# GiNaC -- see #11967. It is easiest to test the version of OS X; we
# delete this file if using OS X 10.6 or later (so `uname -r` returns
# x.y.z with x >= 10).
if [ "$UNAME" = "Darwin" ] && \
[ `uname -r | cut '-d.' -f1` -gt 9 ]; then
rm -f "$SAGE_LOCAL/lib/python$PYTHON_VERSION/config/libpython${PYTHON_VERSION}.a"
elif [ "$UNAME" = "CYGWIN" ]; then
# See http://trac.sagemath.org/ticket/20437
ln -sf "python/config/libpython${PYTHON_VERSION}.dll.a" "$SAGE_LOCAL/lib/libpython${PYTHON_VERSION}.dll.a"
fi
# Make sure extension modules were built correctly.
# All these modules are important and if any one
# fails to build, Sage will not work.
echo "Testing importing of various modules..."
import_errors=false
for module in ctypes math hashlib crypt readline socket ; do
if python3 -c "import $module"; then
echo "$module module imported OK"
else
echo >&2 "$module module failed to import"
import_errors=true
fi
done
if [ "$UNAME" = "Darwin" ]; then
if python3 -c "import _scproxy"; then
echo "_scproxy module imported OK"
else
echo >&2 "_scproxy module failed to import"
import_errors=true
fi
fi
if $import_errors; then
echo >&2 "Error: One or more modules failed to import."
exit 1
fi