Conditional entry point script provider for scikit-build-core
Project description
skbuild-conditional-scripts
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:
- Reads configuration from
[tool.scikit-build.metadata.scripts] - Checks the specified environment variable
- Merges base scripts with conditional scripts if the condition matches
- 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
- WHO_NEEDS_THIS.md - When is this provider needed?
- DEPLOYMENT.md - Deployment options and strategies
- CONTRIBUTING.md - Contributing to this project
- README_SUMMARY.md - Quick navigation guide
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.
- Issues: GitHub Issues
- Discussions: Use issues for questions and discussions
- Contributing: See CONTRIBUTING.md
Related Projects
- scikit-build-core - Modern Python build backend for CMake
- AFDKO - Adobe Font Development Kit for OpenType
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file skbuild_conditional_scripts-1.0.0.tar.gz.
File metadata
- Download URL: skbuild_conditional_scripts-1.0.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
116c198557ebf7f67bfc3b4e80cef8ae8ca90e4d5f9c06eee8fc5c7f1b36920a
|
|
| MD5 |
c153b3d60c1b407971aeb58fcfc6fe09
|
|
| BLAKE2b-256 |
5c57adc589f0b42ee9385d9f66774b47bbddb022723a87aae6653d75b2afc3c2
|
File details
Details for the file skbuild_conditional_scripts-1.0.0-py3-none-any.whl.
File metadata
- Download URL: skbuild_conditional_scripts-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d84f192e17a82b81027a8f4109cbe27e252922c60fe14bcae870b483a909faa
|
|
| MD5 |
4733a6551bd06b340e6e213eab015cef
|
|
| BLAKE2b-256 |
9455b2adc4faf3ab83c01b4b4c0d00b027cd92e617f2eedd5cbace8cfa7a9e42
|