Skip to content

Commit 4e7f615

Browse files
committed
Merge branch 'u/dkrenn/sequences/rec-hash' into u/dkrenn/sequences/k-regular-guess
* u/dkrenn/sequences/rec-hash: (8211 commits) Updated SageMath version to 8.7 Updated SageMath version to 8.7.rc0 Trac #27490: Moved the alternate build_many implementation into a sage_setup.docbuild.utils module. Trac #27490: Further fixes in use of os.wait() Trac #27214: Patch GAP to allocate its memory pool using MAP_NORESERVE on Cygwin Trac #27490: Address some review comments and other cleanup: A little bit of import cleanup Trac #27490: Simplistic multiprocessing.Pool replacement for parallel docbuild on older Cygwin Fix alarm() test when cysignals was compiled with debugging Trac #27485: Use sdh_cmake in the spkg-install for primecount. Trac #27484: Add shd_cmake helper for running cmake with the correct flags for building Sage SPKGs. cysignals should be a normal dependency Upgrade to Cysignals 1.10.2 Upgrade to notebook-5.7.6 Trac #27461: Add abs tol on this test to account for minor numerical difference on Cygwin due to libm differences. Replacing None < infinity comparison with equivalent code. Some last little tidbits for uniformity. Removing some code duplication for __pth_root (changed to _pth_root_func). One more xderinv added. trac 27474: move some references to the master bibliography file. ...
2 parents 622c3f6 + a87520e commit 4e7f615

File tree

3,483 files changed

+299008
-128611
lines changed

Some content is hidden

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

3,483 files changed

+299008
-128611
lines changed

