-
Notifications
You must be signed in to change notification settings - Fork 22
Add install-emscripten CLI command #243
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
base: main
Are you sure you want to change the base?
Add install-emscripten CLI command #243
Conversation
- 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
for more information, see https://pre-commit.ci
"--embedded", | ||
"--build=Release", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pyodide_build/xbuildenv.py
Outdated
) | ||
|
||
# Apply patches from xbuildenv/emsdk/patches directory to upstream/emscripten | ||
# Patches are applied after install but before activate |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted and removed!
Thanks for working on this @bulenty584! |
…in test_install_emscripten.py removed as well
for more information, see https://pre-commit.ci
…nd some basic reformatting
There was a problem hiding this 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.") |
There was a problem hiding this comment.
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.
pyodide_build/xbuildenv.py
Outdated
|
||
# Apply patches from xbuildenv/emsdk/patches directory to upstream/emscripten | ||
subprocess.run( | ||
f"cat {patches_dir}/*.patch | patch -p1 --verbose", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
# Verify subprocess calls | ||
# install_emscripten makes 4 calls: clone + install + patch + activate |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
for more information, see https://pre-commit.ci
There was a problem hiding this 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
.github/workflows/main.yml
Outdated
|
||
- name: Activate emsdk | ||
run: | | ||
source ${{ env.EMSDK_CACHE_FOLDER }}/emsdk_env.sh |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry. Fixed now!
.github/workflows/main.yml
Outdated
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.EMSDK_CACHE_FOLDER }} | ||
key: ${{ env.EMSDK_CACHE_NUMBER }}-${{ env.EMSCRIPTEN_VERSION }}-${{ runner.os }} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2. emsdk caching job removed in main.yml 3. install-emscripten help message also edited
Also there is a failure in the unittest
|
2. Fixed pyodide-root to pyodide_root in integration tests
for more information, see https://pre-commit.ci
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.