Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge #33851
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed May 14, 2022
2 parents c5295e3 + 0df31a9 commit 8d7f7ab
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 86 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/ci-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ jobs:
bash ~/miniconda.sh -b -p $HOME/miniconda
echo "CONDA=$HOME/miniconda" >> $GITHUB_ENV
- name: Install bootstrap prerequisites
run: |
export PATH="$(pwd)/build/bin:$PATH"
SYSTEM=$(sage-guess-package-system)
eval $(sage-print-system-package-command $SYSTEM --sudo install $(sage-get-system-packages $SYSTEM _bootstrap))
# Create conda environment file
- name: Bootstrap
run: ./bootstrap
- name: Create conda environment files
run: ./bootstrap-conda

- name: Cache conda packages
uses: actions/cache@v2
Expand Down Expand Up @@ -80,6 +73,7 @@ jobs:
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 $(for pkg in $(./sage -package list :standard: --has-file spkg-configure.m4 --has-file distros/conda.txt); do echo --with-system-$pkg=force; done)
echo "::remove-matcher owner=configure-system-package-warning::"
Expand All @@ -88,8 +82,8 @@ jobs:
- name: Build
shell: bash -l {0}
run: |
pip install --no-build-isolation -v -v -e pkgs/sage-conf pkgs/sage-setup
pip install --no-build-isolation -v -v -e src
pip install --no-build-isolation -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup
pip install --no-build-isolation -v -v -e ./src
env:
SAGE_NUM_THREADS: 2

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/environment.yml
/environment-optional.yml
/src/environment.yml
/src/environment-dev.yml
/src/environment-optional.yml

/src/setup.cfg
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
],
"python.testing.unittestEnabled": false,
"cSpell.words": [
"Conda",
"Cython",
"sagemath"
],
}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ bootstrap-clean:
rm -f src/doc/en/reference/repl/*.txt
rm -f environment.yml
rm -f src/environment.yml
rm -f src/environment-dev.yml
rm -f environment-optional.yml
rm -f src/environment-optional.yml
rm -f src/Pipfile
Expand Down
1 change: 1 addition & 0 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ SAGE_SPKG_FINALIZE([$pkgname], [$pkgtype], [$SPKG_SOURCE], [$SPKG_TREE_VAR])"
# ONLY stderr, and to re-output the results back to stderr leaving
# stdout alone. Basically we swap the two descriptors using a
# third, filter, and then swap them back.
./bootstrap-conda && \
src/doc/bootstrap && \
install_config_rpath && \
aclocal -I m4 && \
Expand Down
95 changes: 95 additions & 0 deletions bootstrap-conda
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env bash

########################################################################
# Generate auto-generated conda environment files
#########################################################################

STRIP_COMMENTS="sed s/#.*//;"

shopt -s extglob

DEVELOP_SPKG_PATTERN="@(_develop$(for a in $(head -n 1 build/pkgs/_develop/dependencies); do echo -n "|"$a; done))"

BOOTSTRAP_PACKAGES=$(echo $(${STRIP_COMMENTS} build/pkgs/_bootstrap/distros/conda.txt))
SYSTEM_PACKAGES=
OPTIONAL_SYSTEM_PACKAGES=
SAGELIB_SYSTEM_PACKAGES=
SAGELIB_OPTIONAL_SYSTEM_PACKAGES=
DEVELOP_SYSTEM_PACKAGES=
for PKG_BASE in $(./sage --package list --has-file distros/conda.txt); do
PKG_SCRIPTS=build/pkgs/$PKG_BASE
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/distros/conda.txt
PKG_TYPE=$(cat $PKG_SCRIPTS/type)
PKG_SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE))
if [ -n "PKG_SYSTEM_PACKAGES" ]; then
if [ -f $PKG_SCRIPTS/spkg-configure.m4 ]; then
case "$PKG_BASE:$PKG_TYPE" in
*:standard)
SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
;;
$DEVELOP_SPKG_PATTERN:*)
DEVELOP_SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
;;
*)
OPTIONAL_SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
;;
esac
else
case "$PKG_TYPE" in
standard)
SAGELIB_SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
;;
*)
SAGELIB_OPTIONAL_SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
;;
esac
fi
fi
done
echo >&2 $0:$LINENO: generate conda enviroment files
(
echo "name: sage-build"
echo "channels:"
echo " - conda-forge"
echo " - nodefaults"
echo "dependencies:"
for pkg in $SYSTEM_PACKAGES; do
echo " - $pkg"
done
echo " # Packages needed for ./bootstrap"
for pkg in $BOOTSTRAP_PACKAGES; do
echo " - $pkg"
done
) > environment.yml

