Skip to content

Commit 24e9c9b

Browse files
author
Release Manager
committed
gh-40490: Replace 'sage-python' with 'python3' in various scripts for Meson <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> In a pure meson build there is no `sage-python`, so scripts declaring using `sage-python` are not working in this context. To remedy this, simply `python3` is used instead. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40490 Reported by: Tobias Diez Reviewer(s): Antonio Rojas, Dima Pasechnik
2 parents bf6be13 + c4f7b06 commit 24e9c9b

21 files changed

+48
-45
lines changed

src/bin/math-readline

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python3
22

33
# Cleverly run Mathematica with the benefit of readline, which
44
# is something the usual commercial mathematica doesn't provide!
55
# See
66
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/363500
77

8-
import sys
98
import signal
109
import subprocess
10+
import sys
11+
1112
from sage.cpython.string import str_to_bytes
1213

14+
1315
def child_exited(*args):
1416
global child
1517
status = child.poll()

src/bin/sage

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ fi
944944

945945
if [ "$1" = '-fixdistributions' -o "$1" = '--fixdistributions' ]; then
946946
shift
947-
exec sage-python -m sage.misc.package_dir "$@"
947+
exec python3 -m sage.misc.package_dir "$@"
948948
fi
949949

950950
if [ "$1" = '-tox' -o "$1" = '--tox' ]; then
@@ -1012,7 +1012,7 @@ if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then
10121012
# Redirect stdin from /dev/null. This helps with running TeX which
10131013
# tends to ask interactive questions if something goes wrong. These
10141014
# cause the build to hang. If stdin is /dev/null, TeX just aborts.
1015-
exec sage-python -m sage_docbuild "$@" </dev/null
1015+
exec python3 -m sage_docbuild "$@" </dev/null
10161016
fi
10171017

10181018
#####################################################################
@@ -1047,7 +1047,7 @@ if [ "$1" = '-gdb' -o "$1" = "--gdb" ]; then
10471047
gdb --eval-command "run" \
10481048
-args python "${SELF}-ipython" "$@" -i
10491049
else
1050-
sage_dir=$(sage-python -c 'import os, sage; print(os.path.dirname(sage.__file__))')
1050+
sage_dir=$(python3 -c 'import os, sage; print(os.path.dirname(sage.__file__))')
10511051
cygdb "$sage_dir" "$SAGE_SRC/sage" \
10521052
-- --eval-command "run" \
10531053
-args python "${SELF}-ipython" "$@" -i

src/bin/sage-cachegrind

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ else
2121
echo $CACHEGRIND_FLAGS
2222
fi
2323

24-
valgrind --tool=cachegrind $CACHEGRIND_FLAGS sage-python -i
24+
valgrind --tool=cachegrind $CACHEGRIND_FLAGS python3 -i
2525

src/bin/sage-cleaner

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python3
22

33
#*****************************************************************************
44
# This is the sage monitor *daemon*, which cleans up after Sage.
@@ -17,8 +17,14 @@
1717
#*****************************************************************************
1818

1919

20-
import os, shutil, sys, time, socket, errno, signal, atexit
21-
20+
import atexit
21+
import errno
22+
import os
23+
import shutil
24+
import signal
25+
import socket
26+
import sys
27+
import time
2228

2329
HOSTNAME = os.environ.get('HOSTNAME', socket.gethostname())
2430
DOT_SAGE = os.environ['DOT_SAGE']
@@ -30,6 +36,7 @@ pidfile = os.path.join(SAGE_TMP_ROOT, 'cleaner.pid')
3036
old_pidfile = os.path.join(DOT_SAGE, 'temp', 'cleaner-%s.pid'%HOSTNAME)
3137

3238
import logging
39+
3340
logger = logging.getLogger(__name__)
3441

3542

src/bin/sage-eval

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python3
22

33
import sys
4+
45
from sage.all import *
5-
from sage.calculus.predefined import x
6+
from sage.calculus.predefined import x # noqa: F401
67
from sage.repl.preparse import preparse
78

89
if len(sys.argv) > 1:

src/bin/sage-fixdoctests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python3
22
"""
33
Given the output of doctest and a file, adjust the doctests so they won't fail.
44

src/bin/sage-ipython

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
"""
44
Sage IPython startup script.
@@ -7,6 +7,7 @@ Sage IPython startup script.
77
# Display startup banner. Do this before anything else to give the user
88
# early feedback that Sage is starting.
99
from sage.misc.banner import banner
10+
1011
banner()
1112

1213
from sage.repl.interpreter import SageTerminalApp

src/bin/sage-list-packages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python3
22
r"""
33
Script to list the Sage packages
44

src/bin/sage-massif

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ else
2121
echo $MASSIF_FLAGS
2222
fi
2323

24-
valgrind --tool=massif $MASSIF_FLAGS sage-python -i
24+
valgrind --tool=massif $MASSIF_FLAGS python3 -i
2525

src/bin/sage-notebook

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8; mode: python -*-
33

4-
import os
5-
import sys
6-
import ast
74
import argparse
85
import logging
9-
import textwrap
6+
import os
7+
import sys
108
from contextlib import contextmanager
119

1210
logging.basicConfig()
1311
logger = logging.getLogger()
1412

1513
from sage.misc.banner import banner
1614

17-
1815
_system_jupyter_url = "https://doc.sagemath.org/html/en/installation/launching.html#setting-up-sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or-jupyterlab-installation"
1916

2017

@@ -188,7 +185,9 @@ def sage_doc_server():
188185
from functools import partial
189186
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
190187
from threading import Thread
191-
from sage.env import SAGE_DOC, SAGE_DOC_LOCAL_PORT as port
188+
189+
from sage.env import SAGE_DOC
190+
from sage.env import SAGE_DOC_LOCAL_PORT as port
192191

193192
server = ThreadingHTTPServer(('127.0.0.1', int(port)),
194193
partial(SimpleHTTPRequestHandler, directory=SAGE_DOC))

0 commit comments

Comments
 (0)