Skip to content

Commit 6704b34

Browse files
author
Matthias Koeppe
committed
Merge branch 'sage-b-use-make' into remove_patchbot
2 parents 1ae0c4a + 30009fa commit 6704b34

File tree

2 files changed

+45
-47
lines changed

2 files changed

+45
-47
lines changed

src/bin/sage

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ if [ "$1" = '--nodotsage' ]; then
193193
exit $status
194194
fi
195195

196+
# build_sage, sage -b, sage -br, etc. could also be moved to
197+
# build/bin/sage-site. See #29111; but OTOH #34627.
198+
199+
build_sage() {
200+
( cd "$SAGE_ROOT" && make sagelib-no-deps ) || exit $?
201+
}
202+
196203
# Check for '-i' etc. before sourcing sage-env: running "make"
197204
# should be run outside of the Sage shell.
198205
case "$1" in
@@ -206,6 +213,28 @@ case "$1" in
206213
echo >&2 "Error: unknown option: $1"
207214
exit 1
208215
;;
216+
-b)
217+
build_sage
218+
exit 0
219+
;;
220+
-br|--br)
221+
build_sage
222+
shift; set -- -r "$@" # delegate to handling of "-r" below, after sourcing sage-env
223+
;;
224+
-bn|--build-and-notebook)
225+
build_sage
226+
shift; set -- -n "$@" # delegate to handling of "-n" below, after sourcing sage-env
227+
;;
228+
-ba)
229+
( cd "$SAGE_ROOT" && make sagelib-clean )
230+
build_sage
231+
exit 0
232+
;;
233+
-bt*)
234+
build_sage
235+
switch_without_b=-${1#-b}
236+
shift; set -- $switch_without_b "$@" # delegate to handling of "-t...." below, after sourcing sage-env
237+
;;
209238
esac
210239

211240
#####################################################################
@@ -264,7 +293,7 @@ sage_setup() {
264293
echo >&2 '************************************************************************'
265294
echo >&2 'It seems that you are attempting to run Sage from an unpacked source'
266295
echo >&2 'tarball, but you have not compiled it yet (or maybe the build has not'
267-
echo >&2 'finished). You should run `make` in the Sage root directory first.'
296+
echo >&2 'finished). You should run `make` in the SAGE_ROOT directory first.'
268297
echo >&2 'If you did not intend to build Sage from source, you should download'
269298
echo >&2 'a binary tarball instead. Read README.txt for more information.'
270299
echo >&2 '************************************************************************'
@@ -842,12 +871,6 @@ fi
842871
# The notebook, grep, building Sage, testing Sage
843872
#####################################################################
844873

845-
# build_sage, sage -b, sage -br, etc. could be moved to
846-
# build/bin/sage-site. See #29111.
847-
848-
build_sage() {
849-
( cd "$SAGE_ROOT/build/make" && ./install sagelib-no-deps ) || exit $?
850-
}
851874

852875
if [[ "$1" =~ ^--notebook=.* || "$1" =~ ^-n=.* || "$1" =~ ^-notebook=.* ]] ; then
853876
sage-cleaner &>/dev/null &
@@ -882,47 +905,19 @@ if [ -n "$SAGE_SRC" -a -d "$SAGE_SRC" ]; then
882905
fi
883906
fi
884907

885-
if [ "$1" = '-b' ]; then
886-
build_sage
887-
exit $?
888-
fi
889-
890-
if [ "$1" = '-br' -o "$1" = "--br" ]; then
891-
build_sage
892-
interactive_sage
893-
fi
894-
895908
if [ "$1" = '-r' ]; then
896909
shift
897910
interactive_sage
898911
fi
899912

900-
if [ "$1" = '-ba-force' -o "$1" = '--ba-force' ]; then
901-
echo
902-
echo "WARNING: 'sage --ba-force' is deprecated; use 'sage -ba' instead."
903-
echo
904-
( cd "$SAGE_ROOT/build/make" && make sagelib-clean )
905-
build_sage
906-
exit $?
907-
fi
908-
909-
if [ "$1" = '-ba' ]; then
910-
( cd "$SAGE_ROOT/build/make" && make sagelib-clean )
911-
build_sage
912-
exit $?
913-
fi
914-
915913
exec-runtests() {
916914
sage_setup
917915
export PYTHONIOENCODING="utf-8" # Fix encoding for doctests
918916
exec sage-runtests "$@"
919917
}
920918

921-
if [ "$1" = '-t' -o "$1" = '-bt' -o "$1" = '-tp' -o "$1" = '-btp' ]; then
922-
if [ "$1" = '-bt' -o "$1" = '-btp' ]; then
923-
build_sage
924-
fi
925-
if [ "$1" = '-tp' -o "$1" = '-btp' ]; then
919+
if [ "$1" = '-t' -o "$1" = '-tp' ]; then
920+
if [ "$1" = '-tp' ]; then
926921
shift
927922
exec-runtests -p "$@"
928923
else
@@ -931,10 +926,7 @@ if [ "$1" = '-t' -o "$1" = '-bt' -o "$1" = '-tp' -o "$1" = '-btp' ]; then
931926
fi
932927
fi
933928

934-
if [ "$1" = '-tnew' -o "$1" = '-btnew' ]; then
935-
if [ "$1" = '-btnew' ]; then
936-
build_sage
937-
fi
929+
if [ "$1" = '-tnew' ]; then
938930
shift
939931
exec-runtests --new "$@"
940932
fi

src/setup.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@
8585
from sage_setup.autogen import autogen_all
8686
autogen_all()
8787

88-
log.info("Discovering Python/Cython source code....")
89-
t = time.time()
88+
log.info("Discovering Python/Cython source code...")
9089

9190
# Exclude a few files if the corresponding distribution is not loaded
9291
optional_packages = ['mcqd', 'bliss', 'tdlib',
@@ -103,13 +102,19 @@
103102
python_packages = find_namespace_packages(where=SAGE_SRC, include=['sage', 'sage.*'])
104103
log.debug(f"python_packages = {python_packages}")
105104

106-
log.info(f"Discovered Python/Cython sources, time: {(time.time() - t):.2f} seconds.")
105+
log.info(f"Discovering Python/Cython source code... done")
107106

108107
# from sage_build_cython:
109108
import Cython.Compiler.Options
110109
Cython.Compiler.Options.embed_pos_in_docstring = True
111110
gdb_debug = os.environ.get('SAGE_DEBUG', None) != 'no'
112111

112+
aliases = cython_aliases()
113+
log.debug(f"aliases = {aliases}")
114+
include_path = sage_include_directories(use_sources=True) + ['.']
115+
log.debug(f"include_path = {include_path}")
116+
nthreads = sage_build_ext_minimal.get_default_number_build_jobs()
117+
log.info(f"Cythonizing with {nthreads} threads...")
113118
try:
114119
from Cython.Build import cythonize
115120
from sage.env import cython_aliases, sage_include_directories
@@ -118,16 +123,17 @@
118123
extensions = cythonize(
119124
["sage/**/*.pyx"],
120125
exclude=files_to_exclude,
121-
include_path=sage_include_directories(use_sources=True) + ['.'],
126+
include_path=include_path,
122127
compile_time_env=compile_time_env_variables(),
123128
compiler_directives=compiler_directives(False),
124-
aliases=cython_aliases(),
129+
aliases=aliases,
125130
create_extension=create_extension,
126131
gdb_debug=gdb_debug,
127-
nthreads=4)
132+
nthreads=nthreads)
128133
except Exception as exception:
129134
log.warn(f"Exception while cythonizing source files: {repr(exception)}")
130135
raise
136+
log.info(f"Cythonizing with {nthreads} threads... done")
131137

132138
# ########################################################
133139
# ## Distutils

0 commit comments

Comments
 (0)