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

Commit

Permalink
Merge #31296
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Mar 5, 2022
2 parents 5f33d4f + 9266709 commit 3566e53
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@

import os
import shutil
from pathlib import Path

from sage.env import SAGE_SHARE
from sage.env import SAGE_SHARE, SAGE_LOCAL, SAGE_VENV


class TrivialClasscallMetaClass(type):
Expand Down Expand Up @@ -517,6 +518,10 @@ class Executable(FileFeature):
r"""
A feature describing an executable in the ``PATH``.
In an installation of Sage with ``SAGE_LOCAL`` different from ``SAGE_VENV``, the
executable is searched first in ``SAGE_VENV/bin``, then in ``SAGE_LOCAL/bin``,
then in ``PATH``.
.. NOTE::
Overwrite :meth:`is_functional` if you also want to check whether
Expand Down Expand Up @@ -594,6 +599,16 @@ def absolute_filename(self) -> str:
sage.features.FeatureNotPresentError: does-not-exist is not available.
Executable 'does-not-exist-xxxxyxyyxyy' not found on PATH.
"""
if SAGE_LOCAL:
if Path(SAGE_VENV).resolve() != Path(SAGE_LOCAL).resolve():
# As sage.env currently gives SAGE_LOCAL a fallback value from SAGE_VENV,
# SAGE_LOCAL is never unset. So we only use it if it differs from SAGE_VENV.
search_path = ':'.join([os.path.join(SAGE_VENV, 'bin'),
os.path.join(SAGE_LOCAL, 'bin')])
path = shutil.which(self.executable, path=search_path)
if path is not None:
return path
# Now look up in the regular PATH.
path = shutil.which(self.executable)
if path is not None:
return path
Expand Down

0 comments on commit 3566e53

Please sign in to comment.