Skip to content

Conversation

@ocaisa
Copy link
Member

@ocaisa ocaisa commented Nov 28, 2025

The use case for this is buildenv in EESSI (https://gitlab.com/eessi/support/-/issues/213), where you might want to auto-load a buildenv with your compiler, but not if you are in an EasyBuild session.

self.orig_modulepath = os.getenv('MODULEPATH')

# keep track of initial environment we start in, so we can restore it if needed
os.environ['___EASYBUILD___'] = "EasyBuild" # set an environment variable to know we are in an EB session
Copy link
Member Author

Choose a reason for hiding this comment

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

We need this before copying the initial environment as that environment gets restored before loading the module (which is exactly where we want to target a conditional load)

Copy link
Member

Choose a reason for hiding this comment

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

@ocaisa Let's move this up, as the very first thing we do in __init__, just to make sure that we never do anything that involves calling out to external tools (which could take this into account) before this is set.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this should be done way earlier, in main.py ?

Copy link
Member

Choose a reason for hiding this comment

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

@ocaisa see proposed change in ocaisa#48

self.orig_modulepath = os.getenv('MODULEPATH')

# keep track of initial environment we start in, so we can restore it if needed
os.environ['___EASYBUILD___'] = "EasyBuild" # set an environment variable to know we are in an EB session
Copy link
Member

Choose a reason for hiding this comment

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

@ocaisa Let's move this up, as the very first thing we do in __init__, just to make sure that we never do anything that involves calling out to external tools (which could take this into account) before this is set.

@boegel boegel changed the title Set an environment variable to indicate an EB session Set $___EASYBUILD___ environment variable to EasyBuild to indicate that you're in an EasyBuild session Nov 29, 2025
@boegel boegel added this to the next release (5.2.0) milestone Nov 29, 2025
@boegel boegel changed the title Set $___EASYBUILD___ environment variable to EasyBuild to indicate that you're in an EasyBuild session Set $___EASYBUILD___ environment variable to 'EasyBuild' to indicate that you're in an EasyBuild session Dec 3, 2025
set `$___EASYBUILD___` via `prepare_main` in `main.py`
@ocaisa ocaisa requested a review from boegel December 3, 2025 08:19
Copy link
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

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

lgtm

@boegel boegel merged commit efe239b into easybuilders:develop Dec 3, 2025
39 checks passed
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.

2 participants