ci: run pyo3-ffi-check using nox

This commit is contained in:
David Hewitt 2022-12-17 11:32:56 +00:00
parent e5cf1cb971
commit 87b6a9bd92
9 changed files with 64 additions and 22 deletions

View File

@ -128,17 +128,13 @@ jobs:
- '.github/workflows/ci.yml'
- '.github/workflows/build.yml'
- run: cargo doc -p pyo3-ffi
working-directory: pyo3-ffi-check
if: ${{ steps.ffi-changes.outputs.changed == 'true' && inputs.rust == 'stable' && inputs.python-version != 'pypy-3.7' && inputs.python-version != 'pypy-3.8' }}
- name: Run pyo3-ffi-check
run: cargo run
working-directory: pyo3-ffi-check
run: nox -s ffi-check
# Allow failure on PyPy for now
continue-on-error: ${{ startsWith(inputs.python-version, 'pypy') }}
if: ${{ steps.ffi-changes.outputs.changed == 'true' && inputs.rust == 'stable' && inputs.python-version != 'pypy-3.7' && inputs.python-version != 'pypy-3.8' }}
- name: Test cross compilation
if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.9' }}
uses: PyO3/maturin-action@v1

View File

@ -158,6 +158,8 @@ harness = false
[workspace]
members = [
"pyo3-ffi",
"pyo3-ffi-check",
"pyo3-ffi-check/macro",
"pyo3-build-config",
"pyo3-macros",
"pyo3-macros-backend",

View File

@ -111,6 +111,9 @@ def _clippy(session: nox.Session, *, env: Dict[str, str] = None) -> bool:
*feature_set,
"--all-targets",
"--workspace",
# linting pyo3-ffi-check requires docs to have been built or
# the macros will error; doesn't seem worth it on CI
"--exclude=pyo3-ffi-check",
*extra,
external=True,
env=env,
@ -404,9 +407,27 @@ def check_changelog(session: nox.Session):
@nox.session(name="set-minimal-package-versions")
def set_minimal_package_versions(session: nox.Session):
projects = (
None,
"examples/decorator",
"examples/maturin-starter",
"examples/setuptools-rust-starter",
"examples/word-count",
)
# run cargo update first to ensure that everything is at highest
# possible version, so that this matches what CI will resolve to.
for project in projects:
if project is None:
_run(session, "cargo", "update", external=True)
else:
_run(
session,
"cargo",
"update",
f"--manifest-path={project}/Cargo.toml",
external=True,
)
_run_cargo_set_package_version(session, "indexmap", "1.6.2")
_run_cargo_set_package_version(session, "hashbrown:0.12.3", "0.9.1")
@ -418,6 +439,9 @@ def set_minimal_package_versions(session: nox.Session):
_run_cargo_set_package_version(session, "rayon", "1.5.3")
_run_cargo_set_package_version(session, "rayon-core", "1.9.3")
# string_cache 0.8.4 depends on parking_lot 0.12
_run_cargo_set_package_version(session, "string_cache:0.8.4", "0.8.3")
# 1.15.0 depends on hermit-abi 0.2.6 which has edition 2021 and breaks 1.48.0
_run_cargo_set_package_version(session, "num_cpus", "1.14.0")
_run_cargo_set_package_version(
@ -433,7 +457,7 @@ def set_minimal_package_versions(session: nox.Session):
)
for project in projects:
_run_cargo_set_package_version(
session, "parking_lot", "0.11.0", project=project
session, "parking_lot:0.12.1", "0.11.0", project=project
)
_run_cargo_set_package_version(session, "once_cell", "1.14.0", project=project)
@ -447,7 +471,24 @@ def set_minimal_package_versions(session: nox.Session):
# As a smoke test, cargo metadata solves all dependencies, so
# will break if any crates rely on cargo features not
# supported on MSRV
for project in projects:
if project is None:
_run(session, "cargo", "metadata", silent=True, external=True)
else:
_run(
session,
"cargo",
"metadata",
f"--manifest-path={project}/Cargo.toml",
silent=True,
external=True,
)
@nox.session(name="ffi-check")
def ffi_check(session: nox.Session):
session.run("cargo", "doc", "-p", "pyo3-ffi", "--no-deps", external=True)
_run(session, "cargo", "run", "-p", "pyo3-ffi-check", external=True)
@lru_cache()

View File

@ -1,7 +1,7 @@
[package]
name = "pyo3-ffi-check"
version = "0.1.0"
edition = "2021"
edition = "2018"
publish = false
[dependencies]
@ -10,12 +10,7 @@ memoffset = "0.7.0"
[dependencies.pyo3-ffi]
path = "../pyo3-ffi"
features = ["extension-module"] # A lazy way of skipping linking in most cases (as we don't use any runtime symbols)
[workspace]
members = [
"macro"
]
features = ["extension-module"] # A lazy way of skipping linking in most cases (as we don't use any runtime symbols)
[build-dependencies]
bindgen = "0.63.0"

View File

@ -10,7 +10,6 @@ fn main() {
.expect("failed to get lib dir");
println!("cargo:rerun-if-changed=wrapper.h");
dbg!(format!("-I{python_include_dir}"));
let bindings = bindgen::Builder::default()
.header("wrapper.h")

View File

@ -1,7 +1,8 @@
[package]
name = "pyo3-ffi-check-macro"
version = "0.1.0"
edition = "2021"
edition = "2018"
publish = false
[lib]
proc-macro = true
@ -10,4 +11,4 @@ proc-macro = true
glob = "0.3"
quote = "1"
proc-macro2 = "1"
scraper = "0.13"
scraper = "0.12"

View File

@ -19,7 +19,7 @@ pub fn for_all_structs(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
}
};
if !input.next().is_none() {
if input.next().is_some() {
return quote!(compile_error!(
"for_all_structs!() takes only a single ident as input"
))
@ -109,7 +109,7 @@ pub fn for_all_fields(input: proc_macro::TokenStream) -> proc_macro::TokenStream
}
};
if !input.next().is_none() {
if input.next().is_some() {
return quote!(compile_error!(
"for_all_fields!() takes exactly two idents as input"
))

View File

@ -1,6 +1,13 @@
use std::process::exit;
use std::{ffi::CStr, process::exit};
fn main() {
println!(
"comparing pyo3-ffi against headers generated for {}",
CStr::from_bytes_with_nul(bindings::PY_VERSION)
.unwrap()
.to_string_lossy()
);
let mut failed = false;
macro_rules! check_struct {

View File

@ -2,6 +2,7 @@
name = "xtask"
version = "0.1.0"
edition = "2018"
publish = false
[[bin]]
name = "xtask"