Skip to main content

Conditional entry point script provider for scikit-build-core

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skbuild_conditional_scripts-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skbuild_conditional_scripts-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file skbuild_conditional_scripts-1.0.0.tar.gz.

File metadata

File hashes

Hashes for skbuild_conditional_scripts-1.0.0.tar.gz
Algorithm Hash digest
SHA256 116c198557ebf7f67bfc3b4e80cef8ae8ca90e4d5f9c06eee8fc5c7f1b36920a
MD5 c153b3d60c1b407971aeb58fcfc6fe09
BLAKE2b-256 5c57adc589f0b42ee9385d9f66774b47bbddb022723a87aae6653d75b2afc3c2

See more details on using hashes here.

File details

Details for the file skbuild_conditional_scripts-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for skbuild_conditional_scripts-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d84f192e17a82b81027a8f4109cbe27e252922c60fe14bcae870b483a909faa
MD5 4733a6551bd06b340e6e213eab015cef
BLAKE2b-256 9455b2adc4faf3ab83c01b4b4c0d00b027cd92e617f2eedd5cbace8cfa7a9e42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page