diff --git a/src/validate_pyproject/plugins/setuptools.schema.json b/src/validate_pyproject/plugins/setuptools.schema.json index 50ee621..ec887b3 100644 --- a/src/validate_pyproject/plugins/setuptools.schema.json +++ b/src/validate_pyproject/plugins/setuptools.schema.json @@ -158,6 +158,11 @@ "items": {"type": "string", "format": "python-module-name-relaxed"}, "$comment": "TODO: clarify the relationship with ``packages``" }, + "ext-modules": { + "description": "Extension modules to be compiled by setuptools", + "type": "array", + "items": {"$ref": "#/definitions/ext-module"} + }, "data-files": { "$$description": [ "``dict``-like structure where each key represents a directory and", @@ -254,6 +259,82 @@ {"type": "string", "format": "pep561-stub-name"} ] }, + "ext-module": { + "$id": "#/definitions/ext-module", + "title": "Extension module", + "description": "Parameters to construct a :class:`setuptools.Extension` object", + "type": "object", + "required": ["name", "sources"], + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "format": "python-module-name-relaxed" + }, + "sources": { + "type": "array", + "items": {"type": "string"} + }, + "include-dirs":{ + "type": "array", + "items": {"type": "string"} + }, + "define-macros": { + "type": "array", + "items": { + "type": "array", + "items": [ + {"description": "macro name", "type": "string"}, + {"description": "macro value", "oneOf": [{"type": "string"}, {"type": "null"}]} + ], + "additionalItems": false + } + }, + "undef-macros": { + "type": "array", + "items": {"type": "string"} + }, + "library-dirs": { + "type": "array", + "items": {"type": "string"} + }, + "libraries": { + "type": "array", + "items": {"type": "string"} + }, + "runtime-library-dirs": { + "type": "array", + "items": {"type": "string"} + }, + "extra-objects": { + "type": "array", + "items": {"type": "string"} + }, + "extra-compile-args": { + "type": "array", + "items": {"type": "string"} + }, + "extra-link-args": { + "type": "array", + "items": {"type": "string"} + }, + "export-symbols": { + "type": "array", + "items": {"type": "string"} + }, + "swig-opts": { + "type": "array", + "items": {"type": "string"} + }, + "depends": { + "type": "array", + "items": {"type": "string"} + }, + "language": {"type": "string"}, + "optional": {"type": "boolean"}, + "py-limited-api": {"type": "boolean"} + } + }, "file-directive": { "$id": "#/definitions/file-directive", "title": "'file:' directive", diff --git a/tests/examples/setuptools/11-pyproject.toml b/tests/examples/setuptools/11-pyproject.toml new file mode 100644 index 0000000..df3e156 --- /dev/null +++ b/tests/examples/setuptools/11-pyproject.toml @@ -0,0 +1,4 @@ +[tool.setuptools] +ext-modules = [ + {name = "my.ext", sources = ["hello.c", "world.c"]} +] diff --git a/tests/examples/setuptools/12-pyproject.toml b/tests/examples/setuptools/12-pyproject.toml new file mode 100644 index 0000000..c7ad560 --- /dev/null +++ b/tests/examples/setuptools/12-pyproject.toml @@ -0,0 +1,3 @@ +[[tool.setuptools.ext-modules]] +name = "my.ext" +sources = ["hello.c", "world.c"] diff --git a/tests/invalid-examples/setuptools/ext-modules/invalid-field.errors.txt b/tests/invalid-examples/setuptools/ext-modules/invalid-field.errors.txt new file mode 100644 index 0000000..56887b3 --- /dev/null +++ b/tests/invalid-examples/setuptools/ext-modules/invalid-field.errors.txt @@ -0,0 +1 @@ +must not contain {'non-existing-field'} diff --git a/tests/invalid-examples/setuptools/ext-modules/invalid-field.toml b/tests/invalid-examples/setuptools/ext-modules/invalid-field.toml new file mode 100644 index 0000000..e8875ef --- /dev/null +++ b/tests/invalid-examples/setuptools/ext-modules/invalid-field.toml @@ -0,0 +1,4 @@ +[[tool.setuptools.ext-modules]] +name = "hello.world" +sources = ["hello.c"] +non-existing-field = "hello" diff --git a/tests/invalid-examples/setuptools/ext-modules/invalid-sources.errors.txt b/tests/invalid-examples/setuptools/ext-modules/invalid-sources.errors.txt new file mode 100644 index 0000000..48fba1a --- /dev/null +++ b/tests/invalid-examples/setuptools/ext-modules/invalid-sources.errors.txt @@ -0,0 +1 @@ +must be array diff --git a/tests/invalid-examples/setuptools/ext-modules/invalid-sources.toml b/tests/invalid-examples/setuptools/ext-modules/invalid-sources.toml new file mode 100644 index 0000000..6cc1678 --- /dev/null +++ b/tests/invalid-examples/setuptools/ext-modules/invalid-sources.toml @@ -0,0 +1,3 @@ +[[tool.setuptools.ext-modules]] +name = "hello.world" +sources = "hello.c" diff --git a/tests/invalid-examples/setuptools/ext-modules/missing-ext-name.errors.txt b/tests/invalid-examples/setuptools/ext-modules/missing-ext-name.errors.txt new file mode 100644 index 0000000..625a290 --- /dev/null +++ b/tests/invalid-examples/setuptools/ext-modules/missing-ext-name.errors.txt @@ -0,0 +1 @@ +must contain ['name'] diff --git a/tests/invalid-examples/setuptools/ext-modules/missing-ext-name.toml b/tests/invalid-examples/setuptools/ext-modules/missing-ext-name.toml new file mode 100644 index 0000000..83cab4a --- /dev/null +++ b/tests/invalid-examples/setuptools/ext-modules/missing-ext-name.toml @@ -0,0 +1,2 @@ +[[tool.setuptools.ext-modules]] +sources = ["hello.c", "world.c"]