/**
* @file `downloadPipPackage()` — the Python mirror of `dlx/package.ts`'s
* `downloadNpmPackage()`. Installs a pip spec into a content-addressed dlx
* directory (`pip install --target
`), leaving the interpreter pristine:
* the package + its deps land in
* `~/.socket/_dlx//site-packages`, the exact analog of how
* `downloadNpmPackage` installs npm deps into
* `//node_modules/`. This is the bundle-safe / SEA-VFS-safe
* model:
*
* - No venv → no symlinks, no `pyvenv.cfg` with an absolute `home=`.
* - The target dir is plain files → embeddable in a SEA's VFS, relocatable at
* runtime.
* - One shared Python serves N isolated package dirs (true per-tool isolation
* without a venv) — exactly the `node_modules`-per-cacheKey shape. Run the
* installed tool with the package dir on `PYTHONPATH`: spawn(pythonBin,
* ['-m', '', ...args], { env: { ...process.env, PYTHONPATH:
* packageDir } }) `spec` is a PyPI pin (`==`) or a git-SHA
* pin (`git+https://…@`). A TOCTOU lock guards concurrent installs; an
* existing non-empty package dir makes the call idempotent. Contrast
* `createPipVenv` (external-tools/from-pip-venv): venv with a
* `bin/` — convenient but symlink + absolute-`home`-dependent,
* so DLX-only and NOT bundleable.
*/
/**
* Install `spec` into a content-addressed dlx dir via `pip install --target`.
* Lock-guarded + idempotent. Throws on a failed pip install or if the lock
* can't be acquired after MAX_RETRIES. Mirrors `downloadNpmPackage`.
*/
export declare function downloadPipPackage(options: DownloadPipPackageOptions, retryCount?: number): Promise;
export declare function isAlreadyInstalled(packageDir: string): Promise;
export declare function isStaleLock(pid: number): boolean;
export interface DownloadPipPackageOptions {
/**
* Optional sha256 hash (`sha256:` or bare ``) of the top-level
* artifact, the Python analog of `downloadNpmPackage`'s `hash`. When set, pip
* runs with `--require-hashes` and `--hash=sha256:`, which fails closed
* unless EVERY resolved artifact carries a matching hash — the spec plus its
* full dependency closure. So it only fits specs pip can hash-verify (a
* pinned `==` or a direct wheel/sdist URL) with a hash-pinned
* closure. Omit it and rely on the immutable spec as the pin: `==`
* (PyPI is immutable per version) or `@` (git is
* content-addressed).
*/
readonly hash?: string | undefined;
/**
* Absolute path to the Python interpreter used to run pip (and later the
* tool). The interpreter is NOT modified — packages go to the dlx package
* dir. Typically from `resolvePython()`.
*/
readonly pythonBin: string;
/**
* Pip install spec: `==` for a PyPI exact pin, or
* `git+https://@` for a git-SHA pin.
*/
readonly spec: string;
}
export interface DownloadPipPackageResult {
/**
* `true` when this call ran pip; `false` when an existing install was reused.
*/
readonly installed: boolean;
/**
* Directory the package was installed into. Put this on `PYTHONPATH` to run
* the tool: `python -m `. The Python analog of
* `DownloadNpmPackageResult.packageDir`.
*/
readonly packageDir: string;
}
/**
* Content-addressed install dir for a spec:
* `~/.socket/_dlx//site-packages`. The Python analog of
* `downloadNpmPackage`'s `/node_modules`.
*/
export declare function pipPackageDir(spec: string): string;