2026-04-15 17:06:04 +05:30
#!/usr/bin/env -S uv run --script
2023-09-26 11:23:20 -05:00
2024-05-13 23:40:34 -04:00
# /// script
# dependencies = ["pyyaml"]
# ///
2023-10-09 09:36:09 -04:00
import argparse
2023-09-26 11:23:20 -05:00
import copy
import json
from typing import Any
import yaml
2025-08-14 14:44:05 -04:00
parser = argparse . ArgumentParser ( allow_abbrev = False )
2023-10-09 09:36:09 -04:00
parser . add_argument ( "--schemastore" , action = "store_true" , help = "Generate schema_store version" )
args = parser . parse_args ()
2026-05-29 05:27:28 +01:00
# The defaults in the schema are used by external tools for validation and IDE support. They
# should match the values in defaults.toml, which are used by cibuildwheel itself.
2023-09-26 11:23:20 -05:00
starter = """
2025-05-29 19:44:38 -04:00
$schema: http://json-schema.org/draft-07/schema#
2024-03-12 11:25:23 -04:00
$id: https://github.com/pypa/cibuildwheel/blob/main/cibuildwheel/resources/cibuildwheel.schema.json
$defs:
2024-03-02 16:58:18 -05:00
inherit:
enum:
- none
- prepend
- append
default: none
description: How to inherit the parent's value.
2024-11-14 11:39:52 -05:00
enable:
enum:
- cpython-prerelease
2025-06-03 04:35:59 +01:00
- graalpy
- pyodide-prerelease
2024-11-14 11:39:52 -05:00
- pypy
2025-05-15 09:06:48 -04:00
- pypy-eol
2024-11-14 11:39:52 -05:00
description: A Python version or flavor to enable.
2024-03-12 11:25:23 -04:00
additionalProperties: false
description: cibuildwheel's settings.
type: object
2023-09-26 11:23:20 -05:00
properties:
2026-05-14 15:41:14 +01:00
audit-command:
description: Execute a shell command to audit each wheel after it is repaired. Use {wheel} for each wheel path, or {abi3_wheel} to only audit abi3 wheels.
type: string_array
audit-requires:
description: Install Python dependencies for the audit step.
type: string_array
2023-09-26 11:23:20 -05:00
archs:
description: Change the architectures built on your machine by default.
type: string_array
before-all:
description: Execute a shell command on the build system before any wheels are built.
type: string_array
before-build:
description: Execute a shell command preparing each wheel's build.
type: string_array
before-test:
description: Execute a shell command before testing each wheel.
type: string_array
build:
default: ['*']
description: Choose the Python versions to build.
type: string_array
build-frontend:
default: default
2026-02-05 12:08:36 -05:00
description: Set the tool to use to build, either "build" (default), "build[uv]", "uv", or "pip"
2023-09-26 11:23:20 -05:00
oneOf:
2026-02-05 12:08:36 -05:00
- enum: [pip, build, "build[uv]", uv, default]
2023-09-26 11:23:20 -05:00
- type: string
pattern: '^pip; ?args:'
- type: string
pattern: '^build; ?args:'
2024-06-09 15:45:31 -04:00
- type: string
2024-06-11 00:32:38 -04:00
pattern: '^build \\ [uv \\ ]; ?args:'
2026-02-05 12:08:36 -05:00
- type: string
pattern: '^uv; ?args:'
2023-09-26 11:23:20 -05:00
- type: object
additionalProperties: false
required: [name]
properties:
name:
2026-02-05 12:08:36 -05:00
enum: [pip, build, "build[uv]", uv]
2023-09-26 11:23:20 -05:00
args:
type: array
items:
type: string
build-verbosity:
type: integer
minimum: -3
maximum: 3
default: 0
description: Increase/decrease the output of pip wheel.
config-settings:
description: Specify config-settings for the build backend.
type: string_table_array
container-engine:
oneOf:
- enum: [docker, podman]
- type: string
2023-11-21 22:25:20 +00:00
pattern: '^docker; ?(create_args|disable_host_mount):'
2023-09-26 11:23:20 -05:00
- type: string
2023-11-21 22:25:20 +00:00
pattern: '^podman; ?(create_args|disable_host_mount):'
2023-09-26 11:23:20 -05:00
- type: object
additionalProperties: false
required: [name]
properties:
name:
enum: [docker, podman]
create-args:
type: array
items:
type: string
2023-11-21 22:25:20 +00:00
disable-host-mount:
type: boolean
2023-09-26 11:23:20 -05:00
dependency-versions:
default: pinned
description: Specify how cibuildwheel controls the versions of the tools it uses
2025-03-10 21:45:54 +00:00
oneOf:
- enum: [pinned, latest]
- type: string
description: Path to a file containing dependency versions, or inline package specifications, starting with "packages:"
not:
enum: [pinned, latest]
- type: object
additionalProperties: false
properties:
file:
type: string
- type: object
additionalProperties: false
properties:
packages:
type: array
items:
type: string
2024-11-14 11:39:52 -05:00
enable:
description: Enable or disable certain builds.
oneOf:
- $ref: "#/$defs/enable"
- type: array
items:
$ref: "#/$defs/enable"
2023-09-26 11:23:20 -05:00
environment:
description: Set environment variables needed during the build.
type: string_table
environment-pass:
description: Set environment variables on the host to pass-through to the container
during the build.
type: string_array
manylinux-aarch64-image:
type: string
description: Specify alternative manylinux / musllinux container images
2024-11-16 01:07:24 +01:00
manylinux-armv7l-image:
type: string
description: Specify alternative manylinux / musllinux container images
2023-09-26 11:23:20 -05:00
manylinux-i686-image:
type: string
description: Specify alternative manylinux / musllinux container images
manylinux-ppc64le-image:
type: string
description: Specify alternative manylinux / musllinux container images
manylinux-pypy_aarch64-image:
type: string
description: Specify alternative manylinux / musllinux container images
manylinux-pypy_i686-image:
type: string
description: Specify alternative manylinux / musllinux container images
manylinux-pypy_x86_64-image:
type: string
description: Specify alternative manylinux / musllinux container images
2025-04-28 18:05:03 +02:00
manylinux-riscv64-image:
type: string
description: Specify alternative manylinux / musllinux container images
2023-09-26 11:23:20 -05:00
manylinux-s390x-image:
type: string
description: Specify alternative manylinux / musllinux container images
manylinux-x86_64-image:
type: string
description: Specify alternative manylinux / musllinux container images
musllinux-aarch64-image:
type: string
description: Specify alternative manylinux / musllinux container images
2024-10-01 16:33:57 +02:00
musllinux-armv7l-image:
type: string
description: Specify alternative manylinux / musllinux container images
2023-09-26 11:23:20 -05:00
musllinux-i686-image:
type: string
description: Specify alternative manylinux / musllinux container images
musllinux-ppc64le-image:
type: string
description: Specify alternative manylinux / musllinux container images
2025-04-28 18:05:03 +02:00
musllinux-riscv64-image:
type: string
description: Specify alternative manylinux / musllinux container images
2023-09-26 11:23:20 -05:00
musllinux-s390x-image:
type: string
description: Specify alternative manylinux / musllinux container images
musllinux-x86_64-image:
type: string
description: Specify alternative manylinux / musllinux container images
2025-04-07 14:20:20 +08:00
xbuild-tools:
description: Binaries on the path that should be included in an isolated cross-build environment
2023-09-26 11:23:20 -05:00
type: string_array
2026-05-29 05:27:28 +01:00
xbuild-files:
description: Platform-specific files in the build environment
type: string_table_array
2025-05-21 02:29:58 +05:30
pyodide-version:
type: string
description: Specify the version of Pyodide to use
2025-04-07 14:20:20 +08:00
repair-wheel-command:
2023-09-26 11:23:20 -05:00
description: Execute a shell command to repair each built wheel.
2025-04-07 14:20:20 +08:00
type: string_array
2023-09-26 11:23:20 -05:00
skip:
description: Choose the Python versions to skip.
type: string_array
test-command:
description: Execute a shell command to test each built wheel.
type: string_array
test-extras:
description: Install your wheel for testing using `extras_require`
type: string_array
2025-02-03 20:10:44 +00:00
test-sources:
description: Test files that are required by the test environment
type: string_array
2024-11-04 15:25:01 -05:00
test-groups:
description: Install extra groups when testing
type: string_array
2023-09-26 11:23:20 -05:00
test-requires:
description: Install Python dependencies before running the tests
type: string_array
test-skip:
description: Skip running tests on some builds.
type: string_array
2025-05-20 13:41:26 +01:00
test-environment:
description: Set environment variables for the test environment
type: string_table
2025-11-06 05:19:41 +08:00
test-runtime:
description: Additional configuration for the test runner
oneOf:
- type: string
pattern: '^$'
- type: object
additionalProperties: false
- type: string
pattern: 'args:'
- type: object
additionalProperties: false
required: [args]
properties:
args:
type: array
items:
type: string
2023-09-26 11:23:20 -05:00
"""
schema = yaml . safe_load ( starter )
string_array = yaml . safe_load (
"""
- type: string
- type: array
items:
type: string
"""
)
string_table_array = yaml . safe_load (
"""
- type: string
- type: object
additionalProperties: false
patternProperties:
.+:
oneOf:
- type: string
- type: array
items:
type: string
"""
)
string_table = yaml . safe_load (
"""
- type: string
- type: object
additionalProperties: false
patternProperties:
.+:
2023-10-09 09:36:09 -04:00
type: string
2023-09-26 11:23:20 -05:00
"""
)
for value in schema [ "properties" ] . values ():
match value :
case { "type" : "string_array" }:
del value [ "type" ]
value [ "oneOf" ] = string_array
case { "type" : "string_table" }:
del value [ "type" ]
value [ "oneOf" ] = string_table
case { "type" : "string_table_array" }:
del value [ "type" ]
value [ "oneOf" ] = string_table_array
overrides = yaml . safe_load (
"""
type: array
description: An overrides array
items:
type: object
required: ["select"]
2023-09-28 19:32:18 -04:00
minProperties: 2
2023-09-26 11:23:20 -05:00
additionalProperties: false
properties:
select: {}
2024-03-02 16:58:18 -05:00
inherit:
type: object
additionalProperties: false
properties:
2026-05-14 15:41:14 +01:00
audit-command: {"$ref": "#/$defs/inherit"}
audit-requires: {"$ref": "#/$defs/inherit"}
2024-03-12 11:25:23 -04:00
before-all: {"$ref": "#/$defs/inherit"}
before-build: {"$ref": "#/$defs/inherit"}
2025-04-07 14:20:20 +08:00
xbuild-tools: {"$ref": "#/$defs/inherit"}
2026-05-29 05:27:28 +01:00
xbuild-files: {"$ref": "#/$defs/inherit"}
2024-03-12 11:25:23 -04:00
before-test: {"$ref": "#/$defs/inherit"}
config-settings: {"$ref": "#/$defs/inherit"}
container-engine: {"$ref": "#/$defs/inherit"}
environment: {"$ref": "#/$defs/inherit"}
environment-pass: {"$ref": "#/$defs/inherit"}
repair-wheel-command: {"$ref": "#/$defs/inherit"}
test-command: {"$ref": "#/$defs/inherit"}
test-extras: {"$ref": "#/$defs/inherit"}
2025-02-03 20:10:44 +00:00
test-sources: {"$ref": "#/$defs/inherit"}
2024-03-12 11:25:23 -04:00
test-requires: {"$ref": "#/$defs/inherit"}
2025-05-20 13:41:26 +01:00
test-environment: {"$ref": "#/$defs/inherit"}
2025-11-06 05:19:41 +08:00
test-runtime: {"$ref": "#/$defs/inherit"}
2023-09-26 11:23:20 -05:00
"""
)
2023-09-28 12:35:07 -04:00
for key , value in schema [ "properties" ] . items ():
2025-01-20 11:17:01 +00:00
value [ "title" ] = f "CIBW_ { key . replace ( '-' , '_' ) . upper () } "
2023-09-28 12:35:07 -04:00
2024-03-02 16:58:18 -05:00
non_global_options = { k : { "$ref" : f "#/properties/ { k } " } for k in schema [ "properties" ]}
2023-09-26 11:23:20 -05:00
del non_global_options [ "build" ]
del non_global_options [ "skip" ]
del non_global_options [ "test-skip" ]
2024-11-14 11:39:52 -05:00
del non_global_options [ "enable" ]
2023-09-26 11:23:20 -05:00
overrides [ "items" ][ "properties" ][ "select" ][ "oneOf" ] = string_array
overrides [ "items" ][ "properties" ] |= non_global_options . copy ()
del overrides [ "items" ][ "properties" ][ "archs" ]
not_linux = non_global_options . copy ()
del not_linux [ "environment-pass" ]
2024-05-20 07:47:10 +01:00
del not_linux [ "container-engine" ]
2023-09-26 11:23:20 -05:00
for key in list ( not_linux ):
if "linux-" in key :
del not_linux [ key ]
def as_object ( d : dict [ str , Any ]) -> dict [ str , Any ]:
return {
"type" : "object" ,
"additionalProperties" : False ,
"properties" : copy . deepcopy ( d ),
}
oses = {
"linux" : as_object ( non_global_options ),
"windows" : as_object ( not_linux ),
"macos" : as_object ( not_linux ),
2024-05-28 05:31:36 -07:00
"pyodide" : as_object ( not_linux ),
2025-07-23 22:18:33 +01:00
"android" : as_object ( not_linux ),
2025-03-12 04:48:35 +08:00
"ios" : as_object ( not_linux ),
2023-09-26 11:23:20 -05:00
}
2026-05-29 05:27:28 +01:00
for os_name , command in [
( "linux" , "auditwheel repair -w {dest_dir} {wheel} " ),
2026-05-29 13:51:09 -04:00
( "windows" , "delvewheel repair -w {dest_dir} -v {wheel} " ),
2026-05-29 05:27:28 +01:00
( "macos" , "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} " ),
( "android" , "auditwheel repair --ldpaths {ldpaths} -w {dest_dir} {wheel} " ),
]:
oses [ os_name ][ "properties" ][ "repair-wheel-command" ] = {
** schema [ "properties" ][ "repair-wheel-command" ],
"default" : command ,
}
2023-09-26 11:23:20 -05:00
del oses [ "linux" ][ "properties" ][ "dependency-versions" ]
schema [ "properties" ][ "overrides" ] = overrides
schema [ "properties" ] |= oses
2024-03-02 16:58:18 -05:00
if args . schemastore :
schema [ "$id" ] = "https://json.schemastore.org/partial-cibuildwheel.json"
2024-03-15 13:27:39 -04:00
schema [ "description" ] = (
2025-06-14 08:58:57 -04:00
"cibuildwheel's settings. Generated with ./bin/generate_schema.py --schemastore from cibuildwheel."
2024-03-15 13:27:39 -04:00
)
2023-10-09 09:36:09 -04:00
2024-03-02 16:58:18 -05:00
print ( json . dumps ( schema , indent = 2 ))