Update libngspice to 46 and inspice to 1.7.0.5#607
Conversation
ngspice 46 removes the cppduals std::is_compound specialization that newer clang/libc++ rejected with -Winvalid-specialization, which was the error that had disabled the libngspice recipe. Bumping to 46 fixes the build natively, so re-enable the recipe (drop _disabled). All three existing patches still apply cleanly to ngspice 46. Bump inspice to 1.7.0.5 to match; runtime dependencies are unchanged and the NgSpiceShared API used by the tests is intact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJYJXpbfbK2wLfzzQB9B7P
|
Could you please try to upstream this to Edit Oh, looks like you are the maintainer of the inspice package, in that case, why not bundle |
|
Inspice doesn't bundle ngspice on any platform, it's just a pure python library. And libngspice is a shared library not a wheel so aiui you can't distribute it on pypi by itself. So I mean happy to bundle it on pypi somehow but not sure about the logistics. I did recently make a vacask-bin package, which as the name suggests ships binaries in a thin python wrapper. But I don't think that same mechanism works for publishing a share library. |
Well, I would say you should, if you are planning to make inspice package more platform agnostic. Maybe you can do that at least for the pyemscripten wheel that doesn't have the libngspice library in the system. I think you can update the code that locates the libngspice to something like 1) find it from the package's |
|
inspice is a generic interface package though, and it doesn't make sense to ship all the simulators it supports, especially not on other platforms where they're an apt install away. It is within my power as a maintainer to make only wasm be a binary wheel that bundles ngspice but that seems very weird. My preference is an libngspice package that follows the vacask-bin package format that users can install as they please. Is there a way to make a wrapper wheel that either pushes those libs onto the path, or for inspice to look into the libngspice wheel? I guess some importlib resource shenanigans should work if the package is actually somewhere on the filesystem as normal files. |
|
Given that I already have this working recipe, what's the easiest way to turn that into a working wheel? Ideally I'd extend it to native platforms as well at some point, so maybe I just need to bite the bullet and conver to cibuildwheel? |
|
Possibly. You could get pretty far with the importlib shenanigans you mentioned to always find the correct location for the Python package to find the library, but cibuildwheel is the more conventional approach. We have tooling in the form of auditwheel-emscripten for repairing pyemscripten wheels for this purpose. You could also think of publishing it under the name of libngspice-wasm on PyPI, i.e., not under ngspice, though I recognise it needs more work to set up the infrastructure. |
|
I approved the workflows in the meantime, so that we can at least see whether the builds will work, if that helps. |
Yeah, I think that is possible. There is a scipy-openblas64 that does a similar thing. It is a python package but it only contains a shared libraries in it (with some optional helper scripts that helps finding and loading the shared libraries). I think what you need to do is
|
that is some wild error... any pyodide/emscripten change comes to mind that could cause something like that? |
Two issues surfaced when building/running ngspice 46 under Pyodide
(Emscripten 5.0.3):
- The GitHub tag archive extracts to ngspice-sf-mirror-ngspice-46, which
does not match the archive name, so pyodide-build could not locate the
source tree. Add source.extract_dir.
- ngspice 46 added an available-memory check in OUTpD_memory() that aborts
the run when the estimated output exceeds reported free memory. Under
WASM there is no /proc/meminfo, so getMemorySize()/getAvailableMemorySize()
returned 0 and the check always tripped, producing a bogus multi-GB
allocation and "ngspice.dll cannot recover" abort even for tiny circuits
(fopen("/proc/meminfo") + realloc failure). Patch 0004 reports the
Emscripten heap (max / max-current) instead.
Verified end to end: a clean build of the recipe loads in Node and runs a
transient simulation to completion (No. of Data Rows: 4012) with no
/proc/meminfo error and no spurious allocation.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJYJXpbfbK2wLfzzQB9B7P
Package Build ResultsTotal packages built: 48 Package Build Times (click to expand)
Longest build: libngspice (21m 58s) |
There was a problem hiding this comment.
Thanks for fixing it! I am okay with this update, though let's hope that the next update can have a platform-specific inspice wheel directly pushed to PyPI, removing the recipe here... considering that it is fine to have both a pure Python wheel and a WASM wheel, since pip will pick the more specific WASM one during resolution.
Description
ngspice 46 removes the cppduals std::is_compound specialization that newer clang/libc++ rejected with -Winvalid-specialization, which was the error that had disabled the libngspice recipe. Bumping to 46 fixes the build natively, so re-enable the recipe (drop _disabled).
All three existing patches still apply cleanly to ngspice 46.
Bump inspice to 1.7.0.5 to match; runtime dependencies are unchanged and the NgSpiceShared API used by the tests is intact.
Type of change
If there is a reasonable way to ship libngspice on pypi I might do that at some point.
aiui I'll have to wait for the next release for this to be picked up? (and for marimo to pick up that release...)