Skip to content

Commit 6127016

Browse files
author
Matthias Koeppe
committed
bootstrap-conda: Generate environment files with hard-coded Python minor versions (environment-3.9.yml etc.)
This is convenient for conda-lock. Partial cherry-pick from "Use conda-lock for reproducible conda env"
1 parent 2f1a76d commit 6127016

File tree

5 files changed

+89
-69
lines changed

5 files changed

+89
-69
lines changed

.devcontainer/onCreate-conda.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
# Create conda environment
55
./bootstrap-conda
66
conda install mamba -n base -c conda-forge -y
7-
mamba env create --file src/environment-dev.yml || mamba env update --file src/environment-dev.yml
7+
mamba env create --file src/environment-dev-3.11.yml || mamba env update --file src/environment-dev-3.11.yml
88
conda init bash
99

1010
# Build sage

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,29 @@
2727
# no longer generated, but may still be in user worktrees
2828
/src/lib/pkgconfig
2929

30+
# Environment files generated by bootstrap-conda.
31+
# The files without Python version are no longer generated
32+
# but may still be in users' directories.
3033
/environment.yml
34+
/environment-3.9.yml
35+
/environment-3.10.yml
36+
/environment-3.11.yml
3137
/environment-optional.yml
38+
/environment-optional-3.9.yml
39+
/environment-optional-3.10.yml
40+
/environment-optional-3.11.yml
3241
/src/environment.yml
42+
/src/environment-3.9.yml
43+
/src/environment-3.10.yml
44+
/src/environment-3.11.yml
3345
/src/environment-dev.yml
46+
/src/environment-dev-3.9.yml
47+
/src/environment-dev-3.10.yml
48+
/src/environment-dev-3.11.yml
3449
/src/environment-optional.yml
50+
/src/environment-optional-3.9.yml
51+
/src/environment-optional-3.10.yml
52+
/src/environment-optional-3.11.yml
3553

3654
/src/setup.cfg
3755
/src/requirements.txt

.gitpod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tasks:
88
# Create conda environment, then configure and build sage
99
init: >-
1010
./bootstrap-conda
11-
&& mamba env create --file src/environment-dev.yml --prefix venv
11+
&& mamba env create --file src/environment-dev-3.11.yml --prefix venv
1212
&& conda config --append envs_dirs $(pwd)
1313
&& conda activate $(pwd)/venv
1414
&& ./bootstrap

