Add needed pip packages to src/environment.yml, minimize conda environments#35593
Add needed pip packages to src/environment.yml, minimize conda environments#35593mkoeppe wants to merge 15 commits intosagemath:developfrom
src/environment.yml, minimize conda environments#35593Conversation
|
Our upper bound on |
|
Still lots of conflicts, involving narrowly restricted version of |
|
@tobiasdiez do you think we can have the "s: run conda ci" label also run the workflow on PR syncs? |
This is now part of #35380 |
|
Solves and package installs take pretty long - on the CI runners about 30 mins; see https://github.com/sagemath/sage/actions/runs/6331256567?pr=35593 |
tobiasdiez
left a comment
There was a problem hiding this comment.
I propose you split this PR in multiple small ones with a single purpose to make reviewing easier.
src/doc/en/installation/conda.rst
Outdated
| $ ./bootstrap | ||
| $ ./configure --with-python=$CONDA_PREFIX/bin/python \ | ||
| --prefix=$CONDA_PREFIX \ | ||
| --enable-system-site-packages \ |
There was a problem hiding this comment.
Why is this needed / what is it doing in this context? Also since the word 'system' package might be misleading for conda, and the list of additional commands is getting rather big, I propose you introduce a new toggle "with-conda=$CONDA_PREFIX" to configure that takes care of all this config.
There was a problem hiding this comment.
what is it doing in this context?
It's unfortunately not documented yet (@orlitzky, am I right about this?), and is as experimental as this conda installation method.
Here I am using it so that the version constraints of those Python packages with spkg-configure are checked. Extra checks = good.
How long this command is does not really matter -- it is to be copy-pasted anyway. In any case, inventing new switches for conda is beyond the scope of this PR.
There was a problem hiding this comment.
Is it also changing how the venv is setup/used?
Here I am using it so that the version constraints of those Python packages with spkg-configure are checked. Extra checks = good.
I don't see the point in that. We have ci checks already in place and the lock files I proposed would make it even more unnecessary.
There was a problem hiding this comment.
Is it also changing how the venv is setup/used?
Note that in these instructions, no venv is created.
There was a problem hiding this comment.
An important point of running the configure script with the "force" options is to check that the installed versions are suitable for Sage. It is of course just a partial check because it is only done for those package for which we have the spkg-configure.m4. Now thanks to @orlitzky's work, we can check more, so here I'm adding it. It's a natural improvement.
There was a problem hiding this comment.
The configuration step won't go away. This has nothing to do with using or not using the Sage build system. (We aren't using it in this mode, as you know.)
There was a problem hiding this comment.
Concerning 1), I'm right in the assumption that this is not relevant here as we don't create a venv when used with conda.
I can provide a better answer to this now.
Right: it's not directly relevant to the conda installation. But it does provide a sanity check on the compatibility of the versions used by conda and sage. In the long run, that will help conda.
We are currently adding spkg-configure.m4 files for all of sage's python packages, testing the version bounds in install-requires.txt, adding compatibility patches, etc. When all that is done, and when enough people have tested it, my hope is that we can turn --enable-system-site-packages on by default. If that happens, using conda to install dependencies for sage becomes much simpler because you don't have to circumvent make and the venv.
For that to work smoothly, the conda versions all have to be acceptable to ./configure; otherwise, ./configure will either crash or want to install an SPKG. Adding --enable-system-site-packages now, while not having any direct effect, does flag those incompatibilities to us.
There was a problem hiding this comment.
using conda to install dependencies for sage becomes much simpler because you don't have to circumvent make
It's actually a feature and not a bug that the conda install doesn't use the make interface. One of the longterm goals is to replace sages package management and build infrastructure with conda. Right now this is already working very well for python packages. You could remove every python package (but keep the auto generated conda env and setup.cfg files) and everything is still working. That's why I think this flag here is a step backwards (for the conda install, I'm sure it has other good usages).
I would propose we remove this flag from the docs for now, but keep it in the ci workflow. Then you do get the consistency checks, just that not everyone has to run them.
There was a problem hiding this comment.
I don't think anyone is proposing to add the use of make to the all-conda installation method.
There was a problem hiding this comment.
That was also not my point...
I don't think so. The changes are needed to restore the workflow from broken to working. |
|
can we only run |
|
No. Its output files are part of the configure tarball. |
|
there should be an option to bootstrap to build this tarball. We run thus mostly useless bunch of stuff a lot, during routine rebuilds. |
|
I must be out of the loop. How do we avoid the virtualenv when using conda to provide only the dependencies for sage? I thought the process was, at a high level,
Where, in my head at least, that second phase still uses a venv. |
|
I presume this https://doc.sagemath.org/html/en/installation/conda.html#using-conda-to-provide-all-dependencies-for-the-sage-library-experimental can be simplified now, with |
By telling users not to run
Yes, that's the method of section 2 ("Using conda to provide system packages for the Sage distribution") of https://doc.sagemath.org/html/en/installation/conda.html |
This method is what we have been talking about here on the PR. I have added |
|
Ah, thanks. Now that I know that |
|
I'm more concerned about the long solve/install time of the environment (see current run https://github.com/sagemath/sage/actions/runs/6358819359?pr=35593). Any help there would be very welcome. |
|
I've reduced the scope of the PR; it now no longer makes changes to the installation manual. |
In #36367 I simplify the installation instructions by moving the run of |
According to conda/conda-libmamba-solver#283, the issue we faced "is a known incompatibility between the libarchive packages published on defaults and conda-forge. The root cause is a problem in the CMake build configuration upstream (libarchive/libarchive#1857)." So forcing mamba and libarchive to be from conda-forge is a according to the official "recommendation [..] to make sure that libarchive and libmamba come from the same channel."
Please not, mamba will soon be the official solver in conda (in the slightly different form of https://github.com/conda/conda-libmamba-solver). As long as this conda-mamba solver is not supported by the gh action, I prefer to stay with mamba.
Again, please not. This PR is (almost) ready to go, and it is needed to fix a) test failures that come from the setuptools upgrade (to be merged) and b) macos. The added package stuff is orthogonal to this. |
The version of 54cee7d was obviously not working well, with the solve times for macOS just for getting mamba = 30 mins. |
Well, when this is done, there will certainly not be a need to force https://github.com/marketplace/actions/setup-miniconda to use it. The current version is already ready for that. |
No worries, I'll have it ready later today. |
tobiasdiez
left a comment
There was a problem hiding this comment.
I don't think this is ready yet. The build step on conda now fails, it still installs hatch and meson ect in the environment and there is no reason to not use mamba on Linux (I'm fine with using plain conda for now on macos as a temporary workaround).
In light of these, I would like to ask you Matthias to extract some parts to other PRs. For example the package updates for setup tools ect are very good to go in my opinion, so is the splitting by python version.
|
That's now #36411 |
| @@ -1 +0,0 @@ | |||
| patchelf | |||
There was a problem hiding this comment.
patchelf is available on conda-forge, but only on Linux platforms
|
Still some rough edges: |
| ( | ||
| echo >&4 " - pip:" | ||
| echo >&5 " - pip:" | ||
| echo >&6 " - pip:" |
There was a problem hiding this comment.
The standard environment file doesn't contain a pip section by design.
There was a problem hiding this comment.
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.
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.
It's not there to check that all standard packages are installed via conda.
No, it is not being checked by anything. sagenb_export is a standard package, and so far it has just been omitted.
There was a problem hiding this comment.
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.
| if [ -n "$PKG_SYSTEM_PACKAGES" ]; then | ||
| case "$PKG_SYSTEM_PACKAGES" in | ||
| *([-A-Za-z0-9_ ])) # just a package name | ||
| UNCONSTRAINED_PACKAGES+=" $PKG_BASE" |
There was a problem hiding this comment.
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.
It would prevent us from adding a version constraint to non-direct dependencies
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.
design to use "unconstrained version" as an indicator for including or excluding a certain dependency in the environment.
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.
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.
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.
| 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.
I still think it's to early for that change.
There was a problem hiding this comment.
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.
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.
Building the Sage distribution with --enable-system-site-packages is experimental.
Running the configure script with it is safe.
|
I would also suggest a bit more restraint when relabeling as "needs work". None of your comments made identified a clear work item. |
|
Let's get this in. |
|
Documentation preview for this PR (built with commit a5e4c8f; changes) is ready! 🎉 |
… be eliminated by the bootstrap-conda environment minimizer
📚 Description
pipsection tosrc/environment.ymlfor the missing standard packagesagenb_export(this was left out inbootstrap-conda: Refactor, generate versioned environment files #36405)pipsection is also good for adding the new pip package in Update to new conway-polynomials python package #36765--enable-system-site-packages(this was left out in Simplify experimental all-conda installation instructions viapkgs/sage-conf_conda#36367 (review)) and to avoid--with-system-SPKG=forcefor packages that may be omitted by the environment minimizer.src/environment-optional.yml📝 Checklist
⌛ Dependencies
sage --package list: Sort output, add switches--{in,ex}clude-dependencies#36393bootstrap-conda: Refactor, generate versioned environment files #36405setuptoolsupdate #36411build/pkgs/setuptools_scm: Update to 8.0.4, add fixes for version 8 #36400networkx,scipy,ipywidgets: Update version ranges inconda.txt#36513 (split out from here)build/pkgs/sagenb_export: Fix install-requires.txt #36514 (split out from here)