PEPScript
A Python library for parsing, validating, editing, and saving PEP 723 inline script metadata through a typed API.
- Zero runtime dependencies (stdlib only)
- Python 3.12+
- Full type hints with
py.typed
Installation
pip install pepscript
Usage
Read metadata from a script
from pepscript import PEPScript
script = PEPScript("my_script.py")
if script.has_metadata:
print(script.meta.dependencies)
print(script.meta.requires_python)
Edit and save
from pepscript import PEPScript
with PEPScript("my_script.py") as script:
script.meta.add_dependency("httpx>=0.27")
script.meta.set_requires_python(">=3.12")
Parse from a string
from pepscript import parse_script
script = parse_script("""\
# /// script
# dependencies = ["requests>=2.0"]
# requires-python = ">=3.12"
# ///
print("hello")
""")
print(script.meta.dependencies) # ['requests>=2.0']
Access tool configuration
from pepscript import PEPScript
script = PEPScript("my_script.py")
if script.has_metadata:
# Attribute access
ruff = script.meta.config.tool.ruff
# Item access (for keys with hyphens)
line_length = ruff["line-length"]
setting = script.meta.config.tool["my-tool"]["some-setting"]
Validate metadata
from pepscript import PEPScript, MetadataValidationError
script = PEPScript("my_script.py", strict=False)
try:
script.validate()
except MetadataValidationError as e:
print(f"Invalid metadata: {e}")
Contributing
Setup
uv sync
Running checks
uv run pytest # Tests
uv run ruff check . # Lint
uv run ruff format . # Format
uv run ty check . # Type check
Versioning and releases
This project uses Semantic Versioning. The version is set in pyproject.toml.
Release notes are generated automatically from Conventional Commits when a version tag is pushed.
To release:
- Update
versioninpyproject.toml - Push your changes and merge them into
main - Wait for the
CIworkflow onmainto pass - Tag the merged commit on
mainand push the tag:git checkout main git pull origin main git tag v0.1.2 git push origin v0.1.2
Pushing the tag triggers the release workflow, which builds the package, publishes it to PyPI, generates release notes with git-cliff, and creates the GitHub release.
Commit messages should follow Conventional Commits (fix:, feat:, feat!: for breaking changes).
License
MIT
Metadata
Release files for pepscript 0.1.2
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 |
|---|---|---|---|---|
| pepscript-0.1.2.tar.gz | 12.4 kB | Without provenance | Details for pepscript-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pepscript-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pepscript-0.1.2-py3-none-any.whl |
Total release size: 28.6 kB
Release files / pepscript-0.1.2.tar.gz
| Download URL | pepscript-0.1.2.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d5737941276364a6fe2cc11e166ae644eeb4a2f8052e0a8a8ececf0709f39cf
|
|
BLAKE2b-256 checksum How to use checksums |
37f5718b2dbc7274d4dc49ac4ee4922d27af2a4264b315e8b268babca520d2c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pepscript-0.1.2-py3-none-any.whl
| Download URL | pepscript-0.1.2-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
99efbac6bb3384270da89ec6e9ac5b23b8e2895199969cb2a034868004c53106
|
|
BLAKE2b-256 checksum How to use checksums |
9ca1ad0a0ea684531a402432c24bdb83624f7485230c59dab28dd7e933ae4634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pepscript 0.1.2
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.