Skip to content

Commit 7bb1e6b

Browse files
author
Release Manager
committed
gh-36141: Use system python packages with --enable-system-site-packages Rebased branch of #29665 Platform-specific testing: - for example TARGETS_PRE="build-local" tox -e docker-ubuntu-focal- standard-sitepackages -- build ptest Fixes #29665 URL: #36141 Reported by: Michael Orlitzky Reviewer(s): Dima Pasechnik, Matthias Köppe, Michael Orlitzky
2 parents 7ed5b8b + de831a5 commit 7bb1e6b

File tree

730 files changed

+1106
-340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

730 files changed

+1106
-340
lines changed

.github/workflows/ci-linux.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,56 @@ jobs:
6363
["standard"]
6464
docker_push_repository: ghcr.io/${{ github.repository }}/
6565

66+
standard-sitepackages:
67+
if: ${{ success() || failure() }}
68+
needs: [standard-pre]
69+
uses: ./.github/workflows/docker.yml
70+
with:
71+
# Build incrementally from previous stage (pre)
72+
incremental: true
73+
free_disk_space: true
74+
from_docker_repository: ghcr.io/${{ github.repository }}/
75+
from_docker_target: "with-targets-pre"
76+
docker_targets: "with-targets with-targets-optional"
77+
# FIXME: duplicated from env.TARGETS
78+
targets: build doc-html
79+
targets_optional: ptest
80+
tox_packages_factors: >-
81+
["standard-sitepackages"]
82+
# Only test systems with a usable system python (>= 3.9)
83+
tox_system_factors: >-
84+
["ubuntu-jammy",
85+
"ubuntu-kinetic",
86+
"ubuntu-lunar",
87+
"ubuntu-mantic",
88+
"debian-bullseye",
89+
"debian-bookworm",
90+
"debian-trixie",
91+
"debian-sid",
92+
"linuxmint-21",
93+
"linuxmint-21.1",
94+
"linuxmint-21.2",
95+
"fedora-33",
96+
"fedora-34",
97+
"fedora-35",
98+
"fedora-36",
99+
"fedora-37",
100+
"fedora-38",
101+
"fedora-39",
102+
"centos-stream-8-python3.9",
103+
"centos-stream-9-python3.9",
104+
"almalinux-8-python3.9",
105+
"gentoo-python3.10",
106+
"gentoo-python3.11",
107+
"archlinux-latest",
108+
"opensuse-15.4-gcc_11-python3.10",
109+
"opensuse-15.5-gcc_11-python3.11",
110+
"opensuse-tumbleweed-python3.10",
111+
"opensuse-tumbleweed",
112+
"debian-bullseye-i386"]
113+
docker_push_repository: ghcr.io/${{ github.repository }}/
114+
max_parallel: 10
115+
66116
minimal-pre:
67117
if: ${{ success() || failure() }}
68118
# It does not really "need" it.

.github/workflows/docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ on:
5757
"opensuse-15.4-gcc_11-python3.10",
5858
"opensuse-15.5-gcc_11-python3.11",
5959
"opensuse-tumbleweed-python3.10",
60+
"opensuse-tumbleweed",
6061
"conda-forge",
6162
"ubuntu-bionic-gcc_8-i386",
6263
"debian-bullseye-i386",

build/bin/sage-build-env-config.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ export SAGE_PARI_CFG="@SAGE_PARI_CFG@"
5353

5454
export SAGE_GLPK_PREFIX="@SAGE_GLPK_PREFIX@"
5555
export SAGE_FREETYPE_PREFIX="@SAGE_FREETYPE_PREFIX@"
56+
export SAGE_PIP_INSTALL_FLAGS="@SAGE_PIP_INSTALL_FLAGS@"
5657
export SAGE_SUITESPARSE_PREFIX="@SAGE_SUITESPARSE_PREFIX@"
5758

5859
export SAGE_CONFIGURE_FFLAS_FFPACK="@SAGE_CONFIGURE_FFLAS_FFPACK@"
5960

6061
export CONFIGURED_SAGE_EDITABLE="@SAGE_EDITABLE@"
6162
export CONFIGURED_SAGE_WHEELS="@SAGE_WHEELS@"
63+
64+
export ENABLE_SYSTEM_SITE_PACKAGES="@ENABLE_SYSTEM_SITE_PACKAGES@"
65+
export PYTHON_MINOR="@PYTHON_MINOR@"

build/bin/sage-dist-helpers

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ sdh_store_wheel() {
325325
}
326326

