Skip to content

Commit fb78e04

Browse files
committed
Use conda-lock for reproducible conda env
1 parent 543f8d6 commit fb78e04

25 files changed

+4874
-104
lines changed

.devcontainer/onCreate-conda.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
set -e
33

44
# Create conda environment
5-
./bootstrap-conda
65
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
6+
mamba env create --file src/environment-dev-3.11-linux.yml || mamba env update --file src/environment-dev-3.11-linux.yml
87
conda init bash
98

109
# Build sage

.github/workflows/ci-conda.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ concurrency:
2020
jobs:
2121
test:
2222
name: Conda
23-
runs-on: ${{ matrix.os }}
23+
runs-on: ${{ matrix.os }}-latest
2424

2525
# Run on push, workflow dispatch and when certain labels are added
2626
if: |
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
os: [ubuntu-latest, macos-latest]
35+
os: [ubuntu, macos]
3636
python: ['3.9', '3.10', '3.11']
3737
# Optional environment is disabled for now as its not yet working
3838
# environment: [environment, environment-optional]
@@ -53,9 +53,6 @@ jobs:
5353
bash ~/miniconda.sh -b -p $HOME/miniconda
5454
echo "CONDA=$HOME/miniconda" >> $GITHUB_ENV
5555
56-
- name: Create conda environment files
57-
run: ./bootstrap-conda
58-
5956
- name: Cache conda packages
6057
uses: actions/cache@v3
6158
with:
@@ -71,7 +68,7 @@ jobs:
7168
channels: conda-forge,defaults
7269
channel-priority: true
7370
activate-environment: sage-build
74-
environment-file: src/${{ matrix.conda-env }}.yml
71+
environment-file: src/${{ matrix.conda-env }}-${{ matrix.python }}-${{ matrix.os }}.yml
7572

7673
- name: Print Conda environment
7774
shell: bash -l {0}

.gitignore

+15-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,21 @@
2727
# no longer generated, but may still be in user worktrees
2828
/src/lib/pkgconfig
2929

30-
/environment.yml
31-
/environment-optional.yml
32-
/src/environment.yml
33-
/src/environment-dev.yml
34-
/src/environment-optional.yml
30+
/environment-3.9.yml
31+
/environment-3.10.yml
32+
/environment-3.11.yml
33+
/environment-optional-3.9.yml
34+
/environment-optional-3.10.yml
35+
/environment-optional-3.11.yml
36+
/src/environment-3.9.yml
37+
/src/environment-3.10.yml
38+
/src/environment-3.11.yml
39+
/src/environment-dev-3.9.yml
40+
/src/environment-dev-3.10.yml
41+
/src/environment-dev-3.11.yml
42+
/src/environment-optional-3.9.yml
43+
/src/environment-optional-3.10.yml
44+
/src/environment-optional-3.11.yml
3545

3646
/src/setup.cfg
3747
/src/requirements.txt

.gitpod.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ tasks:
77
- name: Setup
88
# Create conda environment, then configure and build sage
99
init: >-
10-
./bootstrap-conda
11-
&& mamba env create --file src/environment-dev.yml --prefix venv
10+
&& mamba env create --file src/environment-dev-3.11-linux.yml --prefix venv
1211
&& conda config --append envs_dirs $(pwd)
1312
&& conda activate $(pwd)/venv
1413
&& ./bootstrap

bootstrap-conda

+70-66
Original file line numberDiff line numberDiff line change
@@ -51,72 +51,76 @@ 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
77+
(
78+
sed 's/name: sage/name: sage-dev/' src/environment-$python_version.yml
79+
echo " # Additional dev tools"
80+
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
81+
echo " - $pkg"
82+
done
83+
) > src/environment-dev-$python_version.yml
6884

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
85+
(
86+
cat environment-$python_version.yml
87+
echo " # optional packages"
88+
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
89+
echo " - $pkg"
90+
done
91+
) > environment-optional-$python_version.yml
7692

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
93+
(
94+
cat src/environment-$python_version.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-$python_version.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"
119+
done
120+
fi
121+
done
122+
# Currently, there are no dev-python packages, so we do not write an empty pip section
123+
#) 4>> src/environment-dev-$python_version.yml 5>> src/environment-optional-$python_version.yml
124+
) 4>> /dev/null 5>> src/environment-optional-$python_version.yml
125+
done
92126
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"
119-
done
120-
fi
121-
done
122-
) 4>> src/environment-dev.yml 5>> src/environment-optional.yml

build/pkgs/cython/distros/conda.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cython
1+
cython<3.0.0
+1-1
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
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Set this bound until https://github.com/sagemath/sage/issues/34209 adds support for PEP660 editable builds
22
# By setting this version bound, we avoid having to include the following in our installation instructions.
33
# export SETUPTOOLS_ENABLE_FEATURES=legacy-editable
4-
"setuptools<64"
4+
setuptools<64

build/pkgs/sphinx/distros/conda.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sphinx<8,>=5.2
1+
sphinx>=5.2

0 commit comments

Comments
 (0)