`numpy_dep` doesn't work with uv if installing locally over `numpy_includes`
Hello,
I was trying to get werpy to install locally as a uv package via. uv add --editable ./werpy and it would be unable to find #include "numpy/arrayobject.h" (I assume due to uv's isolation) with bumpy_dep = dependency('numpy') in meson.build
However, commentating that out and its call in py.extension_module and uncommenting numpy_includes and include_directories allowed for it to build and work fine. Is there a reason this is used over what's commented out?
Thanks.
Hi @namgyaaal,
Thank you for asking about this and digging into werpy! It is quite interesting and something I was looking into several weeks ago.
The switch to dependency('numpy') was intended to leverage Meson's modern dependency handling, as it avoids running Python code during configuration. However, as you noted, it relies on pkg-config being correctly exposed in the build environment. This is known to be inconsistent in strict isolation environments like uv's editable mode. I actually kept the legacy numpy_includes code in the file (commented out) specifically as a fallback for situations like this.
I will add this to the roadmap for the next werpy release. I plan to investigate a fallback mechanism in meson.build that tries the modern dependency method first and falls back to numpy.get_include() if it fails, which would satisfy both modern standards and robust installation.
For context, there are ongoing discussions about this upstream as well: uv does not work with meson-python editable installs.
Thanks again
Hi again @namgyaaal,
I saw from your repos you like using rust as well. We are currently moving a lot of our stack that way.
Actually built a lightweight Python/Rust Word Error Rate package called werx. It is heaps faster!
It functions a bit differently than werpy, but might be worth a look depending on your use case.
Cheers
Hello!
Your reasoning makes sense, thanks for the information on this.
Rust is for personal projects. I use python in work. But I might take a look at this, thank you. I am trying to implement mtWER (see: The CHiME-8 MMCSG Challenge: Multi-modal conversations in smart glasses or Joint ASR and Speaker Role Tagging with Serialized Output Training) in an efficient fashion and maybe contribute it to a repo dedicated to wer. Jiwer seems to be set in stone (last updated in a year and multiple open PRs) and I saw this repo being updated recently so thought it would be cool for me to take a shot at it :-)
Basically, our stack is now Rust running under the hood with a thin Python wrapper. This gives us the best of both worlds: full Python compatibility, but with Rust doing all the heavy lifting. You can still install the packages as normal.
The Python/Rust combo does make the build process a little more complex, but it is absolutely worth it for the performance. Once you get the hang of it, itβs actually super easy, and the bindings are solid.
These Rust-backed Python APIs are especially great for things like ASR because they unlock parallelization really easily.
We generally try not to reinvent the wheel, but if the current ecosystem packages aren't working for us, we prefer to build our own solutions. That said, we are happy to accept contributions if you want to get involved!