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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Micropip should be able to install wheels from the file system #2731
Comments
Posting here for visibility. The latest JupyterLite release adds support for accessing files from the Python (Pyodide-based) kernel:
While the mounting logic is a bit specific to JupyterLite / JupyterLab and enabled via a For example one could upload a wheel (or ship it as part of the default content) and install it with: import micropip
await micropip.install('./snowballstemmer-2.2.0-py2.py3-none-any.whl') |
Maybe it can be |
Probably from a user point of view keeping the same |
We currently interpret |
What about intercepting |
What about relative paths though? |
Well, URIs don't necessarily have to start with # Open a database in read-only mode.
con = sqlite3.connect("file:template.db?mode=ro", uri=True) So, with the default settings, Indeed, allowing |
The problem is that when run in Node.js, |
hey guys! awesome to see this being on the table so recently seems like this is a requested feature not yet available seemlessly, any info would be appreciated! thx & have a good one! |
@fire17 Would you mind opening a separate issue about it? It's a bit orthogonal to the current discussion. The general documentation for adding a package can be found here. Looking at the xo-gd description, it looks like a lof of the functionality it exposes will not be supported in the browser (let's discuss the details in a separate issue). |
I am leaning towards going with I guess another thought is it might be worth having a list of local directories that micropip could automatically search when looking for a wheel. This would better handle the case where you have a wheel and several dependencies of the wheel all in the same folder and you want micropip to correctly resolve the dependencies and load all of them. |
Maybe someone should try to do a draft implementation. I suspect that having two inputs would make the implementation less straightforward as currently we just pass a list of requirements everywhere. Also, it's not very common in Python to have multiple and mutually exclusive input arguments, that's probably the reason for the URL file prefix, instead of doing For some things, we can figure out the details later, but micropip.install is likely one of the most frequently used functions by end users. So it would be good to agree on a public API and implement it, so we can avoid API breakages or deprecations for this (unless we can finish iterating on it before the next release). |
Well what about going with @bollwyvl's suggestion. We could set it up so that |
Or maybe |
"emfs:" is concise yet distinctive. The unslashed-is-relative seems
reasonable as well.
I do still like the idea being able to (re)register of new protocol
handlers that can handle both wheels and warehouse-like API responses...
But "wheels on the disk" seems like a fine place to start.
|
OK, let's go with Actually I wasn't aware that, |
Yeah, URLs are definitely funny things. Here's a little with what from pathlib import Path
from urllib.parse import urlparse
import js
for p in ["emfs:foo.whl", "emfs:./foo.whl", "emfs:/home/pydodide/bar.whl", "emfs://home/pyodide/baz.whl"]:
print("\n---", p, "---")
py_parsed = urlparse(p)
js_parsed = js.eval(f"new URL('{p}')").to_py()
print("py parsed:", py_parsed)
print("... url:", py_parsed.geturl())
print("... path:", Path(py_parsed.path))
print("... abspath:", Path(py_parsed.path).resolve())
print("js parsed:", js_parsed)
print("... parts", f"protocol='{js_parsed.protocol}', origin='{js_parsed.origin}', pathname='{js_parsed.pathname}'")
|
Thanks everyone for the discussion! |
馃殌 Feature
Micropip should be able to install a wheel which is in the emscripten file system from a path.
Motivation
In node (and some day maybe in chrome), we can mount the local file system into the Emscripten file system. It would be useful to install these, for instance when testing whether a wheel was built correctly.
The text was updated successfully, but these errors were encountered: