Skip to content
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

Document building from the monorepo using PIP_CONSTRAINT=$SAGE_ROOT/constraints_pkgs.txt #37434

Merged
merged 21 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c4d3b66
Add noexcept in matroids and set for cython 3.0.11 compatibility
kiwifb Aug 12, 2024
264b913
constraints_pkgs.txt, pkgs/sagemath-standard/constraints_pkgs.txt: New
mkoeppe Feb 23, 2024
9d5322c
.github/workflows/ci-linux.yml: Test sagelib-tox-sagepython-constrain…
mkoeppe Feb 23, 2024
7598576
.github/workflows/ci-linux-incremental.yml: Test constraints_pkgs-nor…
mkoeppe Feb 23, 2024
f8f7b0f
.github/workflows/ci-linux.yml: Fixup
mkoeppe Feb 23, 2024
114b53c
make SPKG-tox-...: Do set the sage environment
mkoeppe Feb 24, 2024
31d6a6b
Add some `except`s (#1)
gmou3 Aug 14, 2024
c52ad79
src/pyproject.toml: Add missing build dep jinja2
mkoeppe Aug 16, 2024
4eff0a0
Merge branch 'src_pyproject_toml_jinja2' into constraints_pkgs
mkoeppe Aug 16, 2024
b3fd6af
pkgs/sagemath-standard/constraints_pkgs.txt: More verbosity in example
mkoeppe Aug 16, 2024
61ace88
constraints_pkgs.txt: More verbosity in example
mkoeppe Aug 16, 2024
b0a6880
Merge commit 'refs/pull/38500/head' of https://github.com/sagemath/sa…
mkoeppe Aug 16, 2024
df5e38a
.github/workflows/ci-linux-incremental.yml: Update, reduce 'constrain…
mkoeppe Aug 16, 2024
b7ff066
.github/workflows/ci-linux[-incremental].yml: Use 'targets-pre' for '…
mkoeppe Aug 16, 2024
bfb531e
.github/workflows/ci-linux.yml: Build all-sage-local for 'constraints…
mkoeppe Aug 16, 2024
bf00218
.github/workflows/ci-linux[-incremental].yml: Ensure tox is installed…
mkoeppe Aug 16, 2024
02f6e88
pkgs/sagemath-standard/README.rst: Add link to https://github.com/sag…
mkoeppe Aug 18, 2024
524dc88
pkgs/sagemath-standard/README.rst: Update copyright year; no longer '…
mkoeppe Aug 18, 2024
368e9f6
pkgs/sagemath-standard/constraints_pkgs.txt: Make explanation more sp…
mkoeppe Aug 18, 2024
4204f2d
pkgs/sagemath-standard/constraints_pkgs.txt: Make explanation more sp…
mkoeppe Aug 18, 2024
3ab2a18
pkgs/sagemath-standard/constraints_pkgs.txt: Change to just 'Example:'
mkoeppe Aug 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions .github/workflows/ci-linux-incremental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ jobs:
uninstall_targets=$(echo $(for a in '' ${{ steps.changed-files.outputs.configures_all_changed_files }}; do echo $a | sed -E 's,build/pkgs/([a-z0-9][_.a-z0-9]*)/spkg-configure[.]m4 *,\1-uninstall,'; done | sort -u))
build_targets=$(echo $(for a in '' ${{ steps.changed-files.outputs.pkgs_all_changed_files }}; do SPKG=$(echo $a | sed -E 's,-,_,g;s,(build/)?pkgs/([a-z0-9][-_.a-z0-9]*)/[^ ]* *,\2,;'); if [ -f "build/pkgs/$SPKG/checksums.ini" -o -f "build/pkgs/$SPKG/requirements.txt" -o -f "build/pkgs/$SPKG/spkg-install" ]; then echo "$SPKG-ensure"; fi; done | sort -u))
if [ -n "$uninstall_targets" ]; then
echo "build_targets=$uninstall_targets reconfigure $build_targets ci-build-with-fallback" >> $GITHUB_OUTPUT
echo "build_targets=$uninstall_targets reconfigure $build_targets" >> $GITHUB_OUTPUT
else
echo "build_targets=$build_targets ci-build-with-fallback" >> $GITHUB_OUTPUT
echo "build_targets=$build_targets" >> $GITHUB_OUTPUT
fi
cat $GITHUB_OUTPUT
- uses: actions/checkout@v4
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
from_docker_target: "with-targets"
from_docker_tag: "dev"
docker_targets: "with-targets"
targets: "${{needs.changed_files.outputs.build_targets}} doc-html ptest-nodoc"
targets: "${{needs.changed_files.outputs.build_targets}} ci-build-with-fallback doc-html ptest-nodoc"
tox_system_factors: >-
["ubuntu-focal",
"ubuntu-noble",
Expand All @@ -108,6 +108,29 @@ jobs:
docker_push_repository: ghcr.io/${{ github.repository }}/
max_parallel: 8

constraints_pkgs-norequirements:
needs: [changed_files]
uses: ./.github/workflows/docker.yml
with:
# Build incrementally from published Docker image
incremental: true
free_disk_space: true
from_docker_repository: ghcr.io/sagemath/sage/
from_docker_target: "with-targets-pre"
from_docker_tag: "dev"
docker_targets: "with-targets-pre"
targets_pre: "${{needs.changed_files.outputs.build_targets}} all-sage-local python3-ensure tox-ensure sagelib-tox-sagepython-constraints_pkgs-norequirements"
tox_system_factors: >-
["ubuntu-focal",
"ubuntu-noble",
"debian-bookworm",
"fedora-40",
"debian-bullseye-i386"]
tox_packages_factors: >-
["standard"]
docker_push_repository: ghcr.io/${{ github.repository }}/
max_parallel: 16

site:
needs: [changed_files]
uses: ./.github/workflows/docker.yml
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ jobs:
# and 'minimal-pre' below
max_parallel: 20

standard-constraints_pkgs-norequirements:
if: ${{ success() || failure() }}
needs: [standard-pre]
uses: ./.github/workflows/docker.yml
with:
# Build incrementally from previous stage (pre)
incremental: true
free_disk_space: true
from_docker_repository: ghcr.io/${{ github.repository }}/
from_docker_target: "with-targets-pre"
docker_targets: "with-targets-pre"
targets_pre: all-sage-local python3-ensure tox-ensure sagelib-tox-sagepython-constraints_pkgs-norequirements
tox_packages_factors: >-
["standard"]
max_parallel: 15

standard-sitepackages:
if: ${{ success() || failure() }}
needs: [standard-pre]
Expand Down
8 changes: 5 additions & 3 deletions build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,14 @@ $(1)-sdist: FORCE python_build sage_setup cython
. '$$(SAGE_ROOT)/src/bin/sage-env' && \
'$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-src'

# Recursive tox invocation (note - we do not set the environment here).
# Recursive tox invocation
# Setting SAGE_SPKG_WHEELS is for the benefit of sagelib's tox.ini
$(1)-tox-%: FORCE
$(AM_V_at)cd '$$(SAGE_ROOT)/build/pkgs/$(1)/src' && \
export PATH="$$(SAGE_ORIG_PATH)" && \
SAGE_SPKG_WHEELS=$$(SAGE_LOCAL)/var/lib/sage/wheels \
. '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \
. '$$(SAGE_ROOT)/src/bin/sage-env-config' && \
. '$$(SAGE_ROOT)/src/bin/sage-env' && \
SAGE_SPKG_WHEELS=$$(SAGE_VENV)/var/lib/sage/wheels \
tox -v -v -v -e $$*

.PHONY: $(1) $(1)-uninstall $(1)-clean $(1)-build-deps $(1)-no-deps $(1)-clean
Expand Down
39 changes: 39 additions & 0 deletions constraints_pkgs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This "constraints file" can be used for forcing pip
# (and any tools that delegate to pip, such as pypa/build)
# to install the distribution packages included in
# the SageMath monorepository only from their source trees
# in SAGE_ROOT/pkgs/ instead of from PyPI.
#
# Example: Building a sagemath-standard wheel
#
# [alice@localhost sage]$ ./bootstrap
# [alice@localhost sage]$ ./configure
# [alice@localhost sage]$ export MAKE="make -j16" SAGE_NUM_THREADS=16
# [alice@localhost sage]$ make all-sage-local
# [alice@localhost sage]$ export PIP_CONSTRAINT="$(pwd)/constraints_pkgs.txt"
# [alice@localhost sage]$ ./sage -sh -c 'python3 -m build -v -v pkgs/sagemath-standard'
#
# Non-example: Installing the built wheel using the same
# constraints file will fail because sagemath-standard is one
# of the distribution packages listed below. It will conflict
# with the built wheel for sagemath-standard!
# Use "pkgs/sagemath-standard/constraints_pkgs.txt" instead.

# Reference on the format:
# https://pip.pypa.io/en/stable/user_guide/#constraints-files
#
sage_conf @ file://${SAGE_ROOT}/pkgs/sage-conf
sage_docbuild @ file://${SAGE_ROOT}/pkgs/sage-docbuild
sage_setup @ file://${SAGE_ROOT}/pkgs/sage-setup
sage_sws2rst @ file://${SAGE_ROOT}/pkgs/sage-sws2rst
sagemath-bliss @ file://${SAGE_ROOT}/pkgs/sagemath-bliss
sagemath-categories @ file://${SAGE_ROOT}/pkgs/sagemath-categories
sagemath-coxeter3 @ file://${SAGE_ROOT}/pkgs/sagemath-coxeter3
sagemath-environment @ file://${SAGE_ROOT}/pkgs/sagemath-environment
sagemath-mcqd @ file://${SAGE_ROOT}/pkgs/sagemath-mcqd
sagemath-meataxe @ file://${SAGE_ROOT}/pkgs/sagemath-meataxe
sagemath-objects @ file://${SAGE_ROOT}/pkgs/sagemath-objects
sagemath-repl @ file://${SAGE_ROOT}/pkgs/sagemath-repl
sagemath-sirocco @ file://${SAGE_ROOT}/pkgs/sagemath-sirocco
sagemath-standard @ file://${SAGE_ROOT}/pkgs/sagemath-standard
sagemath-tdlib @ file://${SAGE_ROOT}/pkgs/sagemath-tdlib
20 changes: 20 additions & 0 deletions pkgs/sagemath-standard/constraints_pkgs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This "constraints file" can be used for forcing pip
# (and any tools that delegate to pip, such as pypa/build)
# to install the distribution packages included in
# the SageMath monorepository only from their source trees
# in SAGE_ROOT/pkgs/ instead of from PyPI.
#
# Example: Building a sagemath-standard wheel
#
# [alice@localhost sage]$ ./bootstrap
# [alice@localhost sage]$ ./configure
# [alice@localhost sage]$ export MAKE="make -j16" SAGE_NUM_THREADS=16
# [alice@localhost sage]$ make all-sage-local
# [alice@localhost sage]$ export PIP_CONSTRAINT="$(pwd)/pkgs/sagemath-standard/constraints_pkgs.txt"
# [alice@localhost sage]$ ./sage -sh -c 'python3 -m build -v -v pkgs/sagemath-standard'
#
kwankyu marked this conversation as resolved.
Show resolved Hide resolved
# Reference on the format:
# https://pip.pypa.io/en/stable/user_guide/#constraints-files
#
sage_conf @ file://${SAGE_ROOT}/pkgs/sage-conf
sage_setup @ file://${SAGE_ROOT}/pkgs/sage-setup
35 changes: 35 additions & 0 deletions pkgs/sagemath-standard/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ envlist =
#
# ./sage -sh -c '(cd pkgs/sagemath-standard && tox -v -v -v -e sagepython-sagewheels-nopypi)'
#
# Build and test without using the concrete dependencies specified by requirements.txt,
# using the dependencies declared in pyproject.toml and setup.cfg (install-requires) only:
# Install the distribution packages included in the SageMath monorepository only from
# their source trees in SAGE_ROOT/pkgs/ (not from PyPI).
#
# ./sage -sh -c '(cd pkgs/sagemath-standard && tox -v -v -v -e sagepython-constraints_pkgs-norequirements)'
#
# Build dependencies according to requirements.txt (all versions fixed).
# Install the distribution packages included in the SageMath monorepository only from
# their source trees in SAGE_ROOT/pkgs/ (not from PyPI).
#
# ./sage -sh -c '(cd pkgs/sagemath-standard && tox -v -v -v -e sagepython-constraints_pkgs)'
#
# EXPERIMENTAL ENVIRONMENTS:
#
# Build dependencies according to requirements.txt (all versions fixed).
Expand Down Expand Up @@ -80,6 +93,8 @@ passenv =
MAKEFLAGS
# SAGE_VENV only for referring to the basepython or finding the wheels
sagepython, sagewheels: SAGE_VENV
# Used as an environment variable in constraints_pkgs.txt
constraints_pkgs: SAGE_ROOT
# Location of the wheels
sagewheels: SAGE_SPKG_WHEELS

Expand All @@ -88,6 +103,7 @@ setenv =
# apply both to the installation of the dependencies and of the package
sagewheels: PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
nopypi: PIP_NO_INDEX=true
constraints_pkgs: PIP_CONSTRAINT={toxinidir}/constraints_pkgs.txt
# No build isolation for PEP 517 packages - use what is already in the environment
# Note that this pip env "NO" variable uses inverted logic:
# PIP_NO_BUILD_ISOLATION=False means don't use build isolation.
Expand Down Expand Up @@ -153,6 +169,17 @@ setenv = {[pkgenv]setenv}

basepython = {env:SAGE_VENV}/bin/python3

[testenv:.pkg-sagepython-constraints_pkgs]
passenv = {[pkgenv]passenv}
SAGE_VENV
# Location of constraints_pkgs.txt
SAGE_ROOT

setenv = {[pkgenv]setenv}
PIP_CONSTRAINT={env:SAGE_ROOT}/constraints_pkgs.txt

basepython = {env:SAGE_VENV}/bin/python3

[testenv:sagepython]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython
Expand All @@ -177,6 +204,14 @@ package_env = .pkg-sagepython
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython

[testenv:sagepython-constraints_pkgs]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython-constraints_pkgs

[testenv:sagepython-constraints_pkgs-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython-constraints_pkgs


[testenv:sagepython-sagewheels-nopypi-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
Expand Down
1 change: 1 addition & 0 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ requires = [
'memory_allocator',
'numpy >=1.19',
'pkgconfig',
'jinja2',
]
build-backend = "setuptools.build_meta"

Expand Down
8 changes: 4 additions & 4 deletions src/sage/matroids/basis_exchange_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ cdef class BasisExchangeMatroid(Matroid):
cpdef _move_current_basis(self, X, Y)

cpdef frozenset _max_independent(self, frozenset F)
cpdef int _rank(self, frozenset F)
cpdef int _rank(self, frozenset F) except -1
cpdef frozenset _circuit(self, frozenset F)
cpdef frozenset _fundamental_circuit(self, frozenset B, e)
cpdef frozenset _closure(self, frozenset F)

cpdef frozenset _max_coindependent(self, frozenset F)
cpdef int _corank(self, frozenset F)
cpdef int _corank(self, frozenset F) noexcept
cpdef frozenset _cocircuit(self, frozenset F)
cpdef frozenset _fundamental_cocircuit(self, frozenset B, e)
cpdef frozenset _coclosure(self, frozenset F)

cpdef frozenset _augment(self, frozenset X, frozenset Y)
cpdef bint _is_independent(self, frozenset F)
cpdef bint _is_independent(self, frozenset F) noexcept

cpdef list whitney_numbers2(self)
cdef _whitney_numbers2_rec(self, object f_vec, bitset_t* flats, bitset_t* todo, long elt, long rnk)
Expand Down Expand Up @@ -90,6 +90,6 @@ cdef class BasisExchangeMatroid(Matroid):
cpdef _is_isomorphism(self, other, morphism)
cdef bint __is_isomorphism(self, BasisExchangeMatroid other, morphism) noexcept

cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept

cdef bint nxksrd(bitset_s *b, long n, long k, bint succ) noexcept
8 changes: 4 additions & 4 deletions src/sage/matroids/basis_exchange_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ cdef class BasisExchangeMatroid(Matroid):
self.__max_independent(self._output, self._input)
return self.__unpack(self._output)

cpdef int _rank(self, frozenset F):
cpdef int _rank(self, frozenset F) except -1:
"""
Compute the rank of a subset of the groundset.

Expand Down Expand Up @@ -796,7 +796,7 @@ cdef class BasisExchangeMatroid(Matroid):
self.__max_coindependent(self._output, self._input)
return self.__unpack(self._output)

cpdef int _corank(self, frozenset F):
cpdef int _corank(self, frozenset F) noexcept:
"""
Return the corank of a set.

Expand Down Expand Up @@ -940,7 +940,7 @@ cdef class BasisExchangeMatroid(Matroid):
self.__augment(self._output, self._input, self._input2)
return self.__unpack(self._output)

cpdef bint _is_independent(self, frozenset F):
cpdef bint _is_independent(self, frozenset F) noexcept:
"""
Test if input is independent.

Expand Down Expand Up @@ -2231,7 +2231,7 @@ cdef class BasisExchangeMatroid(Matroid):

return self._characteristic_setsystem()._isomorphism(other._characteristic_setsystem(), PS, PO) is not None

cpdef bint is_valid(self):
cpdef bint is_valid(self) noexcept:
r"""
Test if the data obey the matroid axioms.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/basis_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cdef class BasisMatroid(BasisExchangeMatroid):

cdef reset_current_basis(self)

cpdef bint _is_basis(self, frozenset X)
cpdef bint _is_basis(self, frozenset X) noexcept

cpdef bases_count(self)
cpdef SetSystem bases(self)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/basis_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ cdef class BasisMatroid(BasisExchangeMatroid):

# a function that is very efficient for this class

cpdef bint _is_basis(self, frozenset X):
cpdef bint _is_basis(self, frozenset X) noexcept:
"""
Test if input is a basis.

Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/circuit_closures_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ cdef class CircuitClosuresMatroid(Matroid):
cdef dict _circuit_closures # _CC
cdef int _matroid_rank # _R
cpdef frozenset groundset(self)
cpdef int _rank(self, frozenset X)
cpdef int _rank(self, frozenset X) except -1
cpdef full_rank(self)
cpdef bint _is_independent(self, frozenset F)
cpdef bint _is_independent(self, frozenset F) noexcept
cpdef frozenset _max_independent(self, frozenset F)
cpdef frozenset _circuit(self, frozenset F)
cpdef dict circuit_closures(self)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/circuit_closures_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ cdef class CircuitClosuresMatroid(Matroid):
"""
return frozenset(self._groundset)

cpdef int _rank(self, frozenset X):
cpdef int _rank(self, frozenset X) except -1:
"""
Return the rank of a set ``X``.

Expand Down Expand Up @@ -221,7 +221,7 @@ cdef class CircuitClosuresMatroid(Matroid):
"""
return self._matroid_rank

cpdef bint _is_independent(self, frozenset F):
cpdef bint _is_independent(self, frozenset F) noexcept:
"""
Test if input is independent.

Expand Down
8 changes: 4 additions & 4 deletions src/sage/matroids/circuits_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ cdef class CircuitsMatroid(Matroid):
cdef list _sorted_C_lens
cdef bint _nsc_defined
cpdef frozenset groundset(self)
cpdef int _rank(self, frozenset X)
cpdef int _rank(self, frozenset X) except -1
cpdef full_rank(self)
cpdef bint _is_independent(self, frozenset X)
cpdef bint _is_independent(self, frozenset X) noexcept
cpdef frozenset _max_independent(self, frozenset X)
cpdef frozenset _circuit(self, frozenset X)
cpdef frozenset _closure(self, frozenset X)
Expand All @@ -27,11 +27,11 @@ cdef class CircuitsMatroid(Matroid):

# properties
cpdef girth(self)
cpdef bint is_paving(self)
cpdef bint is_paving(self) noexcept

# isomorphism and relabeling
cpdef _is_isomorphic(self, other, certificate=*)
cpdef relabel(self, mapping)

# verification
cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept
Loading
Loading