327327
sdh_store_and_pip_install_wheel() {
328-
local pip_options=""
328+
# The $SAGE_PIP_INSTALL_FLAGS variable is set by sage-build-env-config.
329+
# We skip sanity checking its contents since you should either let sage
330+
# decide what it contains, or really know what you are doing.
331+
local pip_options="${SAGE_PIP_INSTALL_FLAGS}"
332+
329333
while [ $# -gt 0 ]; do
330334
case $1 in
331335
-*) pip_options="$pip_options $1"

build/bin/sage-get-system-packages

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2+
23
SYSTEM=$1
34
if [ -z "$SYSTEM" ]; then
45
echo >&2 "usage: $0 {auto|debian|arch|conda|pip|...} SPKGS..."
@@ -10,6 +11,7 @@ SPKGS="$*"
1011
if [ -z "$SAGE_ROOT" ]; then
1112
SAGE_ROOT=`pwd`
1213
fi
14+
1315
case "$SYSTEM" in
1416
install-requires)
1517
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
@@ -44,6 +46,18 @@ case "$SYSTEM" in
4446
;;
4547
esac
4648
for PKG_BASE in $SPKGS; do
49+
50+
# Skip this package if it uses the SAGE_PYTHON_PACKAGE_CHECK
51+
# macro and if --enable-system-site-packages was NOT passed
52+
# to ./configure (or if ./configure has not yet been run).
53+
SPKG_CONFIGURE="${SAGE_ROOT}/build/pkgs/${PKG_BASE}/spkg-configure.m4"
54+
if [ -z "${ENABLE_SYSTEM_SITE_PACKAGES}" ]; then
55+
if grep -q SAGE_PYTHON_PACKAGE_CHECK "${SPKG_CONFIGURE}" 2>/dev/null;
56+
then
57+
continue;
58+
fi
59+
fi
60+
4761
for NAME in $SYSTEM_PACKAGES_FILE_NAMES; do
4862
SYSTEM_PACKAGES_FILE="$SAGE_ROOT"/build/pkgs/$PKG_BASE/$NAME
4963
if [ -f $SYSTEM_PACKAGES_FILE ]; then

build/bin/sage-spkg-info

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,19 @@ if [ -z "$system" ]; then
110110
echo "(none known)"
111111
else
112112
echo
113-
if [ -f "$PKG_SCRIPTS"/spkg-configure.m4 ]; then
114-
echo "If the system package is installed, ./configure will check whether it can be used."
115-
else
116-
echo "However, these system packages will not be used for building Sage"
117-
if [ -f "$PKG_SCRIPTS"/install-requires.txt ]; then
118-
echo "because using Python site-packages is not supported by the Sage distribution;"
119-
echo "see https://github.com/sagemath/sage/issues/29023"
113+
SPKG_CONFIGURE="${PKG_SCRIPTS}/spkg-configure.m4"
114+
if [ -f "${SPKG_CONFIGURE}" ]; then
115+
if grep -q SAGE_PYTHON_PACKAGE_CHECK "${SPKG_CONFIGURE}"; then
116+
echo "If the system package is installed and if the (experimental) option"
117+
echo "--enable-system-site-packages is passed to ./configure, then ./configure"
118+
echo "will check if the system package can be used."
120119
else
121-
echo "because spkg-configure.m4 has not been written for this package;"
122-
echo "see https://github.com/sagemath/sage/issues/27330"
120+
echo "If the system package is installed, ./configure will check if it can be used."
123121
fi
122+
else
123+
echo "However, these system packages will not be used for building Sage"
124+
echo "because spkg-configure.m4 has not been written for this package;"
125+
echo "see https://github.com/sagemath/sage/issues/27330"
124126
fi
125127
fi
126128
echo

