Skip to content
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

Copy source into pyodide environment #43

Open
koenvo opened this issue Oct 11, 2022 · 4 comments
Open

Copy source into pyodide environment #43

koenvo opened this issue Oct 11, 2022 · 4 comments

Comments

@koenvo
Copy link
Contributor

koenvo commented Oct 11, 2022

When running the tests of pyodide-http I occasionally forget to first build the wheel. It would be very convenient when the current context is copied pyodide environment before starting the test.

This could be an additional argument to run_in_pyodide like source_packages. Or maybe even more generic: copy directories to the pyodide environment before execution.

Curious what you think about it.

@hoodmane
Copy link
Member

Sounds like there is some overlap here with what I have been trying to do with my command line test runner, so that tests can be run like python -m pytest and that invokes a Pyodide Python to run the tests. The command line runner uses the Emscripten NodeFS to join the Pyodide file system to the host file system. Then it uses a virtual environment and other stuff residing on the native file system.

Unfortunately it is not clear how to do this in selenium. Chrome's files system access API could work, but it is not clear how to use it in selenium @ryanking13 has made some useful efforts in this direction but he didn't work out yet how to do the dialog window interaction needed to use it in tests. If we worked that out, maybe we could get a command line test runner that also works in Chrome.

Anyways something like what you describe could be a useful half-measure.

@koenvo
Copy link
Contributor Author

koenvo commented Oct 11, 2022

Ah yes nodefs should do the trick. Is your code available somewhere? Curious to the implementation details!

In a real browser it seems pretty hard. “This interface will not grant you access to the users' filesystem. Instead, you will have a "virtual drive" within the browser sandbox” https://developer.mozilla.org/en-US/docs/Web/API/FileSystem

Or maybe it’s possible: https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

Let me see if I’m able to come up with a POC

@hoodmane
Copy link
Member

It's here:
https://github.com/pyodide/pyodide/blob/main/tools/python
and here to create the virtual environment:
https://github.com/pyodide/pyodide/blob/main/pyodide-build/pyodide_build/out_of_tree/venv.py

You can use it with pyodide venv

@rth
Copy link
Member

rth commented Dec 10, 2022

copy directories to the pyodide environment before execution.

There is also an ongoing PR in #62 to do this

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

No branches or pull requests

3 participants