Not exactly what you're talking about, but `uv` lets you specify dependencies in the header of scripts: https://docs.astral.sh/uv/guides/scripts/#declaring-script-d...
I think what you describe really only makes sense for a single file script. I _do not_ want to manage dependency hell within my own source files.