build/bin/write-dockerfile.sh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set -e
66
SYSTEM="${1:-debian}"
77
shopt -s extglob
8-
SAGE_PACKAGE_LIST_ARGS="${2:- --has-file=spkg-configure.m4 :standard:}"
8+
SAGE_PACKAGE_LIST_ARGS="${2:-:standard:}"
99
WITH_SYSTEM_SPKG="${3:-yes}"
1010
IGNORE_MISSING_SYSTEM_PACKAGES="${4:-no}"
1111
EXTRA_SAGE_PACKAGES="${5:-_bootstrap}"
@@ -15,17 +15,13 @@ SAGE_ROOT=.
1515
export PATH="$SAGE_ROOT"/build/bin:$PATH
1616
SYSTEM_PACKAGES=$EXTRA_SYSTEM_PACKAGES
1717
CONFIGURE_ARGS="--enable-option-checking "
18-
for PKG_BASE in $(sage-package list --has-file=distros/$SYSTEM.txt $SAGE_PACKAGE_LIST_ARGS) $EXTRA_SAGE_PACKAGES; do
19-
PKG_SCRIPTS="$SAGE_ROOT"/build/pkgs/$PKG_BASE
20-
if [ -d $PKG_SCRIPTS ]; then
21-
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/distros/$SYSTEM.txt
22-
PKG_SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE))
23-
if [ -n "PKG_SYSTEM_PACKAGES" ]; then
24-
SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
25-
if [ -f $PKG_SCRIPTS/spkg-configure.m4 ]; then
26-
CONFIGURE_ARGS+="--with-system-$PKG_BASE=${WITH_SYSTEM_SPKG} "
27-
fi
28-
fi
18+
for SPKG in $(sage-package list --has-file=spkg-configure.m4 $SAGE_PACKAGE_LIST_ARGS) $EXTRA_SAGE_PACKAGES; do
19+
SYSTEM_PACKAGE=$(sage-get-system-packages $SYSTEM $SPKG | sed 's/${PYTHON_MINOR}/'${PYTHON_MINOR}'/g')
20+
if [ -n "${SYSTEM_PACKAGE}" ]; then
21+
# SYSTEM_PACKAGE can be empty if, for example, the environment
22+
# variable ENABLE_SYSTEM_SITE_PACKAGES is empty.
23+
SYSTEM_PACKAGES+=" ${SYSTEM_PACKAGE}"
24+
CONFIGURE_ARGS+="--with-system-${SPKG}=${WITH_SYSTEM_SPKG} "
2925
fi
3026
done
3127
echo "# Automatically generated by SAGE_ROOT/build/bin/write-dockerfile.sh"

build/make/Makefile.in

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,29 @@ SAGE_I_TARGETS = sagelib doc
227227
python3_venv _clean-broken-gcc
228228

229229
PYTHON_FOR_VENV = @PYTHON_FOR_VENV@
230+
PYTHON_MINOR = @PYTHON_MINOR@
231+
SAGE_VENV_FLAGS = @SAGE_VENV_FLAGS@
230232

231233
ifneq ($(PYTHON_FOR_VENV),)
232234
# Special rule for making the Python virtualenv from the system Python (Python
233235
# 3 only). $(PYTHON) is set in Makefile to python3_venv.
234-
# Thus $(inst_python3_venv) will be the dependency of every Python package.
236+
# Thus $(inst_python3_venv) will an (order-only) dependency of every Python package.
235237
#
236238
# TODO: If we reconfigure to build our own Python after having used the system
237239
# Python, files installed to create the virtualenv should be *removed*. That
238240
# could either be done here by the makefile, or in an spkg-preinst for python3
239241
ifeq ($(PYTHON),python3)
240242
PYTHON = python3_venv
241243
endif
242-
inst_python3_venv = $(SAGE_VENV)/pyvenv.cfg
244+
inst_python3_venv = $(SAGE_VENV)/$(SPKG_INST_RELDIR)/python3_venv-3.$(PYTHON_MINOR)-$(subst /,-,$(PYTHON_FOR_VENV))$(findstring --system-site-packages,$(SAGE_VENV_FLAGS))
243245

244-
$(inst_python3_venv):
245-
$(PYTHON_FOR_VENV) $(SAGE_ROOT)/build/bin/sage-venv "$(SAGE_VENV)"
246+
$(SAGE_VENV)/$(SPKG_INST_RELDIR):
247+
mkdir -p "$@"
248+
249+
$(inst_python3_venv): | $(SAGE_VENV)/$(SPKG_INST_RELDIR)
250+
$(PYTHON_FOR_VENV) $(SAGE_ROOT)/build/bin/sage-venv $(SAGE_VENV_FLAGS) "$(SAGE_VENV)"
251+
rm -f "$(SAGE_VENV)/$(SPKG_INST_RELDIR)"/python3_venv-*
252+
touch "$@"
246253
endif
247254

248255
# Build everything and start Sage.

build/pkgs/admcycles/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$(PYTHON) | $(PYTHON_TOOLCHAIN)
1+
| $(PYTHON_TOOLCHAIN) $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.

build/pkgs/alabaster/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$(PYTHON) | $(PYTHON_TOOLCHAIN)
1+
| $(PYTHON_TOOLCHAIN) $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.

0 commit comments

Comments
 (0)