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

Provided a default value for SAGE_ROOT that can be overridden by an environment variable or configuration file #39885

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Krishnadubey1008
Copy link
Contributor

This PR fixes #39870
added following code to env.py

DEFAULT_SAGE_ROOT = "" 
SAGE_ROOT = var("SAGE_ROOT", DEFAULT_SAGE_ROOT)

to ensure that SAGE_ROOT is not hardcoded and can be dynamically set or overridden

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Apr 5, 2025

Documentation preview for this PR (built with commit 83e10d2; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

Copy link
Contributor

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

The fallback

conf_data.set('SAGE_ROOT', meson.current_source_dir() / '..' / '..')
also needs to be removed (which might lead to other problems that then need to be fixed).

src/sage/env.py Outdated
@@ -192,7 +192,8 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
SAGE_SPKG_INST = var("SAGE_SPKG_INST", join(SAGE_LOCAL, "var", "lib", "sage", "installed")) # deprecated

# source tree of the Sage distribution
SAGE_ROOT = var("SAGE_ROOT") # no fallback for SAGE_ROOT
DEFAULT_SAGE_ROOT = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simply inline this variable.

@antonio-rojas
Copy link
Contributor

antonio-rojas commented Apr 7, 2025

As mentioned in #39870 (comment), SAGE_ROOT must be unset by default, not set to the empty string. Otherwise, in the next two lines in env.py

SAGE_SRC = var("SAGE_SRC", join(SAGE_ROOT, "src"), SAGE_LIB)
SAGE_DOC_SRC = var("SAGE_DOC_SRC", join(SAGE_ROOT, "src", "doc"), SAGE_DOC)

the variables are assigned the wrong fallback (involving SAGE_ROOT) instead of the correct one (the last one). So just removing the fallback in config.py like Tobias suggested in #39885 (review) should suffice.

@Krishnadubey1008
Copy link
Contributor Author

@antonio-rojas @tobiasdiez thanks for your help, I had applied the changes please review

Co-authored-by: Antonio Rojas <[email protected]>
@antonio-rojas
Copy link
Contributor

I still think that config.py is a distro thing that should be installed by the distro (be it sage-the-distro or something else), not by sagelib. But at least it with this it won't break downstreams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Meson build: build dir is hardcoded in sage.config
3 participants