diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d17b785b..dab884af3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: hooks: - id: mypy name: mypy 3.8 on cibuildwheel/ - exclude: ^cibuildwheel/resources/.*py$ + exclude: ^cibuildwheel/resources/.*py|bin/generate_schema.py$ args: ["--python-version=3.8"] additional_dependencies: &mypy-dependencies - nox diff --git a/bin/generate_schema.py b/bin/generate_schema.py new file mode 100755 index 000000000..3cb54bc55 --- /dev/null +++ b/bin/generate_schema.py @@ -0,0 +1,233 @@ +#!/usr/bin/env python + +import json + +import yaml + +starter = """ +$id: https://github.com/pypa/cibuildwheel/blob/main/cibuildwheel/resources/cibuildwheel.schema.json +$schema: http://json-schema.org/draft-07/schema +additionalProperties: false +description: cibulidwheel's settings. +type: object +properties: + 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 + description: Set the tool to use to build, either "pip" (default for now) or "build" + oneOf: + - enum: [pip, build, default] + - type: string + pattern: '^pip; ?args:' + - type: string + pattern: '^build; ?args:' + - type: object + additionalProperties: false + required: [name] + properties: + name: + enum: [pip, build] + 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 + pattern: '^docker; ?create_args:' + - type: string + pattern: '^podman; ?create_args:' + - type: object + additionalProperties: false + required: [name] + properties: + name: + enum: [docker, podman] + create-args: + type: array + items: + type: string + dependency-versions: + default: pinned + description: Specify how cibuildwheel controls the versions of the tools it uses + type: string + 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 + 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 + 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 + musllinux-i686-image: + type: string + description: Specify alternative manylinux / musllinux container images + musllinux-ppc64le-image: + type: string + description: Specify alternative manylinux / musllinux container images + 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 + repair-wheel-command: + type: string_array + description: Execute a shell command to repair each built wheel. + 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 + 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 +""" + +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 +- patternProperties: + .+: + oneOf: + - type: string + - type: array + items: + type: string +""" +) + +string_table = yaml.safe_load( + """ +- type: string +- patternProperties: + .+: + - type: string +""" +) + +for key, value in schema["properties"].items(): + value["title"] = f'CIBW_{key.replace("-", "_").upper()}' + 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"] + additionalProperties: false + properties: + select: {} +""" +) + +limited = schema["properties"].copy() +del limited["build"] +del limited["skip"] + +overrides["items"]["properties"]["select"]["oneOf"] = string_array +overrides["items"]["properties"] |= limited.copy() + +del limited["archs"] + +not_linux = limited.copy() + +del not_linux["environment-pass"] +del not_linux["container-engine"] +for key in list(not_linux): + if "linux-" in key: + del not_linux[key] + +oses = {"linux": limited.copy(), "windows": not_linux.copy(), "macos": not_linux.copy()} + +oses["linux"]["repair-wheel-command"]["default"] = "auditwheel repair -w {dest_dir} {wheel}" +oses["macos"]["repair-wheel-command"][ + "default" +] = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" + +del oses["linux"]["dependency-versions"] + +schema["properties"]["overrides"] = overrides +schema["properties"] |= oses + +print(json.dumps(schema, indent=2)) diff --git a/cibuildwheel/resources/cibuildwheel.schema.json b/cibuildwheel/resources/cibuildwheel.schema.json new file mode 100644 index 000000000..002dc5731 --- /dev/null +++ b/cibuildwheel/resources/cibuildwheel.schema.json @@ -0,0 +1,1568 @@ +{ + "$id": "https://github.com/pypa/cibuildwheel/blob/main/cibuildwheel/resources/toml_schema.json", + "$schema": "http://json-schema.org/draft-07/schema", + "additionalProperties": false, + "description": "cibulidwheel's settings.", + "type": "object", + "properties": { + "archs": { + "description": "Change the architectures built on your machine by default.", + "title": "CIBW_ARCHS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-all": { + "description": "Execute a shell command on the build system before any wheels are built.", + "title": "CIBW_BEFORE_ALL", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-build": { + "description": "Execute a shell command preparing each wheel's build.", + "title": "CIBW_BEFORE_BUILD", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-test": { + "description": "Execute a shell command before testing each wheel.", + "title": "CIBW_BEFORE_TEST", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "build": { + "default": [ + "*" + ], + "description": "Choose the Python versions to build.", + "title": "CIBW_BUILD", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "build-frontend": { + "default": "default", + "description": "Set the tool to use to build, either \"pip\" (default for now) or \"build\"", + "oneOf": [ + { + "enum": [ + "pip", + "build", + "default" + ] + }, + { + "type": "string", + "pattern": "^pip; ?args:" + }, + { + "type": "string", + "pattern": "^build; ?args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "pip", + "build" + ] + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_BUILD_FRONTEND" + }, + "build-verbosity": { + "type": "integer", + "minimum": -3, + "maximum": 3, + "default": 0, + "description": "Increase/decrease the output of pip wheel.", + "title": "CIBW_BUILD_VERBOSITY" + }, + "config-settings": { + "description": "Specify config-settings for the build backend.", + "title": "CIBW_CONFIG_SETTINGS", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } + ] + }, + "container-engine": { + "oneOf": [ + { + "enum": [ + "docker", + "podman" + ] + }, + { + "type": "string", + "pattern": "^docker; ?create_args:" + }, + { + "type": "string", + "pattern": "^podman; ?create_args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "docker", + "podman" + ] + }, + "create-args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_CONTAINER_ENGINE" + }, + "dependency-versions": { + "default": "pinned", + "description": "Specify how cibuildwheel controls the versions of the tools it uses", + "type": "string", + "title": "CIBW_DEPENDENCY_VERSIONS" + }, + "environment": { + "description": "Set environment variables needed during the build.", + "title": "CIBW_ENVIRONMENT", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": [ + { + "type": "string" + } + ] + } + } + ] + }, + "environment-pass": { + "description": "Set environment variables on the host to pass-through to the container during the build.", + "title": "CIBW_ENVIRONMENT_PASS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "manylinux-aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_AARCH64_IMAGE" + }, + "manylinux-i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_I686_IMAGE" + }, + "manylinux-ppc64le-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PPC64LE_IMAGE" + }, + "manylinux-pypy_aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_AARCH64_IMAGE" + }, + "manylinux-pypy_i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_I686_IMAGE" + }, + "manylinux-pypy_x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_X86_64_IMAGE" + }, + "manylinux-s390x-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_S390X_IMAGE" + }, + "manylinux-x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_X86_64_IMAGE" + }, + "musllinux-aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_AARCH64_IMAGE" + }, + "musllinux-i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_I686_IMAGE" + }, + "musllinux-ppc64le-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_PPC64LE_IMAGE" + }, + "musllinux-s390x-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_S390X_IMAGE" + }, + "musllinux-x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_X86_64_IMAGE" + }, + "repair-wheel-command": { + "description": "Execute a shell command to repair each built wheel.", + "title": "CIBW_REPAIR_WHEEL_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ], + "default": "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" + }, + "skip": { + "description": "Choose the Python versions to skip.", + "title": "CIBW_SKIP", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-command": { + "description": "Execute a shell command to test each built wheel.", + "title": "CIBW_TEST_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-extras": { + "description": "Install your wheel for testing using `extras_require`", + "title": "CIBW_TEST_EXTRAS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-requires": { + "description": "Install Python dependencies before running the tests", + "title": "CIBW_TEST_REQUIRES", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-skip": { + "description": "Skip running tests on some builds.", + "title": "CIBW_TEST_SKIP", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "overrides": { + "type": "array", + "description": "An overrides array", + "items": { + "type": "object", + "required": [ + "select" + ], + "additionalProperties": false, + "properties": { + "select": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "archs": { + "description": "Change the architectures built on your machine by default.", + "title": "CIBW_ARCHS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-all": { + "description": "Execute a shell command on the build system before any wheels are built.", + "title": "CIBW_BEFORE_ALL", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-build": { + "description": "Execute a shell command preparing each wheel's build.", + "title": "CIBW_BEFORE_BUILD", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-test": { + "description": "Execute a shell command before testing each wheel.", + "title": "CIBW_BEFORE_TEST", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "build-frontend": { + "default": "default", + "description": "Set the tool to use to build, either \"pip\" (default for now) or \"build\"", + "oneOf": [ + { + "enum": [ + "pip", + "build", + "default" + ] + }, + { + "type": "string", + "pattern": "^pip; ?args:" + }, + { + "type": "string", + "pattern": "^build; ?args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "pip", + "build" + ] + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_BUILD_FRONTEND" + }, + "build-verbosity": { + "type": "integer", + "minimum": -3, + "maximum": 3, + "default": 0, + "description": "Increase/decrease the output of pip wheel.", + "title": "CIBW_BUILD_VERBOSITY" + }, + "config-settings": { + "description": "Specify config-settings for the build backend.", + "title": "CIBW_CONFIG_SETTINGS", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } + ] + }, + "container-engine": { + "oneOf": [ + { + "enum": [ + "docker", + "podman" + ] + }, + { + "type": "string", + "pattern": "^docker; ?create_args:" + }, + { + "type": "string", + "pattern": "^podman; ?create_args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "docker", + "podman" + ] + }, + "create-args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_CONTAINER_ENGINE" + }, + "dependency-versions": { + "default": "pinned", + "description": "Specify how cibuildwheel controls the versions of the tools it uses", + "type": "string", + "title": "CIBW_DEPENDENCY_VERSIONS" + }, + "environment": { + "description": "Set environment variables needed during the build.", + "title": "CIBW_ENVIRONMENT", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": [ + { + "type": "string" + } + ] + } + } + ] + }, + "environment-pass": { + "description": "Set environment variables on the host to pass-through to the container during the build.", + "title": "CIBW_ENVIRONMENT_PASS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "manylinux-aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_AARCH64_IMAGE" + }, + "manylinux-i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_I686_IMAGE" + }, + "manylinux-ppc64le-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PPC64LE_IMAGE" + }, + "manylinux-pypy_aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_AARCH64_IMAGE" + }, + "manylinux-pypy_i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_I686_IMAGE" + }, + "manylinux-pypy_x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_X86_64_IMAGE" + }, + "manylinux-s390x-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_S390X_IMAGE" + }, + "manylinux-x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_X86_64_IMAGE" + }, + "musllinux-aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_AARCH64_IMAGE" + }, + "musllinux-i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_I686_IMAGE" + }, + "musllinux-ppc64le-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_PPC64LE_IMAGE" + }, + "musllinux-s390x-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_S390X_IMAGE" + }, + "musllinux-x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_X86_64_IMAGE" + }, + "repair-wheel-command": { + "description": "Execute a shell command to repair each built wheel.", + "title": "CIBW_REPAIR_WHEEL_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ], + "default": "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" + }, + "test-command": { + "description": "Execute a shell command to test each built wheel.", + "title": "CIBW_TEST_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-extras": { + "description": "Install your wheel for testing using `extras_require`", + "title": "CIBW_TEST_EXTRAS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-requires": { + "description": "Install Python dependencies before running the tests", + "title": "CIBW_TEST_REQUIRES", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-skip": { + "description": "Skip running tests on some builds.", + "title": "CIBW_TEST_SKIP", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } + }, + "linux": { + "before-all": { + "description": "Execute a shell command on the build system before any wheels are built.", + "title": "CIBW_BEFORE_ALL", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-build": { + "description": "Execute a shell command preparing each wheel's build.", + "title": "CIBW_BEFORE_BUILD", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-test": { + "description": "Execute a shell command before testing each wheel.", + "title": "CIBW_BEFORE_TEST", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "build-frontend": { + "default": "default", + "description": "Set the tool to use to build, either \"pip\" (default for now) or \"build\"", + "oneOf": [ + { + "enum": [ + "pip", + "build", + "default" + ] + }, + { + "type": "string", + "pattern": "^pip; ?args:" + }, + { + "type": "string", + "pattern": "^build; ?args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "pip", + "build" + ] + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_BUILD_FRONTEND" + }, + "build-verbosity": { + "type": "integer", + "minimum": -3, + "maximum": 3, + "default": 0, + "description": "Increase/decrease the output of pip wheel.", + "title": "CIBW_BUILD_VERBOSITY" + }, + "config-settings": { + "description": "Specify config-settings for the build backend.", + "title": "CIBW_CONFIG_SETTINGS", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } + ] + }, + "container-engine": { + "oneOf": [ + { + "enum": [ + "docker", + "podman" + ] + }, + { + "type": "string", + "pattern": "^docker; ?create_args:" + }, + { + "type": "string", + "pattern": "^podman; ?create_args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "docker", + "podman" + ] + }, + "create-args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_CONTAINER_ENGINE" + }, + "environment": { + "description": "Set environment variables needed during the build.", + "title": "CIBW_ENVIRONMENT", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": [ + { + "type": "string" + } + ] + } + } + ] + }, + "environment-pass": { + "description": "Set environment variables on the host to pass-through to the container during the build.", + "title": "CIBW_ENVIRONMENT_PASS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "manylinux-aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_AARCH64_IMAGE" + }, + "manylinux-i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_I686_IMAGE" + }, + "manylinux-ppc64le-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PPC64LE_IMAGE" + }, + "manylinux-pypy_aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_AARCH64_IMAGE" + }, + "manylinux-pypy_i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_I686_IMAGE" + }, + "manylinux-pypy_x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_PYPY_X86_64_IMAGE" + }, + "manylinux-s390x-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_S390X_IMAGE" + }, + "manylinux-x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MANYLINUX_X86_64_IMAGE" + }, + "musllinux-aarch64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_AARCH64_IMAGE" + }, + "musllinux-i686-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_I686_IMAGE" + }, + "musllinux-ppc64le-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_PPC64LE_IMAGE" + }, + "musllinux-s390x-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_S390X_IMAGE" + }, + "musllinux-x86_64-image": { + "type": "string", + "description": "Specify alternative manylinux / musllinux container images", + "title": "CIBW_MUSLLINUX_X86_64_IMAGE" + }, + "repair-wheel-command": { + "description": "Execute a shell command to repair each built wheel.", + "title": "CIBW_REPAIR_WHEEL_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ], + "default": "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" + }, + "test-command": { + "description": "Execute a shell command to test each built wheel.", + "title": "CIBW_TEST_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-extras": { + "description": "Install your wheel for testing using `extras_require`", + "title": "CIBW_TEST_EXTRAS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-requires": { + "description": "Install Python dependencies before running the tests", + "title": "CIBW_TEST_REQUIRES", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-skip": { + "description": "Skip running tests on some builds.", + "title": "CIBW_TEST_SKIP", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + }, + "windows": { + "before-all": { + "description": "Execute a shell command on the build system before any wheels are built.", + "title": "CIBW_BEFORE_ALL", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-build": { + "description": "Execute a shell command preparing each wheel's build.", + "title": "CIBW_BEFORE_BUILD", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-test": { + "description": "Execute a shell command before testing each wheel.", + "title": "CIBW_BEFORE_TEST", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "build-frontend": { + "default": "default", + "description": "Set the tool to use to build, either \"pip\" (default for now) or \"build\"", + "oneOf": [ + { + "enum": [ + "pip", + "build", + "default" + ] + }, + { + "type": "string", + "pattern": "^pip; ?args:" + }, + { + "type": "string", + "pattern": "^build; ?args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "pip", + "build" + ] + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_BUILD_FRONTEND" + }, + "build-verbosity": { + "type": "integer", + "minimum": -3, + "maximum": 3, + "default": 0, + "description": "Increase/decrease the output of pip wheel.", + "title": "CIBW_BUILD_VERBOSITY" + }, + "config-settings": { + "description": "Specify config-settings for the build backend.", + "title": "CIBW_CONFIG_SETTINGS", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } + ] + }, + "dependency-versions": { + "default": "pinned", + "description": "Specify how cibuildwheel controls the versions of the tools it uses", + "type": "string", + "title": "CIBW_DEPENDENCY_VERSIONS" + }, + "environment": { + "description": "Set environment variables needed during the build.", + "title": "CIBW_ENVIRONMENT", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": [ + { + "type": "string" + } + ] + } + } + ] + }, + "repair-wheel-command": { + "description": "Execute a shell command to repair each built wheel.", + "title": "CIBW_REPAIR_WHEEL_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ], + "default": "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" + }, + "test-command": { + "description": "Execute a shell command to test each built wheel.", + "title": "CIBW_TEST_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-extras": { + "description": "Install your wheel for testing using `extras_require`", + "title": "CIBW_TEST_EXTRAS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-requires": { + "description": "Install Python dependencies before running the tests", + "title": "CIBW_TEST_REQUIRES", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-skip": { + "description": "Skip running tests on some builds.", + "title": "CIBW_TEST_SKIP", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + }, + "macos": { + "before-all": { + "description": "Execute a shell command on the build system before any wheels are built.", + "title": "CIBW_BEFORE_ALL", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-build": { + "description": "Execute a shell command preparing each wheel's build.", + "title": "CIBW_BEFORE_BUILD", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "before-test": { + "description": "Execute a shell command before testing each wheel.", + "title": "CIBW_BEFORE_TEST", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "build-frontend": { + "default": "default", + "description": "Set the tool to use to build, either \"pip\" (default for now) or \"build\"", + "oneOf": [ + { + "enum": [ + "pip", + "build", + "default" + ] + }, + { + "type": "string", + "pattern": "^pip; ?args:" + }, + { + "type": "string", + "pattern": "^build; ?args:" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "name" + ], + "properties": { + "name": { + "enum": [ + "pip", + "build" + ] + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "title": "CIBW_BUILD_FRONTEND" + }, + "build-verbosity": { + "type": "integer", + "minimum": -3, + "maximum": 3, + "default": 0, + "description": "Increase/decrease the output of pip wheel.", + "title": "CIBW_BUILD_VERBOSITY" + }, + "config-settings": { + "description": "Specify config-settings for the build backend.", + "title": "CIBW_CONFIG_SETTINGS", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } + ] + }, + "dependency-versions": { + "default": "pinned", + "description": "Specify how cibuildwheel controls the versions of the tools it uses", + "type": "string", + "title": "CIBW_DEPENDENCY_VERSIONS" + }, + "environment": { + "description": "Set environment variables needed during the build.", + "title": "CIBW_ENVIRONMENT", + "oneOf": [ + { + "type": "string" + }, + { + "patternProperties": { + ".+": [ + { + "type": "string" + } + ] + } + } + ] + }, + "repair-wheel-command": { + "description": "Execute a shell command to repair each built wheel.", + "title": "CIBW_REPAIR_WHEEL_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ], + "default": "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" + }, + "test-command": { + "description": "Execute a shell command to test each built wheel.", + "title": "CIBW_TEST_COMMAND", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-extras": { + "description": "Install your wheel for testing using `extras_require`", + "title": "CIBW_TEST_EXTRAS", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-requires": { + "description": "Install Python dependencies before running the tests", + "title": "CIBW_TEST_REQUIRES", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "test-skip": { + "description": "Skip running tests on some builds.", + "title": "CIBW_TEST_SKIP", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } +} diff --git a/cibuildwheel/resources/defaults.toml b/cibuildwheel/resources/defaults.toml index 40b42f6ee..cf748c629 100644 --- a/cibuildwheel/resources/defaults.toml +++ b/cibuildwheel/resources/defaults.toml @@ -9,7 +9,7 @@ config-settings = {} dependency-versions = "pinned" environment = {} environment-pass = [] -build-verbosity = "" +build-verbosity = 0 before-all = "" before-build = "" diff --git a/cibuildwheel/schema.py b/cibuildwheel/schema.py new file mode 100644 index 000000000..91ca26594 --- /dev/null +++ b/cibuildwheel/schema.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import json +from pathlib import Path +from typing import Any + +DIR = Path(__file__).parent.resolve() + + +def get_schema(tool_name: str = "cibuildwheel") -> dict[str, Any]: + "Get the stored complete schema for cibuildwheel settings." + assert tool_name == "cibuildwheel", "Only cibuildwheel is supported." + + with DIR.joinpath("resources/cibuildwheel.schema.json").open(encoding="utf-8") as f: + return json.load(f) # type: ignore[no-any-return] diff --git a/noxfile.py b/noxfile.py index 0e66647cd..0611deadf 100644 --- a/noxfile.py +++ b/noxfile.py @@ -113,6 +113,14 @@ def update_proj(session: nox.Session) -> None: ) +@nox.session(reuse_venv=True) +def generate_schema(session: nox.Session) -> None: + session.install("pyyaml", "ruamel.yaml") + output = session.run("python", "bin/generate_schema.py", silent=True) + assert isinstance(output, str) + DIR.joinpath("cibuildwheel/resources/cibuildwheel.schema.json").write_text(output) + + @nox.session(python="3.9") def docs(session: nox.Session) -> None: """ diff --git a/setup.cfg b/setup.cfg index e9e0c7cf5..fa75c2347 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,8 @@ include = [options.entry_points] console_scripts = cibuildwheel = cibuildwheel.__main__:main +validate_pyproject.tool_schema = + cibuildwheel = cibuildwheel.schema:get_schema [options.package_data] cibuildwheel = resources/* diff --git a/setup.py b/setup.py index 1ce3a00dd..90f83feda 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ "pytest-xdist", "build", "tomli_w", + "validate-pyproject", ], "bin": [ "click", diff --git a/unit_test/validate_schema.py b/unit_test/validate_schema.py new file mode 100644 index 000000000..111900aad --- /dev/null +++ b/unit_test/validate_schema.py @@ -0,0 +1,18 @@ +from pathlib import Path + +import pytest + +from cibuildwheel._compat import tomllib + +api = pytest.importorskip("validate_pyproject.api") + +DIR = Path(__file__).parent.resolve() + + +def test_validate_default_schema(): + filepath = DIR.parent / "cibuildwheel/resources/defaults.toml" + with filepath.open("rb") as f: + example = tomllib.load(f) + + validator = api.Validator() + assert validator(example) is not None