-
Notifications
You must be signed in to change notification settings - Fork 12
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
Make pyodide venv
more compatible with standard virtualenv
args + add tests
#117
base: main
Are you sure you want to change the base?
Make pyodide venv
more compatible with standard virtualenv
args + add tests
#117
Conversation
if virtualenv_args: | ||
for arg in virtualenv_args: | ||
if arg.startswith("--"): | ||
# Check if the argument (or its prefix form) is supported. | ||
arg_name = arg.split("=")[0] if "=" in arg else arg | ||
if arg_name not in SUPPORTED_VIRTUALENV_OPTIONS: | ||
msg = f"Unsupported virtualenv option: {arg_name}" | ||
logger.warning(msg) | ||
|
||
cli_args.extend(virtualenv_args) |
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.
Should we raise a warning or an error here?
pyodide_build/tests/test_venv.py
Outdated
def test_pip_install(temp_venv_path, packages): | ||
"""Test that our monkeypatched pip can install packages into the venv""" |
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 checking for our SYSCONFIGDATA
patches and the like, I thought it would be better to see if the end-user functionality is working, as a working pip
ensures that those patches have worked.
# "--copies", "--always-copy", FIXME: node fails to invoke Pyodide | ||
# "--symlink-app-data", FIXME: node fails to invoke Pyodide |
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.
Noting for completeness: for supporting these two arguments, we'll definitely need to patch the Pyodide Python (which I need to learn more about).
@ryanking13, I'm facing some trouble here where the For context, I'm trying to test the venv creation with multiple options, as I noticed that it hasn't been tested before. It is easy to split Edit: either way, this PR is ready for review, it is only the tests that need to be fixed. |
pyodide venv
more compatible with standard virtualenv
args + add testspyodide venv
more compatible with standard virtualenv
args + add tests
Hmm that's weird. Those two fixtures should create xbuildenv in a temporary directory which will be removed after the test function so I am not very sure how they can conflict each other. Let me see if I can reproduce the error. |
I think I found the root cause. Let me open a PR to fix it. |
Tests that create xbuildenv didn't reset the cached functions, including the one that finds pyodide_root. It made the tests fail in #117 (comment) cc: @agriyakhetarpal
Thank you for the quick fix! |
Looks like the error got different. I guess we need to create a xbuildenv first to create a venv? |
Also, please note that the dummy_xbuildenv file that I made in this repository does not contain the Some other options can be:
|
Thanks, Gyeongjae. I'm currently downloading the latest (stable) Pyodide xbuildenv for the package installation tests, which get cached/reused between the tests so that we don't download it for every test. I don't intend to add the real xbuildenv tarball to the repository with this PR – that will be large, as you mention. The CI should pass now, but if you'd like me to label the slow tests as integration tests, I can do that. |
Ah, I spoke too soon 😄 I'm not sure why it fails to find the cross-build environment for downloading. The tests are passing for me locally, though (I confirmed with a fresh state of the repository). |
Okay, almost there – just one failing test (that one also passes on my machine) :D |
The test fails because it uses the wrong Python interpreter to install packages. It, therefore, installs the macOS wheels for NumPy, and was silently passing in my case. To fix it, we need to call the Pyodide Python interpreter inside the venv (which relies on pyodide/pyodide#5448), or handle the activation/deactivation of the Pyodide venv inside that test to install the packages – I've proceeded with this approach for now in aca03ab. I see that the rest of the |
Argh, this passes locally and works perfectly fine, but not in CI... |
So, it passes on macOS indeed, but it fails on Linux. |
🤔 no luck. I'm unable |
This reverts commit 8eb8d7d.
Do we have use cases for all these features? I'm a little reluctant to add the maintenance burden until someone actually wants the missing features. Currently, |
Description
This PR stems from #115 (comment) where I noticed that it is currently not possible to extend
virtualenv
args in order to override the virtual environment creation behaviour.I've added a subset of the arguments listed at https://virtualenv.pypa.io/en/stable/cli_interface.html. The environment variables are already supported as we don't have much to deal with them, this PR enables passing those arguments. A warning is raised on currently and to-be-always unsupported arguments. For example,
--no-pip
does not make sense as we needpip
to be able to install packages, and thus we always need a seeded environment.It might be possible to add support for the
--copies
and--symlink-app-data
flags as well, but I haven't looked into them as they seem to be a bit more complex than I expected. Also, I'm not sure if anyone will need the extra complexity.Further steps that can be taken in the medium term are to create a
virtualenv-pyodide
plugin and register it withvirtualenv
so that we can removevenv.py
out ofpyodide-build
altogether and maintain it separately. I would be happy to work on this, but will probably do it in a separate repository and shift it here.Possible use cases:
pip
when creating the virtual environment, before it is patched uppip
version checks when creating an environmentcc: @hoodmane
TODO: