Skip to content

Commit

Permalink
gh-37287: sagemath-standard: include sage_setup in sdist
Browse files Browse the repository at this point in the history
    
This makes it so that `sage_setup` is included in `sagemath_standard`
for convenience and ease of installation.

Having `sage_setup` as a separate distribution leads to chicken-and-egg
problem. For example, this is what happens when I try to build
`sagemath-standard` from #37270:
```
cd pkgs/sagemath-standard
$ python -m build -s
* Creating venv isolated environment...
* Installing packages in isolated environment... (cypari2 >=2.1.1,
cysignals >=1.10.2, cython >=3.0, != 3.0.3, <4.0, gmpy2 ~=2.1.b999,
jinja2 >=3.0, jupyter_core >=4.6.3, memory_allocator, numpy >=1.19,
pkgconfig, pplpy >=0.8.6, sage-conf ~= 10.3b7, sage-setup ~= 10.3b7,
sage_setup[autogen], setuptools >= 68.1.1, wheel >=0.36.2)

[... snip ...]

ERROR: Could not find a version that satisfies the requirement sage-
setup~=10.3b7 (from versions: 9.4rc1)
ERROR: No matching distribution found for sage-setup~=10.3b7

[...]
```
This is because the version of sage-setup which is available on pypi
requires python <= 3.11. Even if the branch I'm trying to build allows
python 3.12, I cannot use it.

The main idea of this change is that `sagemath-standard` sdists are
self-contained and include the exact matching version of sage-setup. The
self-contained part is good for the pypi sdist, but the matching version
allows for greater flexibility when testing, given that the
implementations of `sagemath-standard/setup.py` and `sage_setup` are so
intrincately connected and really need to match.

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
    
URL: #37287
Reported by: Gonzalo Tornaría
Reviewer(s): Dima Pasechnik, Tobias Diez
  • Loading branch information
Release Manager committed Apr 24, 2024
2 parents c315128 + 0c8d742 commit 4445529
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .devcontainer/onCreate-conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ conda init bash

# Build sage
conda run -n sage-dev ./bootstrap
conda run -n sage-dev ./configure --with-python=/opt/conda/envs/sage-dev/bin/python --prefix=/opt/conda/envs/sage-dev
conda run -n sage-dev pip install --no-build-isolation -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup
conda run -n sage-dev pip install --no-build-isolation -v -v -e ./src
7 changes: 1 addition & 6 deletions .github/workflows/ci-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,16 @@ jobs:
conda info
conda list
- name: Configure
- name: Bootstrap
shell: bash -l {0}
continue-on-error: true
run: |
./bootstrap
echo "::add-matcher::.github/workflows/configure-systempackage-problem-matcher.json"
./configure --enable-build-as-root --with-python=$CONDA_PREFIX/bin/python --prefix=$CONDA_PREFIX --enable-system-site-packages $(for pkg in $(./sage -package list :standard: --has-file spkg-configure.m4 --has-file distros/conda.txt --exclude rpy2); do echo --with-system-$pkg=force; done)
echo "::remove-matcher owner=configure-system-package-warning::"
echo "::remove-matcher owner=configure-system-package-error::"
- name: Build
shell: bash -l {0}
run: |
# Use --no-deps and pip check below to verify that all necessary dependencies are installed via conda.
pip install --no-build-isolation --no-deps -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup
pip install --no-build-isolation --no-deps --config-settings editable_mode=compat -v -v -e ./src
env:
SAGE_NUM_THREADS: 2
Expand Down
2 changes: 0 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ tasks:
&& conda config --append envs_dirs $(pwd)
&& conda activate $(pwd)/venv
&& ./bootstrap
&& ./configure --enable-build-as-root --with-python=$CONDA_PREFIX/bin/python --prefix=$CONDA_PREFIX
&& pip install --no-build-isolation -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup
&& pip install --no-build-isolation -v -v -e ./src
# Activate conda environment, set up Trac remote
# RestructuredText extension recommends python extension, although we have already installed it
Expand Down
2 changes: 1 addition & 1 deletion pkgs/sage-conf/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ sage_conf for conda

The version of the distribution package in the directory
`pkgs/sage-conf_conda <https://github.com/sagemath/sage/tree/develop/pkgs/sage-conf_conda/>`_
is used in an experimental installation method of SageMath, where all packages
may be used in an installation method of SageMath, where all packages
are provided by conda. This method is described in
https://doc.sagemath.org/html/en/installation/conda.html#using-conda-to-provide-all-dependencies-for-the-sage-library-experimental

Expand Down
1 change: 1 addition & 0 deletions pkgs/sagemath-standard/sage_setup
7 changes: 6 additions & 1 deletion src/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ include VERSION.txt
recursive-include sage *.pxi *.pxd *.h *.hpp

prune sage/ext/interpreters # In particular, __init__.py must not be present in the distribution; or sage_setup.autogen.interpreters.rebuild will not generate the code
prune sage_setup
prune sage_docbuild
prune doc

# include sage_setup
recursive-include sage_setup *
prune sage_setup/autogen/flint*
exclude sage_setup/autogen/flint*
exclude sage_setup/autogen/giacpy*

#
# Most C and C++ files are generated by Cython and should not
# be included in the sdist.
Expand Down
7 changes: 6 additions & 1 deletion src/doc/en/installation/conda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,14 @@ Here we assume that you are using a git checkout.
- Bootstrap the source tree and install the build prerequisites and the Sage library::

$ ./bootstrap
$ pip install --no-build-isolation -v -v --editable ./pkgs/sage-conf_conda ./pkgs/sage-setup
$ pip install --no-build-isolation --config-settings editable_mode=compat -v -v --editable ./src

If you encounter any errors, try to install the ``sage-conf`` package first::

$ pip install --no-build-isolation -v -v --editable ./pkgs/sage-conf_conda

and then run the last command again.

- Verify that Sage has been installed::

$ sage -c 'print(version())'
Expand Down
6 changes: 0 additions & 6 deletions src/pyproject.toml.m4
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"sage_setup[autogen]",
# Some version of sage-conf is required.
# Note that PEP517/518 have no notion of optional sage_spkg dependencies:
# https://github.com/pypa/pip/issues/6144
esyscmd(`sage-get-system-packages install-requires-toml \
sage_conf \
setuptools \
wheel \
sage_setup \
cypari \
cysignals \
cython \
Expand Down
1 change: 0 additions & 1 deletion src/setup.cfg.m4
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ include(`setup_cfg_metadata.m4')dnl'
[options]
python_requires = >=3.9, <3.13
install_requires =
SPKG_INSTALL_REQUIRES_sage_conf
SPKG_INSTALL_REQUIRES_six
dnl From build/pkgs/sagelib/dependencies
SPKG_INSTALL_REQUIRES_conway_polynomials
Expand Down

0 comments on commit 4445529

Please sign in to comment.