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

Commit 2f141c8

Browse files
committed
Trac #30128: always source sage-env-config before sage-env.
The sage-env script needs to know the values of SAGE_ROOT and SAGE_SCRIPTS_DIR, for example, but due to a chicken-and-egg problem it can't source the sage-env-config script where they are defined. Since whoever is sourcing sage-env perforce knows where it is located, this commit updates those callers to first source sage-env-config. This solves the inter-dependency, and does so in a POSIX-compatible way. A future commit will remove the bashism in sage-env that tries to determine the location of sage-env-config on its own.
1 parent 467fbc7 commit 2f141c8

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

bootstrap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ mkdir config 2>/dev/null
206206
# Get autotools from our own package into PATH (Trac #21214).
207207
# If Sage has not been built yet, this will fail due to a missing
208208
# sage-env-config. We just ignore that error.
209+
source src/bin/sage-env-config 2>/dev/null
209210
source src/bin/sage-env 2>/dev/null
210211

211212

build/bin/sage-spkg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ fi
166166
# The following sets environment variables for building packages.
167167
# Since this is sourced, it returns a non-zero value on errors rather
168168
# than exiting. Using dot suggested by W. Cheung.
169+
. sage-env-config
169170
. sage-env
170171

171172

@@ -490,7 +491,7 @@ export PKG_NAME="$PKG_NAME"
490491
export PKG_BASE="$PKG_BASE"
491492
export PKG_VER="$PKG_VER"
492493
493-
for lib in "\$SAGE_ROOT/build/bin/sage-dist-helpers" "\$SAGE_SRC/bin/sage-env" "\$SAGE_ROOT/build/bin/sage-build-env-config"; do
494+
for lib in "\$SAGE_ROOT/build/bin/sage-dist-helpers" "\$SAGE_SRC/bin/sage-env-config" "\$SAGE_SRC/bin/sage-env" "\$SAGE_ROOT/build/bin/sage-build-env-config"; do
494495
source "\$lib"
495496
if [ \$? -ne 0 ]; then
496497
echo >&2 "Error: failed to source \$lib"

build/make/Makefile.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,15 @@ endif
485485
#
486486
# $(INST)/<pkgname>-<pkgvers>: <dependencies>
487487
# $(AM_V_at)cd '$SAGE_ROOT' && \\
488+
# . '$SAGE_ROOT/src/bin/sage-env-config' && \\
488489
# . '$SAGE_ROOT/src/bin/sage-env' && \\
489490
# sage-logger -p '$SAGE_ROOT/build/pkgs/<pkgname>/spkg-install' '$(SAGE_LOGS)/<pkgname>.log'
490491
#
491492
# <pkgname>: $(INST)/<pkgname>-<pkgvers>
492493
#
493494
# <pkgname>-clean:
494495
# -$(AM_V_at)cd '$SAGE_ROOT' && \\
496+
# . '$SAGE_ROOT/src/bin/sage-env-config' && \\
495497
# . '$SAGE_ROOT/src/bin/sage-env' && \\
496498
# '$SAGE_ROOT/build/pkgs/$PKG_NAME/spkg-uninstall'
497499

@@ -504,15 +506,19 @@ $(1)-build-deps: $(3)
504506

505507
$$(INST)/$(1)-$(2): $(3)
506508
$(AM_V_at)cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \
507-
. '$$(SAGE_ROOT)/src/bin/sage-env' && . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \
509+
. '$$(SAGE_ROOT)/src/bin/sage-env-config' && \
510+
. '$$(SAGE_ROOT)/src/bin/sage-env' && \
511+
. '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \
508512
sage-logger -p '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' '$$(SAGE_LOGS)/$(1)-$(2).log'
509513
touch "$$@"
510514

511515
$(1): $$(INST)/$(1)-$(2)
512516

513517
$(1)-uninstall:
514518
-$(AM_V_at)cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \
515-
. '$$(SAGE_ROOT)/src/bin/sage-env' && . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \
519+
. '$$(SAGE_ROOT)/src/bin/sage-env-config' && \
520+
. '$$(SAGE_ROOT)/src/bin/sage-env' && \
521+
. '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \
516522
'$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-uninstall'
517523
-rm -f "$$(INST)/$(1)-$(2)"
518524

build/pkgs/gcc/spkg-configure.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ AC_DEFUN([SAGE_CHECK_BROKEN_GCC], [
4141
echo '#include <complex>' >conftest.cpp
4242
echo 'auto inf = 1.0 / std::complex<double>();' >>conftest.cpp
4343
44-
if ! bash -c "source '$SAGE_SRC/bin/sage-env' && g++ -O3 -c -o conftest.o conftest.cpp"; then
44+
if ! bash -c "source '$SAGE_SRC/bin/sage-env-config' && source '$SAGE_SRC/bin/sage-env' && g++ -O3 -c -o conftest.o conftest.cpp"; then
4545
SAGE_BROKEN_GCC=yes
4646
fi
4747
rm -f conftest.*

src/bin/sage

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ fi
196196
# append -env to that). We redirect stdout to stderr, which is safer
197197
# for scripts.
198198
#####################################################################
199-
if [ -f "$0-env" ]; then
199+
if [ -f "$0-env-config" ] && [ -f "$0-env" ]; then
200+
. "$0-env-config" >&2
200201
. "$0-env" >&2
201202
if [ $? -ne 0 ]; then
202203
echo >&2 "Error setting environment variables by sourcing '$0-env';"

src/mac-app/start-sage.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ NB_TYPE="$3"
1717

1818
# Read environment variables
1919
cd $(dirname $SAGE_EXECUTABLE)
20+
source local/bin/sage-env-config
2021
source local/bin/sage-env
2122

2223

0 commit comments

Comments
 (0)