Snakepit.PythonPackages (Snakepit v0.8.7)
View SourcePackage installation and inspection for Snakepit-managed Python runtimes.
Uses uv when available or configured, with pip as the fallback.
Examples
Snakepit.PythonPackages.ensure!({:list, ["numpy~=1.26", "scipy~=1.11"]})
{:ok, :all_installed} =
Snakepit.PythonPackages.check_installed(["numpy~=1.26", "scipy~=1.11"])
{:ok, metadata} = Snakepit.PythonPackages.lock_metadata(["numpy~=1.26"])
Snakepit.PythonPackages.ensure!({:file, "requirements.txt"}, upgrade: true)
Summary
Functions
Check which packages are installed.
Ensure all packages in the requirements spec are installed.
Install the given package requirements.
Return the active installer (:uv or :pip).
Return package metadata for lockfiles.
Types
@type requirement() :: String.t()
@type requirements_spec() :: {:list, [requirement()]} | {:file, Path.t()}
Functions
@spec check_installed( [requirement()], keyword() ) :: {:ok, :all_installed} | {:ok, {:missing, [requirement()]}}
Check which packages are installed.
Returns {:ok, :all_installed} when every requirement is present, or
{:ok, {:missing, requirements}} when any are missing.
@spec ensure!( requirements_spec(), keyword() ) :: :ok | no_return()
Ensure all packages in the requirements spec are installed.
Options:
:upgrade- upgrade matching packages:quiet- suppress installer output:timeout- install timeout in ms
@spec install!( [requirement()], keyword() ) :: :ok | no_return()
Install the given package requirements.
Prefer ensure!/2 unless you already know which requirements are missing.
@spec installer() :: :uv | :pip
Return the active installer (:uv or :pip).
@spec lock_metadata( [requirement()], keyword() ) :: {:ok, map()} | {:error, term()}
Return package metadata for lockfiles.
The result maps package name to %{version: version, hash: hash} entries.