Skip to content

Conversation

bulenty584
Copy link

  • Add new 'pyodide xbuildenv install-emscripten' command
  • Add clone_emscripten() method to clone emsdk repository
  • Add install_emscripten() method to install and activate Emscripten SDK
  • Add tests for new functionality

Message echoed after installation complete for user to show the path to the emsdk_env.sh so that user can activate it manually in their shell.

bulenty584 and others added 2 commits October 15, 2025 15:39
  - Add new 'pyodide xbuildenv install-emscripten' command
  - Add clone_emscripten() method to clone emsdk repository
  - Add install_emscripten() method to install and activate Emscripten SDK
  - Add tests for new functionality
Comment on lines +507 to +508
"--embedded",
"--build=Release",
Copy link
Member

Choose a reason for hiding this comment

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

What's --embedded and --build=Release do?

Copy link
Author

Choose a reason for hiding this comment

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

I believe the --embedded flag tells emsdk to not modify your global shell startup files or system env. Essentially it places env variables into emsdk_env.sh so the user can call source on it later. The --build=Release flag causes emsdk to build or fetch pre-built tools in release mode instead of debug mode. Not quite sure if either is necessary for pyodide's build but I kept the commands identical to @ryanking13's shared script just to be safe.

Copy link
Member

Choose a reason for hiding this comment

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

I believe the --embedded flag tells emsdk to not modify your global shell startup files or system env.

This sounds like the default behavior. I think release build is also the default? Anyways we can leave it as is, but I normally would do this without either of these flags.

)

# Apply patches from xbuildenv/emsdk/patches directory to upstream/emscripten
# Patches are applied after install but before activate
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't matter if they are applied before or after activate.

Copy link
Author

Choose a reason for hiding this comment

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

Noted and removed!

@hoodmane
Copy link
Member

Thanks for working on this @bulenty584!

@ryanking13 ryanking13 self-requested a review October 16, 2025 12:56
Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Could you also update the integration test?

Currently we are installing Emscripten in CI for integration test, but I think we can replace this with this new command to test if this new command works correctly.

emsdk_dir = manager.install_emscripten(version)

print("Installing emsdk complete.")
print(f"Use `source {emsdk_dir}/emsdk_env.sh` to set up the environment.")
Copy link
Member

Choose a reason for hiding this comment

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

Instead of requiring people to manually source the directory, it would be nice to detect the emscripten installation directory and use it during the build.

Let's do that in a separate PR to reduce the diff, for now, it looks good.


# Apply patches from xbuildenv/emsdk/patches directory to upstream/emscripten
subprocess.run(
f"cat {patches_dir}/*.patch | patch -p1 --verbose",
Copy link
Member

Choose a reason for hiding this comment

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

Note that the patch might fail is that emscripten version passed by the user is different from the version that the patch is generated. I think we ned to gracefully catch those errors and show proper error message.

Copy link
Author

Choose a reason for hiding this comment

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

Ah I must have overlooked that. I added some error handling for this case as well.

Comment on lines 69 to 70
# Verify subprocess calls
# install_emscripten makes 4 calls: clone + install + patch + activate
Copy link
Member

Choose a reason for hiding this comment

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

As these are already tested in test_install_emscripten.py, I think these are unnecessary. Testing the outputs should be enough. Same for all other functions in this file.

Copy link
Author

Choose a reason for hiding this comment

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

Yes after re-examining them I agree. Removed as well.

bulenty584 and others added 2 commits October 17, 2025 11:16
1. Changed default version to `get_build_flag("PYODIDE_EMSCRIPTEN_VERSION")`
2. Updated `clone_emscripten` to `_clone_emscripten`
3. Removed and edited redundant tests in both new test files
4. Updated patch path in `xbuildenv.py` and added new command to CI workflow
@ryanking13 ryanking13 added the integration This PR will run the integration tests. This label can be used as a persistent marker to do so. label Oct 19, 2025
Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

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

Thanks! code wise looks good to me overall. I left some minor comments. Also, I added integration label to trigger integration tests.

Removed the get_build_flag command from xbuildenv cli and added default behavior as none

- name: Activate emsdk
run: |
source ${{ env.EMSDK_CACHE_FOLDER }}/emsdk_env.sh
Copy link
Member

Choose a reason for hiding this comment

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

The emscripten will not be installed in env.EMSDK_CACHE_FOLDER, as env.EMSDK_CACHE_FOLDER is used for mymindstorm/setup-emsdk not for pyodide xbuildenv command.

You can get the pyodide root directory inside the xbuildenv using

pyodide config get pyodide-root

then, the path to the emsdk_env.sh would be.

$(pyodide config get pyodide-root)/../emsdk/emsdk_env.sh

Copy link
Author

Choose a reason for hiding this comment

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

Ah ok I see. Still wrapping my head around the env as a whole. Edited in the latest commit!

Copy link
Member

Choose a reason for hiding this comment

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

Oops. sorry it should be pyodide_root not pyodide-root (underscore)

Copy link
Author

Choose a reason for hiding this comment

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

Ah, sorry. Fixed now!

uses: actions/cache@v4
with:
path: ${{ env.EMSDK_CACHE_FOLDER }}
key: ${{ env.EMSDK_CACHE_NUMBER }}-${{ env.EMSCRIPTEN_VERSION }}-${{ runner.os }}
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this emsdk caching job too. We can add back caching when we find a good way to cache pyodide-build.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, removed from my latest commit.

bulenty584 and others added 2 commits October 20, 2025 08:49
2. emsdk caching job removed in main.yml
3. install-emscripten help message also edited
@ryanking13
Copy link
Member

Also there is a failure in the unittest

'NoneType' object has no attribute 'splitlines'

bulenty584 and others added 2 commits October 21, 2025 09:31
2. Fixed pyodide-root to pyodide_root in integration tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration This PR will run the integration tests. This label can be used as a persistent marker to do so.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants