Skip to main content

PEPScript

CI PyPI Python License Coverage Docs

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:

  1. Update version in pyproject.toml
  2. Push your changes and merge them into main
  3. Wait for the CI workflow on main to pass
  4. Tag the merged commit on main and 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

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)

Source distribution for pepscript 0.1.2
File Size Uploaded
pepscript-0.1.2.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pepscript 0.1.2
File Interpreter ABI Platform
pepscript-0.1.2-py3-none-any.whl Python 3 none any Details

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}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page