I got tired of watching pip think for at least 45 seconds before I could write a single line of code only to get back to waiting for dependency resolution and/or installation, so I built a hack that remembers the answer.
What was the issue really?
I built a plug-and-play FastAPI engine ChaCC‑API that loads modules with their own requirements.txt. With every restart, it re‑resolved every module’s dependencies. Like running pip install over and over.
In development, with a medium‑sized module, that meant 45 seconds of waiting. Even when nothing changed.
Restart server? Wait. Edit a module? Wait. Add a module? Wait again.
Then this happened:
I built chacc-dependency-manager. It does one smart thing though very small 🙂
Cache the result of pip-compile.
cache_key = hash(requirements + python_version + os)
if cache_key in cache:
pinned = cache[cache_key] # use saved answer
else:
pinned = run_pip_compile() # solve once (slow)
cache[cache_key] = pinned
# Only install what's actually missing
install_missing_packages(pinned)
Enter fullscreen mode Exit fullscreen mode
No extra resolver runs. No unnecessary pip install calls. Just remember the plan, then do only what’s needed.
Does it work?
- First run (or after requirements change): ~45 seconds (resolve + install)
- Cache hit (no changes): <2 seconds (skip resolution, install only missing packages – usually nothing)
In my dev workflow, that 45‑second wait on every restart is now gone when dependencies are stable.
But be real: If you’re actively editing requirements.txt, you’ll pay the price if not worse each time you change it. This hack shines when you’re not changing dependencies often, exactly my case.
What it won’t do
- Resolve conflicts – still uses
pip-compilefor that. - Make cold installs faster – first run is full price.
- Beat
uvin a speed contest – if you’re starting fresh, just useuv. It’s faster and smarter. - Warn you about version conflicts across modules – those will still surface at install time.
It’s a tiny caching wrapper for a specific modular workflow. That’s it.
Try it if you’re tired of waiting
Standalone or try and use ChaCC‑API (toggle ENABLE_PLUGIN_DEPENDENCY_RESOLUTION) to see it in action.
What’s your “I just want to cache this” story?
#buildinpublic #pip
답글 남기기