yapcad.package package

Subpackages

Submodules

yapcad.package.core module

Core .ycpkg packaging helpers.

class yapcad.package.core.PackageManifest(root: Path, data: Dict[str, ~typing.Any]=<factory>, manifest_name: str = 'manifest.yaml')[source]

Bases: object

Wrapper around the manifest document.

data: Dict[str, Any]
geometry_primary_path() Path[source]
get_material(material_id: str) Dict[str, Any] | None[source]

Get a specific material definition by ID.

get_materials() Dict[str, Any][source]

Return the materials dictionary from the manifest.

classmethod load(package_path: Path | str) PackageManifest[source]
manifest_name: str = 'manifest.yaml'
property manifest_path: Path
recompute_hashes(*, algorithm: str = 'sha256') None[source]
root: Path
save() None[source]
yapcad.package.core.add_geometry_file(manifest: PackageManifest, source: Path | str, *, dest_relative: str | None = None, purpose: str | None = None, category: str = 'derived', overwrite: bool = False, metadata: Dict[str, Any] | None = None) Dict[str, Any][source]

Copy an external geometry file (e.g., STEP/STL) into the package and record it.

Parameters:
  • manifest – Loaded manifest wrapper.

  • source – Path to the external file that should be bundled.

  • dest_relative – Optional relative destination path inside the package root. Defaults to geometry/derived/<source.name>.

  • purpose – Optional description stored alongside the entry.

  • category – Manifest section to update. Supported: "derived" (default), "attachments".

  • overwrite – Allow replacing an existing file at the target location.

  • metadata – Additional key/value pairs merged into the manifest entry.

Returns:

The manifest entry dictionary that was inserted.

yapcad.package.core.create_package_from_entities(entities: Sequence[list], target_dir: Path | str, *, name: str, version: str, description: str | None = None, author: str | None = None, units: str | None = None, materials: Dict[str, Dict[str, Any]] | None = None, generator: Dict[str, Any] | None = None, overwrite: bool = False, hash_algorithm: str = 'sha256') PackageManifest[source]
yapcad.package.core.load_geometry(manifest: PackageManifest) List[list][source]

yapcad.package.signing module

Package signing and verification for yapCAD packages.

This module provides cryptographic signing and verification of .ycpkg packages using GPG or SSH keys. It enables individual contributors to sign packages without requiring a centralized authority.

Usage:

from yapcad.package.signing import sign_package, verify_package

# Sign with GPG sign_package(“my_design.ycpkg”, method=”gpg”, key_id=”ABCD1234”)

# Sign with SSH sign_package(“my_design.ycpkg”, method=”ssh”, key_path=”~/.ssh/id_ed25519”)

# Verify result = verify_package(“my_design.ycpkg”) if result.is_valid:

print(f”Verified: {result.trusted_signers} trusted signatures”)

class yapcad.package.signing.SignatureInfo(signer: str, method: SignatureMethod, key_id: str, timestamp: str, signature_file: str, status: VerificationStatus | None = None, error_message: str | None = None)[source]

Bases: object

Information about a single signature.

error_message: str | None = None
key_id: str
method: SignatureMethod
signature_file: str
signer: str
status: VerificationStatus | None = None
timestamp: str
class yapcad.package.signing.SignatureMethod(*values)[source]

Bases: Enum

Supported signature methods.

GPG = 'gpg'
SSH = 'ssh'
exception yapcad.package.signing.SigningError[source]

Bases: Exception

Error during signing operation.

exception yapcad.package.signing.VerificationError[source]

Bases: Exception

Error during verification operation.

class yapcad.package.signing.VerificationResult(package_path: str, manifest_hash: str, signatures: List[SignatureInfo] = <factory>, errors: List[str] = <factory>, warnings: List[str] = <factory>)[source]

Bases: object

Result of package verification.

errors: List[str]
property is_valid: bool

True if at least one trusted signature is valid.

manifest_hash: str
property overall_status: VerificationStatus

Overall verification status.

package_path: str
signatures: List[SignatureInfo]
property trusted_signers: int

Number of valid, trusted signatures.

property untrusted_signers: int

Number of valid but untrusted signatures.

warnings: List[str]
class yapcad.package.signing.VerificationStatus(*values)[source]

Bases: Enum

Verification result status.

ERROR = 'ERROR'
INVALID = 'INVALID'
VALID = 'VALID'
VALID_UNTRUSTED = 'VALID_UNTRUSTED'
yapcad.package.signing.list_signatures(package_path: str | Path) List[SignatureInfo][source]

List all signatures on a package.

Parameters:

package_path – Path to .ycpkg package directory

Returns:

List of SignatureInfo for each signature

yapcad.package.signing.sign_package(package_path: str | Path, method: str | SignatureMethod = SignatureMethod.GPG, key_id: str | None = None, key_path: str | Path | None = None, add: bool = False, signer_name: str | None = None) SignatureInfo[source]

Sign a yapCAD package.

Parameters:
  • package_path – Path to .ycpkg package directory

  • method – “gpg” or “ssh”

  • key_id – GPG key ID (for GPG signing)

  • key_path – Path to SSH private key (for SSH signing)

  • add – If True, add signature without removing existing ones

  • signer_name – Override signer name in signature entry

Returns:

SignatureInfo for the new signature

yapcad.package.signing.verify_package(package_path: str | Path, allowed_signers: str | Path | None = None, gpg_keyring: str | Path | None = None) VerificationResult[source]

Verify signatures on a yapCAD package.

Parameters:
  • package_path – Path to .ycpkg package directory

  • allowed_signers – Path to SSH allowed_signers file

  • gpg_keyring – Path to custom GPG keyring

Returns:

VerificationResult with status of all signatures

yapcad.package.validator module

Validation utilities for .ycpkg packages.

yapcad.package.validator.validate_package(path: Path | str, *, strict: bool = False) Tuple[bool, List[str]][source]

Validate manifest and referenced artefacts.

Returns (is_valid, messages). Messages are strings with severity prefixes.

yapcad.package.viewer module

Interactive viewer for yapCAD .ycpkg packages.

yapcad.package.viewer.view_package(package_path: Path | str, *, strict: bool = False) bool[source]

Validate a package and launch appropriate viewer.

Module contents

Public API for yapCAD .ycpkg package workflows.