.ci/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Continuous Integration (CI)
2+
3+
We support several implementations of CI. All these implementations rely on
4+
[docker](https://docker.com) in some way. This directory contains bits which
5+
are shared between these CI implementations. The relevant docker files can be
6+
found in `/docker/`.
7+
8+
* [CircleCI](https://circleci.com) is configured in `/.circleci/`.
9+
* [GitLab CI](https://gitlab.com) is configured in `/.gitlab-ci.yml`.

.ci/build-docker.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
# This script gets called from CI to build several flavours of docker images
4+
# which contain Sage.
5+
6+
# ****************************************************************************
7+
# Copyright (C) 2018 Julian Rüth <[email protected]>
8+
#
9+
# This program is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation, either version 2 of the License, or
12+
# (at your option) any later version.
13+
# http://www.gnu.org/licenses/
14+
# ****************************************************************************
15+
16+
set -ex
17+
18+
# We speed up the build process by copying built artifacts from ARTIFACT_BASE
19+
# during docker build. See /docker/Dockerfile for more details.
20+
ARTIFACT_BASE=${ARTIFACT_BASE:-sagemath/sagemath-dev:develop}
21+
22+
# Seed our cache with $ARTIFACT_BASE if it exists.
23+
docker pull "$ARTIFACT_BASE" > /dev/null || true
24+
25+
docker_build() {
26+
# Docker's --cache-from does not really work with multi-stage builds: https://github.com/moby/moby/issues/34715
27+
# So we just have to rely on the local cache.
28+
time docker build -f docker/Dockerfile \
29+
--build-arg "MAKEOPTS=${MAKEOPTS}" --build-arg "SAGE_NUM_THREADS=${SAGE_NUM_THREADS}" --build-arg "MAKEOPTS_DOCBUILD=${MAKEOPTS}" --build-arg "SAGE_NUM_THREADS_DOCBUILD=${SAGE_NUM_THREADS_DOCBUILD}" --build-arg ARTIFACT_BASE=$ARTIFACT_BASE $@
30+
}
31+
32+
# We use a multi-stage build /docker/Dockerfile. For the caching to be
33+
# effective, we populate the cache by building the run/build-time-dependencies
34+
# and the make-all target. (Just building the last target is not enough as
35+
# intermediate targets could be discarded from the cache [depending on the
36+
# docker version] and therefore the caching would fail for our actual builds
37+
# below.)
38+
docker_build --target run-time-dependencies --tag run-time-dependencies:$DOCKER_TAG .
39+
docker_build --target build-time-dependencies --tag build-time-dependencies:$DOCKER_TAG .
40+
docker_build --target make-all --tag make-all:$DOCKER_TAG .
41+
42+
# Build the release image without build artifacts.
43+
docker_build --target sagemath --tag "$DOCKER_IMAGE_CLI" .
44+
# Display the layers of this image
45+
docker history "$DOCKER_IMAGE_CLI"
46+
# Build the developer image with the build artifacts intact.
47+
# Note: It's important to build the dev image last because it might be tagged as ARTIFACT_BASE.
48+
docker_build --target sagemath-dev --tag "$DOCKER_IMAGE_DEV" .
49+
# Display the layers of this image
50+
docker history "$DOCKER_IMAGE_DEV"

.ci/describe-system.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
# ****************************************************************************
4+
# Copyright (C) 2018 Julian Rüth <[email protected]>
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 2 of the License, or
9+
# (at your option) any later version.
10+
# http://www.gnu.org/licenses/
11+
# ****************************************************************************
12+
13+
set +e -x
14+
15+
docker info
16+
docker run docker sh -c "
17+
set -x
18+
uname -a
19+
df -h
20+
cat /proc/cpuinfo
21+
cat /proc/meminfo
22+
cat /proc/sys/vm/overcommit_memory
23+
cat /proc/sys/vm/overcommit_ratio"

.ci/head-tail.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
OFFSET=1024
4+
# This script reads from stdin and prints to stdout as long as a the output
5+
# does not exceed a certain number of bytes. When reading an EOF it prints the
6+
# last $OFFSET lines if they have not been printed normally already.
7+
# This script expects one argument, the number of bytes.
8+
9+
# Heavily inspired by a simlar strategy in make, https://stackoverflow.com/a/44849696/812379.
10+
11+
# ****************************************************************************
12+
# Copyright (C) 2018 Julian Rüth <[email protected]>
13+
#
14+
# This program is free software: you can redistribute it and/or modify
15+
# it under the terms of the GNU General Public License as published by
16+
# the Free Software Foundation, either version 2 of the License, or
17+
# (at your option) any later version.
18+
# http://www.gnu.org/licenses/
19+
# ****************************************************************************
20+
21+
stdbuf -i0 -o0 -e0 awk -v limit=$1 -v firstMissingNR=-1 -v offset=$OFFSET -v bytes=0 \
22+
'{
23+
if (bytes < limit) {
24+
# this probably gets multi-byte characters wrong, but that probably does
25+
# not matter for our purposes. (We add 1 for a UNIX newline.)
26+
bytes += length($0) + 1;
27+
print;
28+
} else {
29+
if (firstMissingNR == -1){
30+
print "[…output truncated…]";
31+
firstMissingNR = NR;
32+
}
33+
a[NR] = $0;
34+
delete a[NR-offset];
35+
printf "." > "/dev/stderr"
36+
}
37+
}
38+
END {
39+
if (firstMissingNR != -1) {
40+
print "" > "/dev/stderr";
41+
for(i = NR-offset+1 > firstMissingNR ? NR-offset-1 : firstMissingNR; i<=NR ; i++){ print a[i]; }
42+
}
43+
}
44+
'
45+

.ci/protect-secrets.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
3+
# This script protects all environment variables that start with "SECRET_".
4+
# It puts them in a temporary file. The name of the variable contains the path
5+
# of that file. This filename can then safely be used in `cat` even if `set
6+
# -x` has been turned on. Also you can run "export" to understand the
7+
# environment without danger.
8+
# Be careful, however, not to use this like the following:
9+
# docker login $DOCKER_USER $(cat $SECRET_DOCKER_PASS)
10+
# as this would expose the password if `set -x` has been turned on.
11+
12+
# ****************************************************************************
13+
# Copyright (C) 2018 Julian Rüth <[email protected]>
14+
#
15+
# This program is free software: you can redistribute it and/or modify
16+
# it under the terms of the GNU General Public License as published by
17+
# the Free Software Foundation, either version 2 of the License, or
18+
# (at your option) any later version.
19+
# http://www.gnu.org/licenses/
20+
# ****************************************************************************
21+
22+
set -eo pipefail
23+
set +x
24+
25+
function encrypt {
26+
RET=`mktemp`
27+
eval " echo \$$1" > "$RET"
28+
echo $RET
29+
}
30+
31+
for name in `awk 'END { for (name in ENVIRON) { print name; } }' < /dev/null`; do
32+
case "$name" in
33+
SECRET_*)
34+
export $name="$(encrypt $name)"
35+
echo "Protected $name"
36+
;;
37+
esac
38+
done
39+
40+
unset encrypt

.ci/pull-gitlab.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# This script gets called from CI to pull the Sage docker images that were
4+
# built during the "build" phase to pull all the connected docker daemon
5+
# (likely a docker-in-docker.)
6+
# This script expects a single parameter, the base name of the docker image
7+
# such as sagemath or sagemath-dev.
8+
# The variable $DOCKER_IMAGE is set to the full name of the pulled image;
9+
# source this script to use it.
10+
11+
# ****************************************************************************
12+
# Copyright (C) 2018 Julian Rüth <[email protected]>
13+
#
14+
# This program is free software: you can redistribute it and/or modify
15+
# it under the terms of the GNU General Public License as published by
16+
# the Free Software Foundation, either version 2 of the License, or
17+
# (at your option) any later version.
18+
# http://www.gnu.org/licenses/
19+
# ****************************************************************************
20+
21+
set -ex
22+
23+
# Pull the built images from the gitlab registry and give them the original
24+
# names they had after built.
25+
# Note that "set -x" prints the $CI_BUILD_TOKEN here but GitLab removes it
26+
# automatically from the log output.
27+
docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
28+
docker pull $CI_REGISTRY_IMAGE/$1:$DOCKER_TAG
29+
export DOCKER_IMAGE="${DOCKER_NAMESPACE:-sagemath}/$1:$DOCKER_TAG"
30+
docker tag $CI_REGISTRY_IMAGE/$1:$DOCKER_TAG $DOCKER_IMAGE

.ci/push-dockerhub.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
# This script gets called from CI to push our docker images to
4+
# $DOCKER_NAMESPACE/sagemath* on the Docker Hub.
5+
# This script expects a single parameter, the base name of the docker image
6+
# such as sagemath or sagemath-dev.
7+
8+
# ****************************************************************************
9+
# Copyright (C) 2018 Julian Rüth <[email protected]>
10+
#
11+
# This program is free software: you can redistribute it and/or modify
12+
# it under the terms of the GNU General Public License as published by
13+
# the Free Software Foundation, either version 2 of the License, or
14+
# (at your option) any later version.
15+
# http://www.gnu.org/licenses/
16+
# ****************************************************************************
17+
18+
set -ex
19+
20+
[ -z "$DOCKER_TAG" ] && (echo "Can not push untagged build."; exit 0)
21+
22+
# Push the built images to the docker hub (and fail silently if
23+
# DOCKER_USER/SECRET_DOCKER_PASS have not been configured.)
24+
if [ -z "$DOCKER_USER" -o -z "$SECRET_DOCKER_PASS" ]; then
25+
echo "DOCKER_USER/SECRET_DOCKER_PASS variables have not been configured in your Continuous Integration setup. Not pushing built images to Docker Hub."
26+
else
27+
cat "$SECRET_DOCKER_PASS" | docker login -u $DOCKER_USER --password-stdin
28+
docker push ${DOCKER_NAMESPACE:-sagemath}/$1:$DOCKER_TAG
29+
fi

.ci/push-gitlab.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
# This script gets called from CI to push our docker images to registry
4+
# configured in GitLab. (Mostly, so we can pull them again to push them to the
5+
# Docker Hub.)
6+
# This script expects a single parameter, the base name of the docker image
7+
# such as sagemath or sagemath-dev.
8+
9+
# ****************************************************************************
10+
# Copyright (C) 2018 Julian Rüth <[email protected]>
11+
#
12+
# This program is free software: you can redistribute it and/or modify
13+
# it under the terms of the GNU General Public License as published by
14+
# the Free Software Foundation, either version 2 of the License, or
15+
# (at your option) any later version.
16+
# http://www.gnu.org/licenses/
17+
# ****************************************************************************
18+
19+
set -ex
20+
21+
# Note that "set -x" prints the $CI_BUILD_TOKEN here but GitLab removes it
22+
# automatically from the log output.
23+
docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
24+
docker tag ${DOCKER_NAMESPACE:-sagemath}/$1:$DOCKER_TAG $CI_REGISTRY_IMAGE/$1:$DOCKER_TAG
25+
docker push $CI_REGISTRY_IMAGE/$1:$DOCKER_TAG

.ci/setup-make-parallelity.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
3+
# Source this to set CPUTHREADS (the number of apparent cores) and RAMTHREADS
4+
# (free RAM divided by the maximum amount needed per thread typically)
5+
# From this this script infers reasonable defaults for SAGE_NUM_THREADS and
6+
# MAKEOPTS.
7+
8+
# We do exactly the same for CPUTHREADS_DOCBUILD, RAMTHREADS_DOCBUILD,
9+
# SAGE_NUM_THREADS_DOCBUILD, MAKEOPTS_DOCBUILD. As the docbuild needs
10+
# substantially more RAM as of May 2018.
11+
12+
# ****************************************************************************
13+
# Copyright (C) 2018 Julian Rüth <[email protected]>
14+
#
15+
# This program is free software: you can redistribute it and/or modify
16+
# it under the terms of the GNU General Public License as published by
17+
# the Free Software Foundation, either version 2 of the License, or
18+
# (at your option) any later version.
19+
# http://www.gnu.org/licenses/
20+
# ****************************************************************************
21+
22+
set -ex
23+
24+
if [ -z "$CPUTHREADS" ]; then
25+
# Determine the number of threads that can run simultaneously on this system
26+
# (we might not have nproc available.)
27+
# Note that this value is incorrect for some CI providers (notably CircleCI:
28+
# https://circleci.com/docs/2.0/configuration-reference/#resource_class) which
29+
# provision fewer vCPUs than shown in /proc/cpuinfo. So it is probably better
30+
# to set CPUTHREADS manuall in your CI configuration.
31+
CPUTHREADS=`docker run docker cat /proc/cpuinfo | grep -E '^processor' | wc -l`
32+
fi
33+
if [ -z "$CPUTHREADS_DOCBUILD" ]; then
34+
CPUTHREADS_DOCBUILD=$CPUTHREADS
35+
fi
36+
37+
if [ -z "$RAMTHREADS" ]; then
38+
RAMTHREADS=$(( `docker run docker cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'` / 1048576 ))
39+
if [ $RAMTHREADS = 0 ];then
40+
RAMTHREADS=1;
41+
fi
42+
fi
43+
if [ -z "$RAMTHREADS_DOCBUILD" ]; then
44+
RAMTHREADS_DOCBUILD=$(( `docker run docker cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'` / 2097152 ))
45+
if [ $RAMTHREADS_DOCBUILD = 0 ];then
46+
RAMTHREADS_DOCBUILD=1;
47+
fi
48+
fi
49+
50+
# On CI machines with their virtual CPUs, it seems to be quite beneficial to
51+
# overcommit on CPU usage. We only need to make sure that we do not exceed RAM
52+
# (as there is no swap.)
53+
if [ $CPUTHREADS -lt $RAMTHREADS ]; then
54+
export SAGE_NUM_THREADS=$((CPUTHREADS + 1))
55+
else
56+
export SAGE_NUM_THREADS=$RAMTHREADS
57+
fi
58+
if [ $CPUTHREADS_DOCBUILD -lt $RAMTHREADS_DOCBUILD ]; then
59+
export SAGE_NUM_THREADS_DOCBUILD=$((CPUTHREADS_DOCBUILD + 1))
60+
else
61+
export SAGE_NUM_THREADS_DOCBUILD=$RAMTHREADS_DOCBUILD
62+
fi
63+
# Set -j and -l for make (though -l is probably ignored by Sage)
64+
export MAKEOPTS="-j $SAGE_NUM_THREADS -l $((CPUTHREADS - 1)).8"
65+
export MAKEOPTS_DOCBUILD="-j $SAGE_NUM_THREADS_DOCBUILD -l $((CPUTHREADS_DOCBUILD - 1)).8"

.ci/test-cli.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# This script gets called from CI to run minimal tests on the sagemath image.
4+
5+
# Usage: ./test-cli.sh IMAGE-NAME
6+
7+
# ****************************************************************************
8+
# Copyright (C) 2018 Julian Rüth <[email protected]>
9+
#
10+
# This program is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation, either version 2 of the License, or
13+
# (at your option) any later version.
14+
# http://www.gnu.org/licenses/
15+
# ****************************************************************************
16+
17+
set -ex
18+
19+
echo "Checking that Sage starts and can calculate 1+1…"
20+
# Calculate 1+1 (remove startup messages and leading & trailing whitespace)
21+
TWO=`docker run "$1" sage -c "'print(1+1)'" | tail -1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'`
22+
[ "x$TWO" = "x2" ]
23+
24+
echo "Checking that some binaries that should be distributed with Sage are on the PATH…"
25+
# We could also run minimal tests on these but we don't yet.
26+
# Check that Singular and GAP are present
27+
docker run "$1" which Singular
28+
docker run "$1" which gap
29+
# Check that jupyter is present (for binder)
30+
docker run "$1" which jupyter

0 commit comments

Comments
 (0)