-
-
Notifications
You must be signed in to change notification settings - Fork 485
/
bootstrap-conda
executable file
·125 lines (111 loc) · 4.45 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
#!/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"
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
) > environment-template.yml
(
sed 's/name: sage/name: sage-dev/' environment-template.yml
echo " # Additional dev tools"
echo " - conda-lock"
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > environment-dev-template.yml
for f in environment 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