Opened 21 months ago

Last modified 20 months ago

#29038 closed enhancement

Python package sage_conf: Provides optional configuration information for sagelib — at Version 21

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.1
Component: build Keywords:
Cc: fbissey, arojas, isuruf, embray, infinity0, gh-timokau, jdemeyer, dimpase, jhpalmieri, vbraun Merged in:
Authors: Matthias Koeppe Reviewers:
Report Upstream: N/A Work issues:
Branch: u/mkoeppe/python_package_sage_conf__provides_optional_configuration_information_for_sagelib (Commits, GitHub, GitLab) Commit: f2863760bea085d285709ef848c53e6ce17a65fa
Dependencies: Stopgaps:

Status badges

Description (last modified by mkoeppe)

This ticket introduces a new Python package sage_conf.

  • sage-the-distribution will generate this Python package at ./configure time and install it at build time before starting to build/install sagelib using src/setup.py.
  • Distributions will generate and install their own sage_conf by a method of their choice before starting to build/install sagelib.

A console_script allows to query individual variable values from the shell, or output all variables in .env format:

$ local/bin/sage-config MAXIMA
/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/local/bin/maxima
$ local/bin/sage-config
VERSION=9.1.beta0
MAXIMA=/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/local/bin/maxima
SAGE_LOCAL=/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/local
SAGE_ROOT=/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring

The module and the script are used as follows:

  1. It provides configuration information to sagelib at installation time (src/setup.py).

Ultimately we want to be able to install sagelib with pip. To support installation by pip from PyPI, from an URL, etc., we cannot expect to configure the build like we do now, by writing the configuration to the file src/sage-env-config. Moreover, if pip is running in --isolated mode, also no environment variables are passed. Then the only information flow is through arguments to pip build and through the installed Python packages. By installing sage_conf first, we make the configuration available to the pip install of sagelib.

  1. It provides configuration information to the docbuild, in particular about the install locations of documentation of external packages.
  1. It provides configuration information to the runtime of sagelib, making sagelib more independent from the environment variables set by src/bin/sage-env (local/bin/sage-env).
  1. By providing SAGE_LOCAL as one the configuration variables, it removes assumptions regarding install locations of sagelib relative to $SAGE_LOCAL. This enables the following:
  • Installing an experimental version of sagelib in other install locations, such as in a user site packages directory.
  • Making sagelib available in a user's venv, as in the following example:

Without this ticket:

$ sage -python -m venv --system-site-packages ~/personal-sage-venv/
$ source ~/personal-sage-venv/bin/activate
(personal-sage-venv) $ python
>>> import sage.env
>>> sage.env.SAGE_LOCAL
'/Users/mkoeppe/personal-sage-venv'                                     # wrong
>>> import sage.all
RuntimeError: You must get the file local/bin/sage-maxima.lisp

With this ticket:

>>> sage.env.SAGE_LOCAL
'/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/local'
>>> import sage.all
>>> sage.all.maxima('1')
1
  • #29013/#27824: Using the system python3 via spkg-configure.m4
  1. For a broader context: see #21707 Task: Split sage-env into 5

Change History (21)

comment:1 Changed 21 months ago by mkoeppe

  • Authors set to Matthias Koeppe
  • Description modified (diff)

comment:2 Changed 21 months ago by mkoeppe

  • Branch set to u/mkoeppe/python_package_sage_conf__provides_optional_configuration_information_for_sagelib

comment:3 Changed 21 months ago by mkoeppe

  • Cc fbissey arojas isuruf embray infinity0 gh-timokau jdemeyer dimpase jhpalmieri added
  • Commit set to fe5c890e66a7dd37395720b6c8e08a3837e5a74d
  • Status changed from new to needs_review

New commits:

fe5c89029038: Python package sage_conf: Provides configuration information for sagelib

comment:4 Changed 21 months ago by git

  • Commit changed from fe5c890e66a7dd37395720b6c8e08a3837e5a74d to aefd827981481f015c696328402278f2f8d30912

Branch pushed to git repo; I updated commit sha1. New commits:

aefd827build/pkgs/sage_conf/spkg-install: Fix up path

comment:5 Changed 21 months ago by dimpase

why are you checking in files which apparently are meant to be generated from .in templates?

comment:6 Changed 21 months ago by mkoeppe

A mistake, which I will fix in a moment. Thanks!

comment:7 Changed 21 months ago by git

  • Commit changed from aefd827981481f015c696328402278f2f8d30912 to 88fd03c7784eb82eeb8cb06102ed4e93f5f1d758

Branch pushed to git repo; I updated commit sha1. New commits:

981e864Move .gitignore to the right place, remove generated files
88fd03cAdd console_scripts entry_point sage-config

comment:8 Changed 21 months ago by mkoeppe

  • Description modified (diff)

comment:9 Changed 20 months ago by mkoeppe

  • Description modified (diff)

comment:10 Changed 20 months ago by mkoeppe

  • Description modified (diff)

comment:11 Changed 20 months ago by mkoeppe

  • Description modified (diff)

comment:12 follow-up: Changed 20 months ago by dimpase

the example with sage --python -m venv - is it going to work if Sage is using venv on its own?

comment:13 in reply to: ↑ 12 Changed 20 months ago by mkoeppe

Replying to dimpase:

the example with sage --python -m venv - is it going to work if Sage is using venv on its own?

Not without installing sage packages into the new venv. As far as I can see, one can only control whether system-packages are made available but not whether the originating venv's packages are made available. But I'd expect that this option will be invented at some point in Python.

comment:14 Changed 20 months ago by mkoeppe

  • Description modified (diff)

comment:15 follow-up: Changed 20 months ago by dimpase

is sage_conf also meant to be used while building Sage's dependencies?

comment:16 in reply to: ↑ 15 Changed 20 months ago by mkoeppe

Replying to dimpase:

is sage_conf also meant to be used while building Sage's dependencies?

No.

comment:17 Changed 20 months ago by dimpase

author ought to be either "The Sage Developers" (cf https://wiki.sagemath.org/Publications_using_SageMath?action=show&redirect=Publications_using_SAGE) or yourself...

comment:18 follow-up: Changed 20 months ago by mkoeppe

I copied the metadata from src/setup.py

comment:19 in reply to: ↑ 18 Changed 20 months ago by dimpase

Replying to mkoeppe:

I copied the metadata from src/setup.py

that line is 5.5 years old. With all respect, William has not contributed a line of code to sagemath since 2017.

Last edited 20 months ago by dimpase (previous) (diff)

comment:20 Changed 20 months ago by git

  • Commit changed from 88fd03c7784eb82eeb8cb06102ed4e93f5f1d758 to f2863760bea085d285709ef848c53e6ce17a65fa

Branch pushed to git repo; I updated commit sha1. New commits:

f286376build/pkgs/sage_conf/src/setup.cfg.in: Change author to 'The Sage Developers'

comment:21 Changed 20 months ago by mkoeppe

  • Description modified (diff)
Note: See TracTickets for help on using tickets.