Skip to content

Fix bootstrap.py script to not depend on tools/shared.py #24424

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

Merged
merged 3 commits into from
May 29, 2025

Conversation

juj
Copy link
Collaborator

@juj juj commented May 28, 2025

Fix bootstrap.py script to not depend on tools/shared.py so that it can be run during emsdk installation phase when no .emscripten config yet exists. Fixes emscripten-core/emsdk#1545

…an be run during emsdk installation phase when no .emscripten config yet exists. Fixes emscripten-core/emsdk#1545
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

I wonder we add test for this in test_bootstrap in test_sanify.py

@juj
Copy link
Collaborator Author

juj commented May 28, 2025

I wonder we add test for this in test_bootstrap in test_sanify.py

Added a sanity test. It is quite convoluted to test since config.py tries its best to locate Emscripten tools via so many different means. But looks like it worked.

@juj juj enabled auto-merge (squash) May 28, 2025 22:13
# Verify that running bootstrap.py in a first-time run scenario should not
# cause an exception. (A first time run scenario is before .emscripten, env.
# vars nor PATH has been configured)
def test_bootstrap_without_em_config(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you just do @with_env_modify({'EM_CONFIG': "/path/does/not/exist"}) maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure - folded that to the other env. modify code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But can you literally just write this test as:

@with_env_modify({'EM_CONFIG': "/path/does/not/exist"})
 def test_bootstrap_without_em_config(self):
   # Verify that bootstrap works even without a valid config file.
   self.run_process([shared.bat_suffix(shared.path_from_root('bootstrap'))])

Copy link
Collaborator

Choose a reason for hiding this comment

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

(verified that that test fails as written without this PR).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But can you literally just write this test as:

No, that doesn't work. It didn't work for me, but falsely passed the test.

That is because

path = shutil.which(tool_binary)
goes and finds clang.exe in PATH, and then assigns LLVM_ROOT based on that, sidestepping the problem.

Those env. removals are important to make sure to match the clean install scenario.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I see, the behavior of from tools import shared is different with

@with_env_modify({'EM_CONFIG': "/path/does/not/exist"})

versus

@with_env_modify({'EM_CONFIG': None})

It is better to test the scenario that first-time emsdk install also exercises, when there are no env. vars yet set. This way the test matches what happens on a new installation, and won't rely on EM_CONFIG pointing to a nonexistent file (emsdk doesn't do that either on first-time install)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough. I think its probably overkill but I get that there could be difference.

@juj juj disabled auto-merge May 28, 2025 22:24
@juj juj enabled auto-merge (squash) May 28, 2025 22:27
@juj juj disabled auto-merge May 29, 2025 09:17
@juj juj merged commit 97f974c into emscripten-core:main May 29, 2025
27 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

emsdk install sdk-main-64bit no longer works.
2 participants