bootstrap-conda

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -51,72 +51,74 @@ for PKG_BASE in $(sage-package list --has-file distros/conda.txt --exclude _sage
5151
fi
5252
done
5353
echo >&2 $0:$LINENO: generate conda environment files
54-
(
55-
echo "name: sage-build"
56-
echo "channels:"
57-
echo " - conda-forge"
58-
echo " - nodefaults"
59-
echo "dependencies:"
60-
for pkg in $SYSTEM_PACKAGES; do
61-
echo " - $pkg"
62-
done
63-
echo " # Packages needed for ./bootstrap"
64-
for pkg in $BOOTSTRAP_PACKAGES; do
65-
echo " - $pkg"
66-
done
67-
) > environment.yml
54+
for python_version in 3.9 3.10 3.11; do
55+
(
56+
echo "name: sage-build"
57+
echo "channels:"
58+
echo " - conda-forge"
59+
echo " - nodefaults"
60+
echo "dependencies:"
61+
echo " - python=$python_version"
62+
for pkg in $SYSTEM_PACKAGES; do
63+
echo " - $pkg"
64+
done
65+
echo " # Packages needed for ./bootstrap"
66+
for pkg in $BOOTSTRAP_PACKAGES; do
67+
echo " - $pkg"
68+
done
69+
) > environment-$python_version.yml
70+
(
71+
sed 's/name: sage-build/name: sage/' environment-$python_version.yml
72+
echo " # Additional packages providing all dependencies for the Sage library"
73+
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
74+
echo " - $pkg"
75+
done
76+
) > src/environment-$python_version.yml
6877

69-
(
70-
sed 's/name: sage-build/name: sage/' environment.yml
71-
echo " # Additional packages providing all dependencies for the Sage library"
72-
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
73-
echo " - $pkg"
74-
done
75-
) > src/environment.yml
78+
(
79+
cat environment-$python_version.yml
80+
echo " # optional packages"
81+
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
82+
echo " - $pkg"
83+
done
84+
) > environment-optional-$python_version.yml
7685

77-
(
78-
sed 's/name: sage/name: sage-dev/' src/environment.yml
79-
echo " # Additional dev tools"
80-
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
81-
echo " - $pkg"
82-
done
83-
) > src/environment-dev.yml
84-
85-
(
86-
cat environment.yml
87-
echo " # optional packages"
88-
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
89-
echo " - $pkg"
90-
done
91-
) > environment-optional.yml
92-
93-
(
94-
cat src/environment.yml
95-
echo " # optional packages"
96-
for pkg in $OPTIONAL_SYSTEM_PACKAGES $SAGELIB_OPTIONAL_SYSTEM_PACKAGES; do
97-
echo " - $pkg"
98-
done
99-
) > src/environment-optional.yml
100-
(
101-
echo >&4 " - pip:"
102-
echo >&5 " - pip:"
103-
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 install-requires.txt --no-file requirements.txt --no-file distros/conda.txt --no-file src) | sort); do
104-
PKG_SCRIPTS=build/pkgs/$PKG_BASE
105-
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/requirements.txt
106-
if [ ! -f $SYSTEM_PACKAGES_FILE ]; then
107-
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/install-requires.txt
108-
fi
109-
PKG_TYPE=$(cat $PKG_SCRIPTS/type)
110-
if grep -q SAGERUNTIME $PKG_SCRIPTS/dependencies $PKG_SCRIPTS/dependencies_order_only 2>/dev/null; then
111-
: # cannot install packages that depend on the Sage library
112-
else
113-
case "$PKG_BASE:$PKG_TYPE" in
114-
$DEVELOP_SPKG_PATTERN:*) FD=4;;
115-
*) FD=5;;
116-
esac
117-
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE | while read -r line; do
118-
[ -n "$line" ] && echo >&$FD " - $line"
86+
(
87+
(
88+
sed 's/name: sage/name: sage-dev/' src/environment-$python_version.yml
89+
echo " # Additional dev tools"
90+
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
91+
echo " - $pkg"
11992
done
120-
fi
121-
done
122-
) 4>> src/environment-dev.yml 5>> src/environment-optional.yml
93+
) >&4
94+
(
95+
cat src/environment-$python_version.yml
96+
echo " # optional packages"
97+
for pkg in $OPTIONAL_SYSTEM_PACKAGES $SAGELIB_OPTIONAL_SYSTEM_PACKAGES; do
98+
echo " - $pkg"
99+
done
100+
) >&5
101+
echo >&4 " - pip:"
102+
echo >&5 " - pip:"
103+
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 install-requires.txt --no-file requirements.txt --no-file distros/conda.txt --no-file src) | sort); do
104+
PKG_SCRIPTS=build/pkgs/$PKG_BASE
105+
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/requirements.txt
106+
if [ ! -f $SYSTEM_PACKAGES_FILE ]; then
107+
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/install-requires.txt
108+
fi
109+
PKG_TYPE=$(cat $PKG_SCRIPTS/type)
110+
if grep -q SAGERUNTIME $PKG_SCRIPTS/dependencies $PKG_SCRIPTS/dependencies_order_only 2>/dev/null; then
111+
: # cannot install packages that depend on the Sage library
112+
else
113+
case "$PKG_BASE:$PKG_TYPE" in
114+
$DEVELOP_SPKG_PATTERN:*) FD=4;;
115+
*:standard) FD="4 5";;
116+
*) FD=5;;
117+
esac
118+
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE | while read -r line; do
119+
[ -n "$line" ] && for fd in $FD; do echo >&$fd " - $line"; done
120+
done
121+
fi
122+
done
123+
) 4>> src/environment-dev-$python_version.yml 5>> src/environment-optional-$python_version.yml
124+
done
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Trac #33642: For unknown reasons, without the version constraint, conda installs only 3.3.2
2-
"matplotlib>=3.5.1"
2+
matplotlib>=3.5.1

0 commit comments

Comments
 (0)