(
sed 's/name: sage-build/name: sage/' environment.yml
echo " # Additional packages providing all dependencies for the Sage library"
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment.yml

(
sed 's/name: sage/name: sage-dev/' src/environment.yml
echo " # Additional dev tools"
for pkg in $DEVELOP_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-dev.yml

(
cat environment.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > environment-optional.yml

(
cat src/environment.yml
echo " # optional packages"
for pkg in $OPTIONAL_SYSTEM_PACKAGES $SAGELIB_OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg"
done
) > src/environment-optional.yml
7 changes: 7 additions & 0 deletions build/pkgs/_develop/SPKG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\_develop: Represents system packages recommended for development
=================================================================

Description
-----------

Script package representing a list of system packages recommended for developers.
1 change: 1 addition & 0 deletions build/pkgs/_develop/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git pytest pytest_xdist
2 changes: 2 additions & 0 deletions build/pkgs/_develop/distros/conda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openssh
pycodestyle
3 changes: 3 additions & 0 deletions build/pkgs/_develop/distros/debian.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Needed for devcontainer support in VS code
gpgconf
openssh-client
3 changes: 3 additions & 0 deletions build/pkgs/_develop/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([_develop], [
sage_spkg_install__develop=yes
])
2 changes: 2 additions & 0 deletions build/pkgs/_develop/spkg-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#! /usr/bin/env bash
# Nothing to do
1 change: 1 addition & 0 deletions build/pkgs/_develop/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional
1 change: 1 addition & 0 deletions build/pkgs/jupyter_sphinx/distros/conda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jupyter_sphinx
2 changes: 1 addition & 1 deletion build/pkgs/pytest/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(PYTHON) pluggy packaging attrs py pyparsing importlib_metadata | $(PYTHON_TOOLCHAIN)
$(PYTHON) pluggy packaging attrs py pyparsing importlib_metadata tomli | $(PYTHON_TOOLCHAIN)

----------
All lines of this file are ignored except the first.
18 changes: 18 additions & 0 deletions build/pkgs/pytest_xdist/SPKG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pytest_xdist: pytest xdist plugin for distributed testing and loop-on-failing modes
===================================================================================

Description
-----------

pytest xdist plugin for distributed testing and loop-on-failing modes

License
-------

MIT

Upstream Contact
----------------

https://pypi.org/project/pytest-xdist/

4 changes: 4 additions & 0 deletions build/pkgs/pytest_xdist/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$(PYTHON) pytest | $(PYTHON_TOOLCHAIN)

----------
All lines of this file are ignored except the first.
1 change: 1 addition & 0 deletions build/pkgs/pytest_xdist/distros/conda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest-xdist
1 change: 1 addition & 0 deletions build/pkgs/pytest_xdist/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest-xdist
1 change: 1 addition & 0 deletions build/pkgs/pytest_xdist/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional
41 changes: 7 additions & 34 deletions src/doc/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ shopt -s extglob

RECOMMENDED_SPKG_PATTERN="@(_recommended$(for a in $(head -n 1 build/pkgs/_recommended/dependencies); do echo -n "|"$a; done))"

for SYSTEM in arch debian fedora cygwin homebrew conda; do
for SYSTEM in arch debian fedora cygwin homebrew; do
SYSTEM_PACKAGES=
OPTIONAL_SYSTEM_PACKAGES=
SAGELIB_SYSTEM_PACKAGES=
Expand Down Expand Up @@ -63,40 +63,13 @@ for SYSTEM in arch debian fedora cygwin homebrew conda; do
fi
fi
done
if [ "${SYSTEM}" = "conda" ]; then
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
echo >&2 $0:$LINENO: installing environment.yml, environment-optional.yml, src/environment.yml and src/environment-optional.yml
fi
echo "name: sage-build" > environment.yml
echo "channels:" >> environment.yml
echo " - conda-forge" >> environment.yml
echo " - nodefaults" >> environment.yml
echo "dependencies:" >> environment.yml
for pkg in $SYSTEM_PACKAGES; do
echo " - $pkg" >> environment.yml
done
sed 's/name: sage-build/name: sage/' environment.yml > src/environment.yml
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
echo " - $pkg" >> src/environment.yml
done
cp environment.yml environment-optional.yml
echo " # optional packages" >> environment-optional.yml
for pkg in $OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg" >> environment-optional.yml
done
cp src/environment.yml src/environment-optional.yml
echo " # optional packages" >> src/environment-optional.yml
for pkg in $OPTIONAL_SYSTEM_PACKAGES $SAGELIB_OPTIONAL_SYSTEM_PACKAGES; do
echo " - $pkg" >> src/environment-optional.yml
done
else
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
echo >&2 $0:$LINENO: installing "$OUTPUT_DIR"/$SYSTEM"*.txt"
fi
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM.txt
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $RECOMMENDED_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-recommended.txt

if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
echo >&2 $0:$LINENO: installing "$OUTPUT_DIR"/$SYSTEM"*.txt"
fi
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM.txt
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $RECOMMENDED_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-recommended.txt
done

OUTPUT_DIR="src/doc/en/reference/spkg"
Expand Down
9 changes: 7 additions & 2 deletions src/doc/en/developer/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,18 @@ package :mod:`sage.numerical.backends` and some modules in

*Installation:*

- ``./sage -i pytest``.
- ``./sage -i pytest pytest_xdist``.

*Usage:*

- Tox, Sage doctester: At the end of ``./sage -t`` (or ``./sage --tox -e doctest``), Pytest is automatically invoked.

- Manual: Run ``./sage -pytest path/to/the/test_file.py`` or ``./sage -pytest`` to run all tests.
- Manual: Run ``./sage -pytest path/to/the/test_file.py`` or ``./sage -pytest``
to run all tests. The additional argument ``-n`` can be used to
distribute tests across multiple CPUs to speed up test execution.
For example, ``./sage -pytest -n 4`` will run 4 tests in parallel, while
``./sage -pytest -n auto`` will spawn a number of workers processes equal
to the number of available CPUs.

- VS Code: Install the `Python extension <https://marketplace.visualstudio.com/items?itemName=ms-python.python>`_ and follow the `offical VS Code documentation <https://code.visualstudio.com/docs/python/testing>`__.

Expand Down
Loading

0 comments on commit 8d7f7ab

Please sign in to comment.