Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/sage/env.py: don't pass if mismatched SAGE_ROOT is None #38935

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
r"""
Sage Runtime Environment
Verify that importing ``sage.all`` works in Sage's Python without any ``SAGE_``
environment variables, and has the same ``SAGE_ROOT`` and ``SAGE_LOCAL``
(see also :issue:`29446`)::
Verify that importing ``sage.all`` works in Sage's Python without any
``SAGE_`` environment variables, and has the same ``SAGE_ROOT`` and
``SAGE_LOCAL`` (see also :issue:`29446`). If ``SAGE_ROOT`` is a path,
we normalize it, but keep in mind that ``SAGE_ROOT`` may also be
``None``::
sage: env = {k:v for (k,v) in os.environ.items() if not k.startswith("SAGE_")}
sage: from subprocess import check_output
sage: module_name = "sage.all" # hide .all import from the linter
sage: cmd = f"from {module_name} import SAGE_ROOT, SAGE_LOCAL;"
sage: cmd += "from os.path import samefile;"
sage: cmd += f"s1 = samefile(SAGE_ROOT, '{SAGE_ROOT}') if SAGE_ROOT else True;"
sage: if SAGE_ROOT is None:
....: cmd += "s1 = SAGE_ROOT is None;"
....: else:
....: cmd += f"s1 = samefile(SAGE_ROOT, '{SAGE_ROOT}');"
sage: cmd += f"s2 = samefile(SAGE_LOCAL, '{SAGE_LOCAL}');"
sage: cmd += "print(s1 and s2);"
sage: out = check_output([sys.executable, "-c", cmd], env=env).decode().strip() # long time
Expand Down
Loading