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

Micropip should be able to process requirements files #6

Open
hoodmane opened this issue Jun 26, 2022 · 5 comments
Open

Micropip should be able to process requirements files #6

hoodmane opened this issue Jun 26, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@hoodmane
Copy link
Member

🚀 Feature

We should have a micropip version of pip install -r requirements.txt. Maybe micropip.install(requirements_file="some/path").

@hoodmane hoodmane added the enhancement New feature or request label Jun 26, 2022
@rth
Copy link
Member

rth commented Jun 28, 2022

We should probably nudge users toward using some form of a lock file instead of a requirement.txt file, but I suppose it still makes sense to support requirements.txt files for existing projects.

@rth rth transferred this issue from pyodide/pyodide Sep 24, 2022
@rth
Copy link
Member

rth commented Sep 24, 2022

BTW, tried recently pip-tools for lock file generation in a requirement.txt and was very happy with it.

@miohtama
Copy link

miohtama commented Jul 7, 2023

Any ideas/examples how this could be accomplished on the caller side today e.g. by feeding packages one by one?

  • We are currently trying a library with complex dependencies getting installed through micropic
  • The package is managed by poetry, so we can generate all kind of exports of requirements
  • micropip installation currently fails, as some parts of micropip dependency resolution seem to be different/broken
  • However it is not possible to tell, because at least to our knowledge there is currently not an easy to way to get micropip installation process give a meaningful log output what it is doing and why to address the issues
  • Not allowing micropip to figure out dependencies on its own, but force feeding it a requirements.txt pin down list or similar should solve this issue

@rth
Copy link
Member

rth commented Jul 7, 2023

micropip installation currently fails, as some parts of micropip dependency resolution seem to be different/broken

@miohtama Can you open a new issue with the details of the errors you are getting?

However it is not possible to tell, because at least to our knowledge there is currently not an easy to way to get micropip installation process give a meaningful log output what it is doing and why to address the issues

micropip has fairly rudimentary dependency resolution where it starts from the first package, loads recursively all requirements, and hopes that all will be OK. You can see what it is doing in the dev console log.

Not allowing micropip to figure out dependencies on its own, but force feeding it a requirements.txt pin down list or similar should solve this issue

Well, you can do something like,

from pathlib import Path

requirements = Path('requrements.txt').read_text().splitlines()
await micoropip.install(requirements)

the question is how to create that frozen list of requirements. What poetry or pip-compile will give you will not be correct, since it will not take into account binary wheels that exist for the emscripten/wasm platform. We are exploring this topic in pyodide/pyodide-lock#10 but it's still early days.

Meanwhile, you can also take the output of frozen requirements given to you by those tools and manually tweak it until it works. In particular, any package version with binary wheels (e.g. numpy etc) need to match the version in the Pyodide distribution otherwise it will not be able to find the wheel. Though it's certainly not a very user friendly approach.

@joemarshall
Copy link
Contributor

joemarshall commented Sep 1, 2023

@rth pyodide build can output a flat requirements.txt / lockfile for a build already.

I do think it needs some fixup in terms of how one makes pyodide/ micropip aware of dependencies of wheels you've installed but that is a lot more straightforward (and I've put in an issue relating to this)

#78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants