spython is a Python library that provides a programmatic interface for interacting with the Singularity (now Apptainer) container engine. It allows Python applications to execute Singularity commands, manage images, and run containers without directly calling the command-line interface. The current version is 0.3.15, and it maintains a somewhat active release cadence with several updates per year.
pip install spythonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to pull a Singularity image, run a command inside it, start and execute a command within an instance, and then stop the instance. It highlights the importance of checking the return_code for command success.
Ensure Singularity/Apptainer is correctly installed and configured on your host system, and its binaries are discoverable via the PATH environment variable.
Always check `result.get('return_code')` for a non-zero value to detect failures, and inspect `result.get('stderr')` for diagnostic information.Manage instance names explicitly and avoid relying on `spython` to alter them. Ensure your instance start and stop commands use the exact instance names you intend.
Use `os.path.abspath()` or provide full paths to `.sif` files when invoking `spython` commands.
Review and test any workflows that programmatically create or convert Singularity recipes, specifically checking `WORKDIR` behavior, if upgrading from `spython < 0.3.0`.
Install Apptainer (or Singularity) on your system and ensure the `singularity` or `apptainer` executable is available in your shell's PATH, or set the `SINGULARITY_PATH` environment variable to its full path.
Install the package using pip: `pip install spython`.
Use the `Client` class to execute commands directly: `from spython.main import Client; Client.pull("library://alpine:latest")`.Use the correct package name for imports, such as `from spython.main import Client` or `from spython.main import Singularity`.
No dependency data recorded yet.