build(python): Switch to maturin (#411)
* build(python): Switch to maturin * chore: Use `maturin>=0.14.11,<0.15` Co-authored-by: messense <messense@icloud.com> * build: Build only `sdist` in the `test-python-sdist` job Co-authored-by: messense <messense@icloud.com> * build: Set the proper output directory for `maturin` * chore: Add more metadata --------- Co-authored-by: messense <messense@icloud.com>
This commit is contained in:
parent
77ce10015f
commit
0391921362
|
@ -188,10 +188,10 @@ jobs:
|
|||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- run: python -m pip install tox
|
||||
- run: python -m pip install maturin
|
||||
working-directory: ./bindings/python
|
||||
|
||||
- run: tox -e build-sdist
|
||||
- run: maturin sdist -o dist
|
||||
working-directory: ./bindings/python
|
||||
|
||||
- name: Installing sdist
|
||||
|
|
|
@ -31,11 +31,11 @@ jobs:
|
|||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- name: Install Tox
|
||||
run: pip install tox
|
||||
- name: Install maturin
|
||||
run: pip install maturin
|
||||
- name: Build wheel
|
||||
working-directory: ./bindings/python
|
||||
run: tox -e build-wheel
|
||||
run: maturin build -o dist
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Distribution Artifacts
|
||||
|
@ -75,12 +75,12 @@ jobs:
|
|||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- name: Install Tox
|
||||
run: ${{ env.PYTHON_SYS_EXECUTABLE }} -m pip install tox
|
||||
- name: Install maturin
|
||||
run: pip install maturin
|
||||
- name: Build wheel
|
||||
working-directory: ./bindings/python
|
||||
run: |
|
||||
${{ env.PYTHON_SYS_EXECUTABLE }} -m tox -e build-wheel
|
||||
maturin build -o dist
|
||||
# Ensure that the wheel is tagged as manylinux2014 platform
|
||||
auditwheel repair \
|
||||
--wheel-dir=./dist \
|
||||
|
@ -107,11 +107,11 @@ jobs:
|
|||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- name: Install Tox
|
||||
run: pip install tox
|
||||
- name: Install maturin
|
||||
run: pip install maturin
|
||||
- name: Build sdist
|
||||
working-directory: ./bindings/python
|
||||
run: tox -e build-sdist
|
||||
run: maturin sdist -o dist
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Distribution Artifacts
|
||||
|
|
|
@ -31,27 +31,6 @@ serde = "1.0.152"
|
|||
pyo3 = { version = "0.17.3", features = ["extension-module"] }
|
||||
pyo3-built = "0.4.7"
|
||||
|
||||
[package.metadata.maturin]
|
||||
requires-python = ">=3.7"
|
||||
project-url = { repository = "https://github.com/Stranger6667/jsonschema-rs" }
|
||||
maintainer = "Dmitry Dygalo"
|
||||
maintainer-email = "Dmitry Dygalo <dadygalo@gmail.com>"
|
||||
classifier = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Rust",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
lto = "on"
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
include Cargo.toml
|
||||
include build.rs
|
||||
include pyproject.toml
|
||||
include rust-toolchain
|
||||
recursive-include src *
|
||||
include jsonschema_rs/py.typed
|
||||
recursive-include jsonschema_rs *.pyi
|
||||
recursive-include jsonschema-lib *
|
||||
recursive-exclude jsonschema-lib Cargo.lock
|
||||
recursive-exclude jsonschema-lib/target *
|
||||
recursive-exclude jsonschema-lib/benches *.json
|
||||
recursive-exclude jsonschema-lib/tests *
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
# Create a symlink for jsonschema
|
||||
ln -sf ../../jsonschema jsonschema-lib
|
||||
# Modify Cargo.toml to include this symlink
|
||||
cp Cargo.toml Cargo.toml.orig
|
||||
sed -i 's/\.\.\/\.\.\/jsonschema/\.\/jsonschema-lib/' Cargo.toml
|
||||
# Build the source distribution
|
||||
python setup.py sdist
|
||||
rm jsonschema-lib
|
||||
mv Cargo.toml.orig Cargo.toml
|
|
@ -1 +0,0 @@
|
|||
from ._jsonschema_rs import *
|
|
@ -1,5 +1,39 @@
|
|||
[build-system]
|
||||
requires = ["setuptools", "setuptools-rust", "toml", "wheel"]
|
||||
[project]
|
||||
name = "jsonschema_rs"
|
||||
description = "Fast JSON Schema validation for Python implemented in Rust"
|
||||
keywords = ["jsonschema", "validation", "rust"]
|
||||
authors = [
|
||||
{name = "Dmitry Dygalo", email = "dadygalo@gmail.com"}
|
||||
]
|
||||
maintainers = [
|
||||
{name = "Dmitry Dygalo", email = "dadygalo@gmail.com"}
|
||||
]
|
||||
readme = "README.rst"
|
||||
license = { text = "MIT" }
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Rust",
|
||||
]
|
||||
dependencies = []
|
||||
requires-python = ">=3.7"
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/Stranger6667/jsonschema-rs/tree/master/python"
|
||||
Changelog = "https://github.com/Stranger6667/jsonschema-rs/blob/master/bindings/python/CHANGELOG.md"
|
||||
"Bug Tracker" = "https://github.com/Stranger6667/jsonschema-rs/issues"
|
||||
Source = "https://github.com/Stranger6667/jsonschema-rs"
|
||||
Funding = 'https://github.com/sponsors/Stranger6667'
|
||||
|
||||
[tool.black]
|
||||
line-length = 120
|
||||
|
@ -13,3 +47,11 @@ default_section = "THIRDPARTY"
|
|||
include_trailing_comma = true
|
||||
known_first_party = "jsonschema_rs"
|
||||
known_third_party = []
|
||||
|
||||
[tool.maturin]
|
||||
python-source = "python"
|
||||
strip = true
|
||||
|
||||
[build-system]
|
||||
requires = ["maturin>=0.14.11,<0.15"]
|
||||
build-backend = "maturin"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
from .jsonschema_rs import *
|
|
@ -1,57 +0,0 @@
|
|||
from setuptools import setup
|
||||
|
||||
try:
|
||||
from setuptools_rust import Binding, RustExtension
|
||||
except ImportError:
|
||||
from textwrap import dedent
|
||||
|
||||
raise ImportError(
|
||||
dedent(
|
||||
"""
|
||||
`setuptools-rust` is a required dependency to run `setup.py`.
|
||||
This should not happen if you're using `pip>=10` as it honors `pyproject.toml`.
|
||||
This usually (at least on our workflows) might happen while
|
||||
building source-distribution.
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def call_setup():
|
||||
setup(
|
||||
name="jsonschema_rs",
|
||||
version="0.16.2",
|
||||
packages=["jsonschema_rs"],
|
||||
description="Fast JSON Schema validation for Python implemented in Rust",
|
||||
long_description=open("README.rst", encoding="utf-8").read(),
|
||||
long_description_content_type="text/x-rst",
|
||||
keywords="jsonschema validation rust",
|
||||
author="Dmitry Dygalo",
|
||||
author_email="dadygalo@gmail.com",
|
||||
maintainer="Dmitry Dygalo",
|
||||
maintainer_email="dadygalo@gmail.com",
|
||||
python_requires=">=3.7",
|
||||
url="https://github.com/Stranger6667/jsonschema-rs/tree/master/python",
|
||||
license="MIT",
|
||||
rust_extensions=[RustExtension("jsonschema_rs._jsonschema_rs", binding=Binding.PyO3)],
|
||||
include_package_data=True,
|
||||
classifiers=[
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Rust",
|
||||
],
|
||||
zip_safe=False,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
call_setup()
|
|
@ -450,7 +450,7 @@ mod build {
|
|||
|
||||
/// JSON Schema validation for Python written in Rust.
|
||||
#[pymodule]
|
||||
fn _jsonschema_rs(py: Python<'_>, module: &PyModule) -> PyResult<()> {
|
||||
fn jsonschema_rs(py: Python<'_>, module: &PyModule) -> PyResult<()> {
|
||||
// To provide proper signatures for PyCharm, all the functions have their signatures as the
|
||||
// first line in docstrings. The idea is taken from NumPy.
|
||||
types::init();
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
[tox]
|
||||
# Skip Source distribution build to allow each task to install it via pip
|
||||
# (workaround the fact that setup.py does not honor pyproject.toml)
|
||||
skipsdist = True
|
||||
|
||||
envlist = py{36,37,38,39,310,311}
|
||||
|
||||
[testenv]
|
||||
|
@ -12,22 +9,5 @@ deps =
|
|||
pytest-benchmark
|
||||
hypothesis
|
||||
commands =
|
||||
pip install -e . # Installing it within commands allow faster env build (NOTE: uses debug rust build)
|
||||
pip install -e .
|
||||
python -m pytest tests-py {posargs:}
|
||||
|
||||
[testenv:build-sdist]
|
||||
deps =
|
||||
setuptools-rust
|
||||
commands =
|
||||
./build-sdist.sh
|
||||
allowlist_externals =
|
||||
./build-sdist.sh
|
||||
|
||||
[testenv:build-wheel]
|
||||
passenv =
|
||||
PYTHON_SYS_EXECUTABLE
|
||||
deps =
|
||||
setuptools-rust
|
||||
wheel
|
||||
commands =
|
||||
python setup.py bdist_wheel
|
||||
|
|
Loading…
Reference in New Issue