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

Commit

Permalink
src/sage/features/__init__.py: Simplify Executable.absolute_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Mar 2, 2022
1 parent 9fad95e commit a93e9af
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,12 @@ def absolute_path(self) -> str:
Executable 'does-not-exist-xxxxyxyyxyy' not found on PATH.
"""
if SAGE_LOCAL:
sage_venv = Path(SAGE_VENV)
sage_local = Path(SAGE_LOCAL)
if sage_venv.resolve() != sage_local.resolve():
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.
PATH = ':'.join(str(p) for p in [sage_venv / 'bin', sage_local / 'bin'])
path = shutil.which(self.executable, path=PATH)
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.
Expand Down

0 comments on commit a93e9af

Please sign in to comment.