Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import functools
import io
import json
import os
Expand Down Expand Up @@ -89,6 +90,15 @@ def _supported_interpreter_versions(
return versions


@functools.cache
def _is_no_std() -> bool:
no_std = os.environ.get("PYO3_WIP_NO_STD")
if no_std is None:
return False
no_std = no_std.strip()
return no_std == "1" or no_std.lower() == "true"


PY_VERSIONS = _supported_interpreter_versions("cpython")
ABI3_PY_VERSIONS = [p for p in PY_VERSIONS if not p.endswith("t")]
ABI3T_PY_VERSIONS = [
Expand Down Expand Up @@ -1570,6 +1580,12 @@ def _cfg_attr_is_non_cpython_only(attr: str) -> bool:
)


_REQUIRED_FOR_NO_STD = {
"hashbrown",
"parking_lot",
}


@nox.session(name="check-feature-powerset", venv_backend="none")
def check_feature_powerset(session: nox.Session):
if toml is None:
Expand Down Expand Up @@ -1660,6 +1676,8 @@ def check_feature_powerset(session: nox.Session):
*abi3_version_features,
*abi3t_version_features,
]
if _is_no_std():
features_to_skip.extend(_REQUIRED_FOR_NO_STD)

# deny warnings
env = os.environ.copy()
Expand All @@ -1672,7 +1690,7 @@ def check_feature_powerset(session: nox.Session):

comma_join = ",".join
for abi_name in ["abi3", "abi3t"]:
_run_cargo(
args = [
session,
subcommand,
"--feature-powerset",
Expand All @@ -1681,8 +1699,10 @@ def check_feature_powerset(session: nox.Session):
*(f"--group-features={comma_join(group)}" for group in features_to_group),
"check",
"--all-targets",
env=env,
)
]
if not _is_no_std:
args.push(f"--features={comma_join(_REQUIRED_FOR_NO_STD)}")
_run_cargo(*args, env=env)


@nox.session(name="update-ui-tests", venv_backend="none")
Expand Down Expand Up @@ -1802,6 +1822,8 @@ def _get_feature_sets(

cargo_target = os.getenv("CARGO_BUILD_TARGET", "")

required = ",".join(_REQUIRED_FOR_NO_STD) if _is_no_std() else ""

features = "full"

if "wasm32-wasip1" not in cargo_target:
Expand All @@ -1813,21 +1835,31 @@ def _get_feature_sets(

if FREE_THREADED_BUILD:
if version >= (3, 15):
return (None, "abi3t", features, f"abi3t,{features}")
return (
required,
f"abi3t,{required}",
f"{features},{required}",
f"abi3t,{features},{required}",
)
else:
return (None, features)
return (required, f"{features},{required}")

# do fewer abi3t builds?
if version >= (3, 15):
return (
None,
"abi3",
"abi3t",
features,
f"abi3,{features}",
f"abi3t,{features}",
required,
f"abi3,{required}",
f"abi3t,{required}",
f"{features},{required}",
f"abi3,{features},{required}",
f"abi3t,{features},{required}",
)
return (None, "abi3", features, f"abi3,{features}")
return (
required,
f"abi3,{required}",
f"{features},{required}",
f"abi3,{features},{required}",
)


_RELEASE_LINE_START = "release: "
Expand Down
10 changes: 10 additions & 0 deletions tests/test_compile_error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg(feature = "macros")]

use std::env;

fn main() {
if cfg!(target_arch = "wasm32") {
// Not possible to invoke compiler from wasm
Expand Down Expand Up @@ -52,6 +54,10 @@ fn main() {
// There doesn't seem to be a good way to forward all these features automatically,
// so have to just list the relevant ones here.
let deps_features = [
#[cfg(not(wip_feature_std))]
"pyo3/hashbrown".to_string(),
#[cfg(not(wip_feature_std))]
"pyo3/parking_lot".to_string(),
#[cfg(feature = "macros")]
"pyo3/macros".to_string(),
#[cfg(feature = "abi3")]
Expand All @@ -75,6 +81,10 @@ fn main() {
let mut deps_cargo = ui_test::CommandBuilder::cargo();
deps_cargo.args.push("--features".into());
deps_cargo.args.push(deps_features.join(",").into());
#[cfg(not(wip_feature_std))]
deps_cargo
.envs
.push(("PYO3_WIP_NO_STD".into(), Some("1".into())));

config.comment_defaults.base().set_custom(
"dependencies",
Expand Down