Skip to main content

skbuild-conditional-scripts

License Python

Generic dynamic script metadata provider for scikit-build-core projects.

This micro-package provides a reusable metadata provider that can conditionally install entry point scripts based on environment variables. Originally developed for AFDKO to choose between installing a C++ binary or Python wrapper, it can be used by any scikit-build-core project that needs conditional entry point generation.

Features

  • Data-driven: All script definitions live in pyproject.toml, not code
  • Conditional installation: Install different scripts based on environment variables
  • Generic: Can be reused by other projects with similar needs
  • Simple: ~70 lines of code, easy to understand and maintain

Installation

pip install skbuild-conditional-scripts

Or include in your project locally using provider-path.

Quick Start

Add to your pyproject.toml:

[build-system]
requires = ["scikit-build-core", "skbuild-conditional-scripts"]
build-backend = "scikit_build_core.build"

[tool.scikit-build.metadata.scripts]
provider = "skbuild_conditional_scripts"

# Always installed scripts
scripts = {
    "my-command" = "mypackage:main",
    "my-tool" = "mypackage.tools:cli",
}

# Conditionally installed scripts (only when MY_ENV_VAR=ON)
conditional-scripts = {
    "my-debug-tool" = "mypackage.debug:main",
}

condition-env-var = "MY_ENV_VAR"
condition-env-value = "ON"

Then build your project:

# Normal build - only base scripts installed
pip install .

# With condition - both base and conditional scripts installed
MY_ENV_VAR=ON pip install .

Use Cases

  • Binary vs Python wrapper: Install C++ binary or Python wrapper based on build configuration
  • Platform-specific commands: Different entry points for different platforms (via env vars)
  • Debug builds: Install additional debug tools only when requested
  • Optional features: Install extra commands when feature flags are enabled

How It Works

The provider is called during the metadata generation phase (before building). It:

  1. Reads configuration from [tool.scikit-build.metadata.scripts]
  2. Checks the specified environment variable
  3. Merges base scripts with conditional scripts if the condition matches
  4. Returns the combined dictionary to scikit-build-core

Note: This is a build-time tool. End users installing from PyPI wheels don't need it.

Documentation

Example: AFDKO

AFDKO uses this provider to choose between a C++ binary and Python wrapper:

[tool.scikit-build.metadata.scripts]
provider = "skbuild_conditional_scripts"

scripts = {
    # 30+ deprecated wrapper scripts always installed
    "tx" = "afdko._deprecated:tx_wrapper",
    "makeotf" = "afdko._deprecated:makeotf_wrapper",
    # ... etc
}

conditional-scripts = {
    # Python wrapper only when requested
    "afdko" = "afdko.invoker:main"
}

condition-env-var = "AFDKO_COMMAND_USE_WRAPPER"
condition-env-value = "ON"

Normal builds install the fast C++ binary. When building in environments where the C++ build fails, setting AFDKO_COMMAND_USE_WRAPPER=ON installs the Python wrapper instead.

Requirements

  • Python >= 3.10
  • scikit-build-core (as your build backend)

License

Apache License 2.0 - See LICENSE for details.

Support

This project is maintained by the Adobe Type team.

Related Projects

Metadata

Release files for skbuild-conditional-scripts 1.0.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 skbuild-conditional-scripts 1.0.0
File Size Uploaded Provenance
skbuild_conditional_scripts-1.0.0.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for skbuild-conditional-scripts 1.0.0
File Interpreter ABI Platform
skbuild_conditional_scripts-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / skbuild_conditional_scripts-1.0.0.tar.gz

Download URL skbuild_conditional_scripts-1.0.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
116c198557ebf7f67bfc3b4e80cef8ae8ca90e4d5f9c06eee8fc5c7f1b36920a
BLAKE2b-256 checksum
How to use checksums
5c57adc589f0b42ee9385d9f66774b47bbddb022723a87aae6653d75b2afc3c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / skbuild_conditional_scripts-1.0.0-py3-none-any.whl

Download URL skbuild_conditional_scripts-1.0.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d84f192e17a82b81027a8f4109cbe27e252922c60fe14bcae870b483a909faa
BLAKE2b-256 checksum
How to use checksums
9455b2adc4faf3ab83c01b4b4c0d00b027cd92e617f2eedd5cbace8cfa7a9e42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Security for skbuild-conditional-scripts 1.0.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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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