-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Add needed pip packages to src/environment.yml
, minimize conda environments
#35593
base: develop
Are you sure you want to change the base?
Changes from all commits
65277dc
e18a7ab
addd6e4
346b16d
d46bfa9
0da1ac2
aafebf4
3fb54ff
22ba07b
fcb537d
38c8c2c
db482e2
8b8c45e
5af6f07
a5e4c8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ OPTIONAL_PACKAGES= | |
SAGELIB_PACKAGES= | ||
SAGELIB_OPTIONAL_PACKAGES= | ||
DEVELOP_PACKAGES= | ||
UNCONSTRAINED_PACKAGES= | ||
CONSTRAINED_PACKAGES= | ||
|
||
eval $(sage-package properties --format=shell :all:) | ||
|
||
|
@@ -25,6 +27,15 @@ for PKG_BASE in $(sage-package list --has-file distros/conda.txt --exclude _sage | |
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/distros/conda.txt | ||
PKG_SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE)) | ||
if [ -n "$PKG_SYSTEM_PACKAGES" ]; then | ||
case "$PKG_SYSTEM_PACKAGES" in | ||
*([-A-Za-z0-9_ ])) # just a package name | ||
UNCONSTRAINED_PACKAGES+=" $PKG_BASE" | ||
;; | ||
*) # a package name with version constraints or other decorations; | ||
# we never remove such packages when minimizing package lists | ||
CONSTRAINED_PACKAGES+=" $PKG_BASE" | ||
;; | ||
esac | ||
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 | ||
|
@@ -67,7 +78,34 @@ for PKG_BASE in $(sage-package list --has-file distros/conda.txt --exclude _sage | |
done | ||
unset PKG_SYSTEM_PACKAGES | ||
|
||
[ -n "$BOOTSTRAP_VERBOSE" ] && echo "## Collected:" && set | grep PACKAGES= | ||
[ -n "$BOOTSTRAP_VERBOSE" ] && printf "##\n## Collected:\n##\n" && set | grep PACKAGES= | ||
|
||
# Minimize | ||
|
||
PACKAGES=$(sage-package list $(sage-package list --include-dependencies $PACKAGES --exclude $UNCONSTRAINED_PACKAGES) \ | ||
$(sage-package list --exclude-dependencies $PACKAGES)) | ||
|
||
BOOTSTRAP_PACKAGES=$(sage-package list $(sage-package list --include-dependencies $BOOTSTRAP_PACKAGES --exclude $UNCONSTRAINED_PACKAGES) \ | ||
$(sage-package list --exclude-dependencies $BOOTSTRAP_PACKAGES) \ | ||
--exclude $(sage-package list --include-dependencies $PACKAGES)) | ||
|
||
DEVELOP_PACKAGES=$(sage-package list $(sage-package list --include-dependencies $DEVELOP_PACKAGES --exclude $UNCONSTRAINED_PACKAGES) \ | ||
$(sage-package list --exclude-dependencies $DEVELOP_PACKAGES) \ | ||
--exclude $(sage-package list --include-dependencies $PACKAGES $BOOTSTRAP_PACKAGES)) | ||
|
||
OPTIONAL_PACKAGES=$(sage-package list $(sage-package list --include-dependencies $OPTIONAL_PACKAGES --exclude $UNCONSTRAINED_PACKAGES) \ | ||
$(sage-package list --exclude-dependencies $OPTIONAL_PACKAGES) \ | ||
--exclude $(sage-package list --include-dependencies $PACKAGES $BOOTSTRAP_PACKAGES)) | ||
|
||
SAGELIB_PACKAGES=$(sage-package list $(sage-package list --include-dependencies $SAGELIB_PACKAGES --exclude $UNCONSTRAINED_PACKAGES) \ | ||
$(sage-package list --exclude-dependencies $SAGELIB_PACKAGES) \ | ||
--exclude $(sage-package list --include-dependencies $PACKAGES $BOOTSTRAP_PACKAGES)) | ||
|
||
SAGELIB_OPTIONAL_PACKAGES=$(sage-package list $(sage-package list --include-dependencies $SAGELIB_OPTIONAL_PACKAGES --exclude $UNCONSTRAINED_PACKAGES) \ | ||
$(sage-package list --exclude-dependencies $SAGELIB_OPTIONAL_PACKAGES) \ | ||
--exclude $(sage-package list --include-dependencies $PACKAGES $BOOTSTRAP_PACKAGES $SAGELIB_PACKAGES $OPTIONAL_PACKAGES)) | ||
|
||
[ -n "$BOOTSTRAP_VERBOSE" ] && printf "##\n## Minimized:\n##\n" && set | grep PACKAGES= | ||
|
||
# Translate to system packages | ||
export ENABLE_SYSTEM_SITE_PACKAGES=yes # Disable filtering in sage-get-system-packages | ||
|
@@ -79,7 +117,7 @@ SAGELIB_OPTIONAL_SYSTEM_PACKAGES=$(sage-get-system-packages conda $SAGELIB_OPTIO | |
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= | ||
[ -n "$BOOTSTRAP_VERBOSE" ] && printf "##\n## Translated to system:\n##\n" && set | grep SYSTEM_PACKAGES= | ||
|
||
echo >&2 $0:$LINENO: generate conda environment files | ||
|
||
|
@@ -133,6 +171,7 @@ echo >&2 $0:$LINENO: generate conda environment files | |
( | ||
echo >&4 " - pip:" | ||
echo >&5 " - pip:" | ||
echo >&6 " - pip:" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The standard environment file doesn't contain a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, if that's by design (whose?), then that's a severe bug in it, and this is the fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not there to check that all standard packages are installed via conda. If anything is a bug, then it's the presence of the pip section for optional and dev environments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, it is not being checked by anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bigger flaw is related to what we explained to you over in #36765 (comment): Creating conda packages is a downstream activity. If we were to take the design idea that "all standard packages need to have a conda package" seriously, it would mean that we could never add a standard package in our capacity as the upstream project. But neither is this current practice (neither with conda nor with any other downstream package repository), nor has such a change of policy been established or even discussed anywhere. And certainly this change cannot come into existence by gaslighting PR authors. |
||
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 | ||
|
@@ -144,15 +183,15 @@ echo >&2 $0:$LINENO: generate conda environment files | |
else | ||
case "$PKG_BASE:$PKG_TYPE" in | ||
$DEVELOP_SPKG_PATTERN:*) FD=4;; | ||
*:standard) FD="4 5";; | ||
*:standard) FD="4 5 6";; | ||
*) 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 | ||
) 4>> /dev/null 5>> src/environment-optional-template.yml 6>>src/environment-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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
argon2-cffi-bindings |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
boost_cropped m4ri libpng | pkgconf | ||
m4ri libpng | pkgconf boost_cropped | ||
|
||
---------- | ||
All lines of this file are ignored except the first. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cachetools | ||
mkoeppe marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
calver |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chardet |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
cliquer | ||
cliquer>=1.21 | ||
# We include the version constraint so that bootstrap-conda's environment minimizer | ||
# does not eliminate it (as a declared dependency of the giac SPKG) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
colorama |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
contourpy |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
$(MP_LIBRARY) flint boost_cropped | ||
$(MP_LIBRARY) flint | boost_cropped | ||
|
||
---------- | ||
All lines of this file are ignored except the first. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ecl | ||
ecl>=21.2.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
bdw-gc | ||
bdw-gc>=7.6.4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hatch-fancy-pypi-readme |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hatch-nodejs-version |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hatch-vcs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# The presence of this file ensures that we do not try to pip-install JuPyMake (there is no polymake conda package). | ||
mkoeppe marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
jupyterlab_widgets |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
libatomic_ops | ||
libatomic_ops>=7.6.2 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
meson |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
meson-python |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
$(MP_LIBRARY) boost_cropped onetbb $(BLAS) gfortran | cmake | ||
$(MP_LIBRARY) onetbb $(BLAS) gfortran | cmake boost_cropped |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# The presence of this file ensures that we do not try to pip-install pycygwin -- which would fail with a compilation error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pyproject-api |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pyproject-metadata |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
$(MP_LIBRARY) mpfr boost_cropped zlib papilo | cmake | ||
$(MP_LIBRARY) mpfr zlib papilo | cmake boost_cropped |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
trove-classifiers |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ def run(self): | |
'See https://doc.sagemath.org/html/en/installation/conda.html on how to get started.') | ||
|
||
cmd = f"cd {SAGE_ROOT} && ./configure --enable-build-as-root --with-system-python3=force --disable-notebook --disable-sagelib --disable-sage_conf --disable-doc" | ||
cmd += ' --with-python=$CONDA_PREFIX/bin/python --prefix="$CONDA_PREFIX"' | ||
cmd += ' $(for pkg in $(PATH="build/bin:$PATH" build/bin/sage-package list :standard: --exclude rpy2 --has-file spkg-configure.m4 --has-file distros/conda.txt); do echo --with-system-$pkg=force; done)' | ||
cmd += ' --with-python=$CONDA_PREFIX/bin/python --prefix="$CONDA_PREFIX" --enable-system-site-packages' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think it's to early for that change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just re-read the comments in the thread above from 2 months ago, I don't think there's anything that supports delaying it further. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still "experimental" right? Given that the conda workflow is not as stable right now as we want it to be, I don't think we should add any non-stable elements to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Building the Sage distribution with |
||
cmd += ' $(for pkg in $(PATH="build/bin:$PATH" build/bin/sage-package list :standard: --exclude rpy2 --has-file spkg-configure.m4 --has-file distros/conda.txt --exclude-dependencies); do echo --with-system-$pkg=force; done)' | ||
print(f"Running {cmd}") | ||
sys.stdout.flush() | ||
if os.system(cmd) != 0: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a fragile design to use "unconstrained version" as an indicator for including or excluding a certain dependency in the environment. It would prevent us from adding a version constraint to non-direct dependencies (although I have to admit I don't even understand the purpose of having conda.txt files for such dependencies) and forces us to specify a version constraint for those packages that do should end up.
Going with Python's 'explicit is better than implicit' slogan, I think it would be better to have a certain indicator file that says 'I'm a direct dependency, so include me please'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the contrary. It does the right thing -- namely including the dependency with the version constraint in the environment file -- for the non-direct dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not what it does. Packages are excluded by the minimizer from the environment file when they are implied by dependence. But we never exclude packages that have their own version constraints, so that the version constraint is not lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for any of the version constraints you added in this PR (intrinsic need, as in "if you install an older version that it's known to fail"). Thus you use version constraints as a a signal to include the given package in the environment file. I think this is not a good use of version constraints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is an "intrinsic need" for these version constraints; they are the same version bounds that
configure
checks, each with good reasons.It's just that "extrinsically" we have so far gotten away with not setting them -- simply because there is nothing that would force an older unsuitable version. But when users mix our environment with other conda packages, we can run into trouble. (And no, it's not better to wait for the bug report.)
Yes, I reuse this mechanism here for another purpose -- so that not another mechanism needs to be invented.