-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
New mode - in-memory install #89
Comments
I'm unable to assign this issue, but @bswck has volunteered to work on it. |
Happy to work on it at https://github.com/bswck/pip-run/tree/feature/in-memory-install! |
I've created a separate repository for the project to share low-level interfaces for downloading, installing and running modules all in memory: mempip. State: WIP. The reason for this is a whole lot of logic in the task and the amount of tests it takes—what primarily led me to this decision is the single responsibility rule and the very often practice of decoupling. When a mempip MVP is ready, the incorporation to pip-run can be discussed: mempip could be added as an extra dependency I am open for advice and recommendations. |
Here's a quick write-up of my initial ideas. Things might change as I explore the possibilities. Take this is a BrainstormThe New Definition of "Installation"In mempip, installation would mean creating a ready-to-use data structure in memory (a high-level ZIP file wrapper) from a wheel that allows to import a new package with all its declared dependencies guaranteed to exist at runtime. Similarly to how a normal pip installation most often results in a ready-to-use, importable package, located typically in site-packages with its dependencies spread across the neighboring subfolders. A Generic RoadmapSome things a minimal mempip MUST handle:
mempip SHOULD also handle:
The Can't-Touch-This Policymempip should not touch the filesystem. That means pressing Ctrl+C with a running mempip in a shell session will free up all the resources used by mempip immediately and leave no trace (except for the prompt in your shell history file). pip Compliancemempip's main goal SHOULD be to offer a known, standard interface with strong focus on portability across all platforms supported by pip-run. mempip is not, however, meant to replace pip, but rather broaden its horizons to allow memory-located installations. Here's a rundown on the current programmatic interface design inspired by the current pip CLI commands: https://github.com/bswck/mempip/issues/1. Reusing pipWhenever possible, mempip SHOULD reuse the internal pip implementation for resolving dependencies or building wheels. Distributed ApproachIdeally, mempip SHOULD come with a daemon service (possible names: mempipd, depstore, cachedpip?) that would behave similarly to Redis, allowing to reuse in-memory installations in a distributed manner, which might be useful, for example, for large concurrent test frameworks running in isolated filesystems (like containers) with a lot of dependencies to operate on. The daemon would serve as a store where dependencies can be looked up dynamically by test runners and imported directly from the aforementioned ZIP files in the daemon's memory. Let's call it the "distributed strategy" of mempip. The implementation MUST obey the ACID rules—broken mempip installations SHOULD NOT pollute the existing public memory state of the daemon and future importers should wait until their in-memory installation is complete. The daemon could optionally, similarly to Redis, dump its state to a backup file and be recovered to the last state as a recovery feature, useful for speeding up pipelines by reusing already installed & cached packages. Technical PlanMore to come here later... Downloading Wheels/Source Packages
Building Wheels from Source Packages
Installing Wheels into In-Memory ZIP Files
Distributed Strategy
Access Control
Backups
Importing
Benchmarking
Testing
Learning Materials
|
As part of my research, I'm exploring PyPA specifications to get a good grasp of what I'm doing. Maybe I will figure out what to do with non-pure Python installations in the process. |
Imagine - instead of having to assemble expanded installs of packages into some folder on a file system, instead resolving dependencies to wheels and importing modules from those wheels directly from zip files in memory, similar to how a web browser can load javascript dependencies from a URL. This ambitious approach would require developing custom loaders/finders/resource providers and developing facilities for handling non-pure wheels.
The text was updated successfully, but these errors were encountered: