python3Packages.{pyro-ppl,funsor}: fix build (#577519)

This commit is contained in:
Gaétan Lepage
2026-10-22 21:52:08 +00:00
committed by GitHub
2 changed files with 30 additions and 5 deletions

View File

@@ -47,6 +47,14 @@ buildPythonPackage (finalAttrs: {
./torch-arg-constraints-property.patch
];
# `torch.cholesky` and `Tensor.cholesky` were removed in torch 2.14
postPatch = ''
substituteInPlace test/pyro/test_convert.py test/pyro/test_hmm.py \
--replace-fail "torch.cholesky(cov)" "torch.linalg.cholesky(cov)"
substituteInPlace test/test_gaussian.py \
--replace-fail "u = x.cholesky()" "u = torch.linalg.cholesky(x)"
'';
build-system = [ setuptools ];
dependencies = [
@@ -76,6 +84,11 @@ buildPythonPackage (finalAttrs: {
export FUNSOR_BACKEND=torch
'';
pytestFlags = [
# FutureWarning: `torch.jit.trace` is not supported in Python 3.14+ and may break.
"-Wignore:`torch.jit.:FutureWarning"
];
pythonImportsCheck = [ "funsor" ];
meta = {

View File

@@ -70,10 +70,15 @@ buildPythonPackage (finalAttrs: {
"pyro.optim"
];
# Added for the tests/distributions/test_spanning_tree.py
preCheck = ''
export TORCH_EXTENSIONS_DIR=$(mktemp -d)
'';
preCheck =
# Added for the tests/distributions/test_spanning_tree.py
''
export TORCH_EXTENSIONS_DIR=$(mktemp -d)
''
# Avoid a race between xdist workers when tests/perf/test_benchmark.py creates it at import
+ ''
mkdir -p .benchmarks
'';
nativeCheckInputs = [
graphviz
@@ -83,7 +88,14 @@ buildPythonPackage (finalAttrs: {
scipy
];
pytestFlags = [ "--stage=unit" ];
pytestFlags = [
"--stage=unit"
# FutureWarning: `torch.jit.{trace,trace_method,save,load}` is not supported in Python 3.14+
# Upstream only ignores the "is deprecated" variant of these warnings.
# Note: `-W` messages are matched literally as a prefix, not as regexes.
"-Wignore:`torch.jit.:FutureWarning"
];
disabledTests = [
"test_stable_with_log_prob_param_fit"