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

Commit

Permalink
Trac 33624: fix doctest when sage scripts are not in SAGE_VENV/bin
Browse files Browse the repository at this point in the history
We don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
be the full path to `sage-ipython` and the same directory should also
have `sage`.

For a normal install, `os.path.dirname(sys.argv[0])` should be the same
as `SAGE_VENV/bin`.

For installs where the `sys.prefix` contains system python packages but
NOT the sagelib or the sage scripts, using `sys.argv[0]` should be ok
but using `SAGE_VENV/bin` fails this particular doctest.

This commit doesn't change any functionality, only a doctest.
  • Loading branch information
tornaria committed Apr 1, 2022
1 parent 43474c9 commit 6ec4ee7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/sage/misc/sage_ostools.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ def have_program(program, path=None):
True
sage: have_program('there_is_not_a_program_with_this_name')
False
sage: from sage.env import SAGE_VENV
sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
sage: have_program('sage', os.path.dirname(sys.argv[0]))
True
sage: have_program('sage', '/there_is_not_a_path_with_this_name')
False
sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
sage: have_program('there_is_not_a_program_with_this_name', "/bin")
False
"""
if path is None:
Expand Down

0 comments on commit 6ec4ee7

Please sign in to comment.