Typed Python library for working with PEP 723 inline script metadata
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pepscript-0.1.2.tar.gz.
File metadata
- Download URL: pepscript-0.1.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d5737941276364a6fe2cc11e166ae644eeb4a2f8052e0a8a8ececf0709f39cf
|
|
| MD5 |
e879f9cea6cbe43e8ad9ff487f7d53e7
|
|
| BLAKE2b-256 |
37f5718b2dbc7274d4dc49ac4ee4922d27af2a4264b315e8b268babca520d2c0
|
File details
Details for the file pepscript-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pepscript-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99efbac6bb3384270da89ec6e9ac5b23b8e2895199969cb2a034868004c53106
|
|
| MD5 |
ffb4eb3e3283267c16ea61f137fd0e96
|
|
| BLAKE2b-256 |
9ca1ad0a0ea684531a402432c24bdb83624f7485230c59dab28dd7e933ae4634
|