forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap-conda
executable file
·165 lines (148 loc) · 6.3 KB
/
bootstrap-conda
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
161
162
163
164
165
#!/usr/bin/env bash
########################################################################
# Generate auto-generated conda environment files
#########################################################################
export PATH="$(pwd)/build/bin:$PATH"
STRIP_COMMENTS="sed s/#.*//;"
shopt -s extglob
DEVELOP_SPKG_PATTERN="@(_develop$(for a in $(head -n 1 build/pkgs/_develop/dependencies); do echo -n "|"$a; done))"
BOOTSTRAP_PACKAGES=_bootstrap
PACKAGES=
OPTIONAL_PACKAGES=
SAGELIB_PACKAGES=
SAGELIB_OPTIONAL_PACKAGES=
DEVELOP_PACKAGES=
eval $(sage-package properties --format=shell :all:)
for PKG_BASE in $(sage-package list --has-file distros/conda.txt --exclude _sagemath); do
eval PKG_SCRIPTS=\$path_$PKG_BASE PKG_TYPE=\$type_$PKG_BASE
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/distros/conda.txt
PKG_SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE))
if [ -n "$PKG_SYSTEM_PACKAGES" ]; then
if [ -f $PKG_SCRIPTS/spkg-configure.m4 ]; then
if grep -q SAGE_PYTHON_PACKAGE_CHECK $PKG_SCRIPTS/spkg-configure.m4; then
# Python package that would need --enable-system-site-packages to be used
# with the Sage distribution, but we do not recommend that for conda.
PKG_SAGELIB_ONLY=yes
else
PKG_SAGELIB_ONLY=no
fi
else
# No spkg-configure, so the Sage distribution is not able to make use of this package.
PKG_SAGELIB_ONLY=yes
fi
[ -n "$BOOTSTRAP_VERBOSE" ] && echo "$PKG_BASE:$PKG_TYPE:$PKG_SAGELIB_ONLY"
if [ $PKG_SAGELIB_ONLY = no ]; then
case "$PKG_BASE:$PKG_TYPE" in
*:standard)
PACKAGES+=" $PKG_BASE"
;;
$DEVELOP_SPKG_PATTERN:*)
DEVELOP_PACKAGES+=" $PKG_BASE"
;;
*)
OPTIONAL_PACKAGES+=" $PKG_BASE"
;;
esac
else
case "$PKG_BASE:$PKG_TYPE" in
*:standard)
SAGELIB_PACKAGES+=" $PKG_BASE"
;;
$DEVELOP_SPKG_PATTERN:*)
DEVELOP_PACKAGES+=" $PKG_BASE"
;;
*)
SAGELIB_OPTIONAL_PACKAGES+=" $PKG_BASE"
;;
esac
fi
fi
done
unset PKG_SYSTEM_PACKAGES
[ -n "$BOOTSTRAP_VERBOSE" ] && echo "## Collected:" && set | grep PACKAGES=
# Translate to system packages
export ENABLE_SYSTEM_SITE_PACKAGES=yes # Disable filtering in sage-get-system-packages
SYSTEM_PACKAGES=$(sage-get-system-packages conda $PACKAGES)
BOOTSTRAP_SYSTEM_PACKAGES=$(sage-get-system-packages conda $BOOTSTRAP_PACKAGES)
OPTIONAL_SYSTEM_PACKAGES=$(sage-get-system-packages conda $OPTIONAL_PACKAGES)
SAGELIB_SYSTEM_PACKAGES=$(sage-get-system-packages conda $SAGELIB_PACKAGES)
SAGELIB_OPTIONAL_SYSTEM_PACKAGES=$(sage-get-system-packages conda $SAGELIB_OPTIONAL_PACKAGES)
DEVELOP_SYSTEM_PACKAGES=$(sage-get-system-packages conda $DEVELOP_PACKAGES)
unset ENABLE_SYSTEM_SITE_PACKAGES
[ -n "$BOOTSTRAP_VERBOSE" ] && echo "## Translated to system:" && set | grep SYSTEM_PACKAGES=
echo >&2 $0:$LINENO: generate conda environment files
(
echo "name: sage-build"
echo "channels:"
echo " - conda-forge"
echo " - nodefaults"
echo "dependencies:"
for pkg in $SYSTEM_PACKAGES; do
echo " - $pkg"
done
echo " # Packages needed for ./bootstrap"
for pkg in $BOOTSTRAP_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > environment-template.yml
(
sed 's/name: sage-build/name: sage/' environment-template.yml
echo " - meson"
echo " - meson-python"
echo " - pytest"
echo " # Additional packages providing all dependencies for the Sage library"
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-template.yml
(
cat environment-template.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > environment-optional-template.yml
(
sed 's/name: sage/name: sage-dev/' src/environment-template.yml
echo " # Additional dev tools"
echo " - conda-lock"
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-dev-template.yml
(
cat src/environment-template.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES $SAGELIB_OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-optional-template.yml
(
echo >&4 " - pip:"
echo >&5 " - pip:"
for PKG_BASE in $(sage-package list :standard: :optional: --has-file requirements.txt --no-file distros/conda.txt --no-file src; sage-package list :standard: :optional: --has-file version_requirements.txt --no-file requirements.txt --no-file distros/conda.txt --no-file src); do
eval PKG_SCRIPTS=\$path_$PKG_BASE PKG_TYPE=\$type_$PKG_BASE
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/requirements.txt
if [ ! -f $SYSTEM_PACKAGES_FILE ]; then
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/version_requirements.txt
fi
if grep -q SAGERUNTIME $PKG_SCRIPTS/dependencies $PKG_SCRIPTS/dependencies_order_only 2>/dev/null; then
: # cannot install packages that depend on the Sage library
else
case "$PKG_BASE:$PKG_TYPE" in
$DEVELOP_SPKG_PATTERN:*) FD=4;;
*:standard) FD="4 5";;
*) FD=5;;
esac
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE | while read -r line; do
[ -n "$line" ] && for fd in $FD; do echo >&$fd " - $line"; done
done
fi
done
) 4>> /dev/null 5>> src/environment-optional-template.yml
for f in environment environment-optional src/environment src/environment-optional src/environment-dev; do
for python_version in 3.9 3.10 3.11; do
sed -E 's/^( *- *)python *$/\1python='$python_version'/' $f-template.yml > $f-$python_version.yml
done
rm -f $f-template.yml
done