Skip to main content

ub-project

A library for the sphinx-needs family, which the extensions pull in – not a Sphinx extension, and nothing to add to conf.py.

It is the shared reader for ubproject.toml, the declarative file that describes a project to every useblocks tool: the sphinx-needs family of Sphinx extensions (sphinx-needs, sphinx-mounts, sphinx-codelinks, sphinx-test-reports), their command lines, and ubCode.

It holds the parts of that file more than one tool reads, so that they are read one way:

  • finding, loading and anchoring the file – the walk up to the repository root (or, outside a repository, the distribution root), TOML 1.1 read with every failure named, a dotted table selected, and relative paths anchored at the file’s own directory;

  • the [variants] table, with the legacy [needs] variant_data* keys as its fallback;

  • the variant-data merge – validate, load from JSON, deep-merge, resolve – in one copy.

Standard library only, plus the TOML 1.1 backport tomli below Python 3.15: no Sphinx, no docutils, no sibling distribution. A converter or a build action that runs without the documentation toolchain can use it.

The three calls

from pathlib import Path

from ub_project import find_project_config, load_toml, read_variants

toml_path = find_project_config(Path.cwd())   # or the path your tool is configured with
if toml_path is not None:
    result = read_variants(load_toml(toml_path), toml_path)
    result.data          # the merged variant map
    result.data_file     # the data file, anchored at the TOML's directory, or None
    result.location      # "variants", "needs" or None
    result.diagnostics   # findings to report -- or not

Every hard failure is an ProjectConfigError whose message names the file and the rule that was broken.

[variants]

[variants]
data_file = "variants.json"   # one path, anchored at this file's directory

[variants.data]               # deep-merged over the file; the inline table wins
edition = "pro"
build = { debug = false }

If [variants] declares neither key, the reader falls back to [needs] variant_data and [needs] variant_data_file. If both locations are set, [variants] is read whole and every ignored [needs] key is reported.

Consumers decide the policy

This package decides nothing a consumer has reason to decide differently. Discovery (walk up, or read the Sphinx confdir), warnings (a diagnostic is returned, never logged: whether the legacy location deserves one is each tool’s call), and the command line (-D in Sphinx, -c in ubCode) are all the consumer’s.

The contract

design/reading-contract.md is the normative specification, and tests/fixtures/ubproject_reading_conformance.toml is its executable half: a corpus of inputs and expected results that this package’s suite runs, and that ubCode is to vendor and run against its own reader (its reader does not read [variants] yet).

Metadata

Release files for ub-project 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ub-project 1.3.0
File Size Uploaded Provenance Actions
ub_project-1.3.0.tar.gz 15.5 kB Without provenance Details for ub_project-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ub-project 1.3.0
File Interpreter ABI Platform Actions
ub_project-1.3.0-py3-none-any.whl Python 3 none any Details for ub_project-1.3.0-py3-none-any.whl

Total release size: 32.4 kB

Release files / ub_project-1.3.0.tar.gz

Download URL ub_project-1.3.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
17ac4adfceddb3256dd671ae75f804233641c3f3efa44bc1195f47d93a0c371f
BLAKE2b-256 checksum
How to use checksums
0a1bf8fcaf2f6566243f62258b21cc9e4321c2db32430a32c5ba6d64b62780a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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 / ub_project-1.3.0-py3-none-any.whl

Download URL ub_project-1.3.0-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe849be49ef57ae9d85de2a84875fec65032d3600fb8c94bf4b94eb0d6a1388a
BLAKE2b-256 checksum
How to use checksums
511cd60d7658b44e26aba2cac9dbbca9af4e55d0162e7f7ea1d6f8bdb99899c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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 ub-project 1.3.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.

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