Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap-conda: Refactor, generate versioned environment files #36405

Merged
merged 10 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bootstrap-conda: Generate environment files with hard-coded Python mi…
…nor versions (environment-3.9.yml etc.)

This is convenient for conda-lock.

Partial cherry-pick from "Use conda-lock for reproducible conda env"
  • Loading branch information
Matthias Koeppe committed Oct 8, 2023
commit 6127016ec90f4c2f66a99b6e6966cc05df9eeb6c
2 changes: 1 addition & 1 deletion .devcontainer/onCreate-conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
# Create conda environment
./bootstrap-conda
conda install mamba -n base -c conda-forge -y
mamba env create --file src/environment-dev.yml || mamba env update --file src/environment-dev.yml
mamba env create --file src/environment-dev-3.11.yml || mamba env update --file src/environment-dev-3.11.yml
conda init bash

# Build sage
Expand Down
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,29 @@
# no longer generated, but may still be in user worktrees
/src/lib/pkgconfig

# Environment files generated by bootstrap-conda.
# The files without Python version are no longer generated
# but may still be in users' directories.
/environment.yml
/environment-3.9.yml
/environment-3.10.yml
/environment-3.11.yml
/environment-optional.yml
/environment-optional-3.9.yml
/environment-optional-3.10.yml
/environment-optional-3.11.yml
/src/environment.yml
/src/environment-3.9.yml
/src/environment-3.10.yml
/src/environment-3.11.yml
/src/environment-dev.yml
/src/environment-dev-3.9.yml
/src/environment-dev-3.10.yml
/src/environment-dev-3.11.yml
/src/environment-optional.yml
/src/environment-optional-3.9.yml
/src/environment-optional-3.10.yml
/src/environment-optional-3.11.yml

/src/setup.cfg
/src/requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tasks:
# Create conda environment, then configure and build sage
init: >-
./bootstrap-conda
&& mamba env create --file src/environment-dev.yml --prefix venv
&& mamba env create --file src/environment-dev-3.11.yml --prefix venv
&& conda config --append envs_dirs $(pwd)
&& conda activate $(pwd)/venv
&& ./bootstrap
Expand Down
134 changes: 68 additions & 66 deletions bootstrap-conda
Original file line number Diff line number Diff line change
Expand Up @@ -51,72 +51,74 @@ for PKG_BASE in $(sage-package list --has-file distros/conda.txt --exclude _sage
fi
done
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_PACKAGES; do
echo " - $pkg"
done
) > environment.yml
for python_version in 3.9 3.10 3.11; do
(
echo "name: sage-build"
echo "channels:"
echo " - conda-forge"
echo " - nodefaults"
echo "dependencies:"
echo " - python=$python_version"
for pkg in $SYSTEM_PACKAGES; do
echo " - $pkg"
done
echo " # Packages needed for ./bootstrap"
for pkg in $BOOTSTRAP_PACKAGES; do
echo " - $pkg"
done
) > environment-$python_version.yml
(
sed 's/name: sage-build/name: sage/' environment-$python_version.yml
echo " # Additional packages providing all dependencies for the Sage library"
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-$python_version.yml

(
sed 's/name: sage-build/name: sage/' environment.yml
echo " # Additional packages providing all dependencies for the Sage library"
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment.yml
(
cat environment-$python_version.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > environment-optional-$python_version.yml

(
sed 's/name: sage/name: sage-dev/' src/environment.yml
echo " # Additional dev tools"
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-dev.yml

(
cat environment.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > environment-optional.yml

(
cat src/environment.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES $SAGELIB_OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-optional.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 install-requires.txt --no-file requirements.txt --no-file distros/conda.txt --no-file src) | sort); do
PKG_SCRIPTS=build/pkgs/$PKG_BASE
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/requirements.txt
if [ ! -f $SYSTEM_PACKAGES_FILE ]; then
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/install-requires.txt
fi
PKG_TYPE=$(cat $PKG_SCRIPTS/type)
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;;
*) FD=5;;
esac
${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE | while read -r line; do
[ -n "$line" ] && echo >&$FD " - $line"
(
(
sed 's/name: sage/name: sage-dev/' src/environment-$python_version.yml
echo " # Additional dev tools"
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
echo " - $pkg"
done
fi
done
) 4>> src/environment-dev.yml 5>> src/environment-optional.yml
) >&4
(
cat src/environment-$python_version.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES $SAGELIB_OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) >&5
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 install-requires.txt --no-file requirements.txt --no-file distros/conda.txt --no-file src) | sort); do
PKG_SCRIPTS=build/pkgs/$PKG_BASE
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/requirements.txt
if [ ! -f $SYSTEM_PACKAGES_FILE ]; then
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/install-requires.txt
fi
PKG_TYPE=$(cat $PKG_SCRIPTS/type)
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>> src/environment-dev-$python_version.yml 5>> src/environment-optional-$python_version.yml
done
2 changes: 1 addition & 1 deletion build/pkgs/matplotlib/distros/conda.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Trac #33642: For unknown reasons, without the version constraint, conda installs only 3.3.2
"matplotlib>=3.5.1"
matplotlib>=3.5.1