src-snapshot
Lightweight utility to snapshot your source code into a zip archive for reproducible experiments.
Designed for researchers who want a simple, reliable way to store the exact code used for a run (and some metadata).
Installation
pip install src-snapshot
The package is installed as src-snapshot and imported as src_snapshot.
Usage
from src_snapshot import create_snapshot
create_snapshot("code.zip", source_folders="src")
That’s it. A zip archive will be created containing your source files and optional metadata.
Features
- Copy selected source folders into a zip archive
- Filter files by suffix (default: .py, .yaml)
- Include the main entrypoint script (automatically or manual path)
- Store current git commit and diff
- Generate a metadata file with environment, hardware, SLURM and run information
API
def create_snapshot(
filepath: Path | str,
*,
source_folders: Optional[Path | str | Iterable[Path | str]] = None,
suffixes: Optional[str | tuple[str]] = (".py", ".yaml"),
add_main_file: bool | Path | str = True,
add_git_diff: bool = True,
add_metadata: bool = True,
)
Arguments
filepath: Output zip file (must not exist yet)source_folders: Folder(s) to include (default: current directory)suffixes: File extensions to includeadd_main_file: Include the main script as__main__.py.Truedetects it automatically; pass a path to choose it explicitly. In interactive sessions (Jupyter, REPL,python -c) there is no main script, so it is skipped with a warning.add_git_diff: Store uncommitted changes asgit_diff.patchadd_metadata: Writemetadata.json(timestamp, environment, git info, installed packages)
Archive contents
code.zip
├── <source_folder>/... # your source files
├── __main__.py # the entrypoint script
├── git_diff.patch # uncommitted changes
└── metadata.json # run metadata
Privacy
metadata.json contains the username, hostname, working directory, command line and the list of installed packages.
Keep this in mind before sharing snapshots publicly, or set add_metadata=False.
Releasing
Releases are published to PyPI by GitHub Actions using trusted publishing:
- Bump
versioninpyproject.toml. - Commit, then tag and push:
git tag v0.1.0 && git push origin v0.1.0.
The workflow runs the tests, checks that the tag matches the version, builds and uploads the package.
License
Metadata
Release files for src-snapshot 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| src_snapshot-0.1.0.tar.gz | 7.0 kB | Without provenance | Details for src_snapshot-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| src_snapshot-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for src_snapshot-0.1.0-py3-none-any.whl |
Total release size: 14.3 kB
Release files / src_snapshot-0.1.0.tar.gz
| Download URL | src_snapshot-0.1.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e9dabcaf84f9aa7003d9efe4833a1b0c13aea5b06518487a099da7aaecee213
|
|
BLAKE2b-256 checksum How to use checksums |
207224ba54c7075735938e06f6a49a32dfa88648a6303cca15b86e30b1cfac32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / src_snapshot-0.1.0-py3-none-any.whl
| Download URL | src_snapshot-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9bec704acc347803f53f601be3722584a31151a7506130b7fbdbccfbd000e4c
|
|
BLAKE2b-256 checksum How to use checksums |
fbccf2a8327dd11b10223b3367a1905c28ca881161b06b502caaff6998cd5376
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for src-snapshot 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.