2813: ci: run pyo3-ffi-check using nox r=davidhewitt a=davidhewitt

Makes it easier to run pyo3-ffi-check locally :)

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
This commit is contained in:
bors[bot] 2022-12-26 10:02:54 +00:00 committed by GitHub
commit 097af010e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 64 additions and 22 deletions

View File

@ -128,17 +128,13 @@ jobs:
- '.github/workflows/ci.yml' - '.github/workflows/ci.yml'
- '.github/workflows/build.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 - name: Run pyo3-ffi-check
run: cargo run run: nox -s ffi-check
working-directory: pyo3-ffi-check
# Allow failure on PyPy for now # Allow failure on PyPy for now
continue-on-error: ${{ startsWith(inputs.python-version, 'pypy') }} 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' }} 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 - name: Test cross compilation
if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.9' }} if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.9' }}
uses: PyO3/maturin-action@v1 uses: PyO3/maturin-action@v1

View File

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

View File

@ -111,6 +111,9 @@ def _clippy(session: nox.Session, *, env: Dict[str, str] = None) -> bool:
*feature_set, *feature_set,
"--all-targets", "--all-targets",
"--workspace", "--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, *extra,
external=True, external=True,
env=env, env=env,
@ -404,9 +407,27 @@ def check_changelog(session: nox.Session):
@nox.session(name="set-minimal-package-versions") @nox.session(name="set-minimal-package-versions")
def set_minimal_package_versions(session: nox.Session): 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 # run cargo update first to ensure that everything is at highest
# possible version, so that this matches what CI will resolve to. # 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) _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, "indexmap", "1.6.2")
_run_cargo_set_package_version(session, "hashbrown:0.12.3", "0.9.1") _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", "1.5.3")
_run_cargo_set_package_version(session, "rayon-core", "1.9.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 # 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(session, "num_cpus", "1.14.0")
_run_cargo_set_package_version( _run_cargo_set_package_version(
@ -433,7 +457,7 @@ def set_minimal_package_versions(session: nox.Session):
) )
for project in projects: for project in projects:
_run_cargo_set_package_version( _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) _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 # As a smoke test, cargo metadata solves all dependencies, so
# will break if any crates rely on cargo features not # will break if any crates rely on cargo features not
# supported on MSRV # supported on MSRV
for project in projects:
if project is None:
_run(session, "cargo", "metadata", silent=True, external=True) _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() @lru_cache()

View File

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

View File

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

View File

@ -1,7 +1,8 @@
[package] [package]
name = "pyo3-ffi-check-macro" name = "pyo3-ffi-check-macro"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2018"
publish = false
[lib] [lib]
proc-macro = true proc-macro = true
@ -10,4 +11,4 @@ proc-macro = true
glob = "0.3" glob = "0.3"
quote = "1" quote = "1"
proc-macro2 = "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!( return quote!(compile_error!(
"for_all_structs!() takes only a single ident as input" "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!( return quote!(compile_error!(
"for_all_fields!() takes exactly two idents as input" "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() { 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; let mut failed = false;
macro_rules! check_struct { macro_rules! check_struct {

View File

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