Skip to content

Meson build: build dir is hardcoded in sage.config #39870

@antonio-rojas

Description

@antonio-rojas

Steps To Reproduce

sage: from sage.env import SAGE_ROOT
sage: SAGE_ROOT
'/build/sagemath-git/src/sage/src/sage/../..'

SAGE_ROOT should be empty in sagelib except if explicitly specified (eg. by sage-the-distro). Otherwise things break badly for distro packages:

**********************************************************************
File "sage/src/sage/doctest/forker.py", line 1764, in sage.doctest.forker.DocTestDispatcher.serial_dispatch
Failed example:
    DC.expand_files_into_sources()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.doctest.forker.DocTestDispatcher.serial_dispatch[8]>", line 1, in <module>
        DC.expand_files_into_sources()
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/usr/lib/python3.13/site-packages/sage/doctest/control.py", line 1048, in expand_files_into_sources
        self.sources = [FileDocTestSource(path, self.options) for path in expand()]
                                                                          ~~~~~~^^
      File "/usr/lib/python3.13/site-packages/sage/doctest/control.py", line 1045, in expand
        elif not skipfile(path, bool(self.options.optional),
                 ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        if_installed=self.options.if_installed, log=self.log):  # log when directly specified filenames are skipped
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.13/site-packages/sage/doctest/control.py", line 322, in skipfile
        with open(filename) as F:
             ~~~~^^^^^^^^^^
    FileNotFoundError: [Errno 2] No such file or directory: '/build/sagemath-git/src/sage/src/sage/../../src/sage/rings/homset.py'
**********************************************************************

Expected Behavior

SAGE_ROOT is unset (so expand_files_into_sources() works properly)

Actual Behavior

See above

Additional Information

No response

Environment

  • OS: Arch Linux
  • Sage Version: 10.7.beta0

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions