fix: Sdist Python packaging

* chore: Move Python bindings to `bindings`

* chore: Move `jsonschema` into a separate directory

* chore: Move submodule

* ci: Fix the `coverage` job

* chore: Move submodule

* test: Disable some failing optional tests

* ci: Add tests for installing Python sdist

* fix: Sdist Python packaging

* chore: Remove coverage job

It doesn't support such project structure
Ref: https://github.com/actions-rs/grcov/issues/50
This commit is contained in:
Dmitry Dygalo 2021-01-29 09:52:12 +01:00 committed by GitHub
parent 6d770d0714
commit f5be9508d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 85 additions and 67 deletions

View File

@ -31,7 +31,7 @@ jobs:
- run: pip install pre-commit
- run: pre-commit run --all-files
working-directory: ./python
working-directory: ./bindings/python
test-stable:
strategy:
@ -51,41 +51,8 @@ jobs:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast
coverage:
name: Test + Coverage (nightly)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: clean
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Cpanic=abort'
- id: coverage
uses: actions-rs/grcov@v0.1
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.0.15
if: ${{ env.GITHUB_REPOSITORY }} == 'Stranger6667/jsonschema-rs'
with:
name: coverage
file: ${{ steps.coverage.outputs.report }}
- run: cargo test --no-fail-fast
working-directory: ./jsonschema
test-python:
strategy:
@ -106,7 +73,7 @@ jobs:
architecture: x64
- run: python -m pip install tox
working-directory: ./python
working-directory: ./bindings/python
- uses: actions-rs/toolchain@v1
with:
@ -115,7 +82,35 @@ jobs:
- name: Run ${{ matrix.python }} tox job
run: tox -e py
working-directory: ./python
working-directory: ./bindings/python
test-python-sdist:
runs-on: ubuntu-latest
name: Testing Python source code distribution
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: x64
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: python -m pip install tox
working-directory: ./bindings/python
- run: tox -e build-sdist
working-directory: ./bindings/python
- name: Installing sdist
run: pip install dist/*
working-directory: ./bindings/python
fmt:
name: Rustfmt
@ -128,10 +123,8 @@ jobs:
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- run: cargo fmt --all -- --check
working-directory: ./jsonschema
clippy:
name: Clippy
@ -146,7 +139,5 @@ jobs:
toolchain: stable
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings
- run: cargo clippy --all-targets --all-features -- -D warnings
working-directory: ./jsonschema

View File

@ -34,12 +34,12 @@ jobs:
- name: Install Tox
run: pip install tox
- name: Build wheel
working-directory: ./python
working-directory: ./bindings/python
run: tox -e build-wheel
- uses: actions/upload-artifact@v2
with:
name: Distribution Artifacts
path: python/dist/
path: bindings/python/dist/
create_wheels_manylinux:
name: Wheels for Python ${{ matrix.PYTHON_IMPLEMENTATION_ABI }} / Linux
@ -78,7 +78,7 @@ jobs:
- name: Install Tox
run: ${{ env.PYTHON_SYS_EXECUTABLE }} -m pip install tox
- name: Build wheel
working-directory: ./python
working-directory: ./bindings/python
run: |
${{ env.PYTHON_SYS_EXECUTABLE }} -m tox -e build-wheel
# Ensure that the wheel is tagged as manylinux2014 platform
@ -92,7 +92,7 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: Distribution Artifacts
path: python/dist/
path: bindings/python/dist/
create_source_dist:
name: Create sdist package
@ -110,12 +110,12 @@ jobs:
- name: Install Tox
run: pip install tox
- name: Build sdist
working-directory: ./python
working-directory: ./bindings/python
run: tox -e build-sdist
- uses: actions/upload-artifact@v2
with:
name: Distribution Artifacts
path: python/dist/
path: bindings/python/dist/
upload_to_pypi:
needs:
@ -128,7 +128,7 @@ jobs:
- uses: actions/download-artifact@v2
with:
name: Distribution Artifacts
path: python/dist/
path: bindings/python/dist/
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@v1.2.2
with:

7
.gitignore vendored
View File

@ -1,6 +1,9 @@
# Rust
/target
/Cargo.lock
/jsonschema/target
/bindings/*/target
.hypothesis
.benchmarks
/jsonschema/Cargo.lock
# IDEs
/.idea

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "tests/suite"]
path = tests/suite
url = https://github.com/json-schema-org/JSON-Schema-Test-Suite.git
[submodule "jsonschema/tests/suite"]
path = jsonschema/tests/suite
url = git@github.com:json-schema-org/JSON-Schema-Test-Suite.git

View File

@ -10,9 +10,9 @@ A JSON Schema validator implementation. It compiles schema into a validation tre
Supported drafts:
- Draft 7 (except optional `idn-hostname.json` test cases)
- Draft 6
- Draft 4 (except optional `bignum.json` test cases)
- Draft 7 (except optional `idn-hostname.json`, `float_overflow.json` and `format_email.json` test cases)
- Draft 6 (except optional `float_overflow.json` and `format_email.json` test cases)
- Draft 4 (except optional `bignum.json`, `float_overflow.json` and `format_email.json` test cases)
```toml
# Cargo.toml

View File

@ -9,6 +9,9 @@
### Fixed
- Not necessary network requests for schemas with `$id` values with trailing `#` symbol. [#163](https://github.com/Stranger6667/jsonschema-rs/issues/163)
- Source code distribution. It was missing the source code for the underlying Rust crate and were leading to
a build error during `pip install css-inline` on platforms that we don't have wheels for.
[#159](https://github.com/Stranger6667/jsonschema-rs/issues/159)
### Performance

View File

@ -12,10 +12,15 @@ crate-type = ["cdylib"]
[build-dependencies]
built = { version = "0.4", features = ["chrono"] }
[dependencies.jsonschema]
path = "../../jsonschema"
version = "*"
default-features = false
features = ["reqwest"]
[dependencies]
serde_json = "1"
serde = "1"
jsonschema = { path = "../", version = "*" , default-features = false, features = ["reqwest"] }
pyo3 = { version = "^0.12", features = ["extension-module"] }
pyo3-built = "0.4"

View File

@ -3,3 +3,5 @@ include build.rs
include pyproject.toml
include rust-toolchain
recursive-include src *
recursive-include jsonschema-lib *
recursive-exclude jsonschema-lib/target *

12
bindings/python/build-sdist.sh Executable file
View File

@ -0,0 +1,12 @@
#!/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

View File

@ -19,7 +19,7 @@ commands =
deps =
setuptools-rust
commands =
python setup.py sdist
./build-sdist.sh
[testenv:build-wheel]
passenv =

@ -0,0 +1 @@
Subproject commit 8daea3f47e52526518cc2e88ef5d25d8a7070e3c

View File

@ -1,10 +1,12 @@
use json_schema_test_suite::{json_schema_test_suite, TestCase};
use jsonschema::{Draft, JSONSchema};
#[json_schema_test_suite("tests/suite", "draft4", {"optional_bignum_0_0", "optional_bignum_2_0"})]
#[json_schema_test_suite("tests/suite", "draft6")]
#[json_schema_test_suite("tests/suite", "draft4", {"optional_bignum_0_0", "optional_bignum_2_0", "optional_float_overflow_0_0", r"optional_format_email_0_\d+"})]
#[json_schema_test_suite("tests/suite", "draft6", {"optional_float_overflow_0_0", r"optional_format_email_0_\d+"})]
#[json_schema_test_suite("tests/suite", "draft7", {
r"optional_format_idn_hostname_0_\d+", // https://github.com/Stranger6667/jsonschema-rs/issues/101
"optional_float_overflow_0_0",
r"optional_format_email_0_\d+"
})]
fn test_draft(_server_address: &str, test_case: TestCase) {
let draft_version = match test_case.draft_version.as_ref() {

View File

@ -7,7 +7,7 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
jsonschema = { path = "../" }
jsonschema = { path = "../jsonschema" }
serde_json = "1"
[profile.release]

@ -1 +0,0 @@
Subproject commit 40601f62853229f26d0533bfc6cd5afb413fbf60