Supply-chain security is hard. Have one dependency and hallucinate the rest.
Project description
hallucipip
Supply-chain security is hard. Have one dependency and hallucinate the rest.
hallucipip ships with exactly one runtime dependency — an LLM client. Every other module you import is generated on demand by an LLM, written to disk as a plain .py file, and loaded through Python's normal import machinery.
It is a joke. The mechanism is real.
The premise
Modern Python projects routinely pull in hundreds of transitive dependencies, any one of which can own your supply chain. hallucipip asks: what if you just didn't install them? What if, at import time, we generated the module ourselves?
Every hallucinated module is:
- Generated from a prompt, not fetched from PyPI.
- Cached locally as a plain Python file you can read.
- Uniquely yours — different API key, different model, different code.
The blast radius of a compromised dependency is zero, because the dependency does not exist.
The blast radius of a bad hallucination is, admittedly, non-zero.
How it works
import hallucipipinstalls aMetaPathFinderintosys.meta_path.- When Python tries to import a top-level module that isn't stdlib and isn't installed, the finder takes over.
- The finder computes a request signature from the module name, model, version hint, and prompt.
- If a matching file exists in
~/.hallucipip/cache, it's loaded immediately. - Otherwise an LLM is asked to produce a single-file implementation with no third-party imports, the result is written to the cache, and Python loads it normally.
The generated code is just a .py file. You can cat it. You can edit it. You can check it into version control if you hate yourself.
Installation
uv pip install hallucipip
# or
pip install hallucipip
Quickstart
import hallucipip
hallucipip.configure(
model="anthropic/claude-sonnet-4.5",
api_key="...", # or set OPENROUTER_API_KEY
hallucination_intensity=4,
debug=True,
)
import fake_math_lib # does not exist on PyPI
print(fake_math_lib.__version__)
print(fake_math_lib.add(2, 3))
The first import takes an LLM call. Every subsequent import is a disk read.
Configuration
All of these can be set as env vars or passed to hallucipip.configure():
| Env var | Purpose | Default |
|---|---|---|
HALLUCIPIP_MODEL |
Model slug | anthropic/claude-3.7-sonnet |
HALLUCIPIP_BASE_URL |
OpenAI-compatible endpoint | https://openrouter.ai/api/v1 |
HALLUCIPIP_TEMPERATURE |
Sampling temperature | 0.7 |
HALLUCIPIP_MAX_TOKENS |
Generation cap | 8000 |
HALLUCIPIP_INTENSITY |
1 (conservative) – 10 (unhinged) |
5 |
HALLUCIPIP_CACHE_DIR |
Where cached modules live | ~/.hallucipip/cache |
HALLUCIPIP_DEBUG |
Verbose logging | false |
OPENROUTER_API_KEY / ANTHROPIC_API_KEY / OPENAI_API_KEY |
Whichever you have | — |
Version hints
If you want the generator to aim at a particular public API shape, drop an inline comment:
import imaginary_numpy # hallucipip: imaginary_numpy>=2.0,<3
The hint becomes part of the generation request and the cache signature, so different compatibility targets don't overwrite each other.
CLI
hallucipip config # show active configuration
hallucipip cache list # list cached hallucinations
hallucipip cache clear # wipe cache — next import re-hallucinates
hallucipip --debug ... # structured logs on stderr
Dependencies
One. openai — used as a thin OpenAI-compatible HTTP client so you can point at OpenRouter, Anthropic, OpenAI, or your own endpoint. The CLI uses argparse. Pretty output uses print. There is no rich, no click, no requests, no pydantic.
If openai itself offends you philosophically, the joke lands harder.
What this is not
- A substitute for real package management.
- A substitute for reproducible builds.
- A substitute for audited dependencies.
- Safe.
- Deterministic.
- A good idea.
It is a useful import hook for prototyping, demos, compatibility experiments, and the occasional cursed notebook.
Limitations
- Generated code is not trustworthy by default. Read it before you trust it.
- Behavior drifts across models and prompts.
- Only top-level imports are handled right now. Deep package emulation is out of scope.
- Non-trivial libraries with large C-extension surfaces will only get partial compatibility.
Development
uv sync --extra dev
uv run pytest
uv run python -m build
Publishing
uv run python -m build
uv run twine upload dist/*
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hallucipip-0.2.0.tar.gz.
File metadata
- Download URL: hallucipip-0.2.0.tar.gz
- Upload date:
- Size: 3.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d44579821bdc0e316c96b04c8b7d2fb073fed1c4c04c20c6a7aa3e19a004706
|
|
| MD5 |
5341788678e8ebe81b97073a9d1db483
|
|
| BLAKE2b-256 |
b303451e8e9530cc744f744182f820c3390d21b393b28b1920dd82d31885c299
|
File details
Details for the file hallucipip-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hallucipip-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
729ef7a4b04866878e6577bb6a1fbd67ec05cfdb99c53241eaf5e3b2224c3bb4
|
|
| MD5 |
e0b23d2cdb67a3b1d272b854b0c4b00e
|
|
| BLAKE2b-256 |
9865a64b3361ef06afa61671ef095808e15f493574063b7903f8a9ac4c3fc443
|