-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems switching from numpy.distutils to Meson and wrapping Fortran code into Python #14144
Comments
It looks like it is getting it from the wrong directory, truthfully:
meson doesn't have a I noticed that your module is in OMMBV/ and your tests are in OMMBV/tests/ but the tests aren't actually installed. My personal packaging suggestion is that it only leads to confusion if you do this mixture (it might be different if you were installing them). Moving the tests out would allow you to import OMMBV from an installed environment and the tests from the source tree. SciPy's |
@rgommers this is an interesting one :) |
I must've missed adding them to the install this round. I believe under distutils they got installed.
Thanks for the tip! I'll check that out tomorrow. My plan was to release a version of OMMBV where the only change was the switch to Meson. After that I feel ok making more changes to the install, like removing the tests from distributions, where it isn't strictly needed.
Glad to hear the problem is of interest. Given how many issues y'all must've seen I'll take it as a compliment :) |
Uh! This is a funny one, and meson or meson-python have nothing to do with the issue. The error you are getting is:
from executing Indeed in What I think happens at this point is that Python tries to find it at another location is All this happens because Please note that this is independent of the build system you use to install the package. I believe that the reason why you did not encounter the error with setuptools is that yuo were doing an "old school" editable installation where the extension modules are copied into the source tree. |
Thanks for the tip. You are correct, after changing my directory I can import OMMBV and use the fortran compiled functions. I have run into an issue with the import though. On my local system I can do the following:
Works great. This same command does not work on the Meson built version on GitHub. I have to import the fortran modules specifically.
yields
I'm not sure this is Meson specific but since the init files are the same in both cases I'm not sure what the problem could be. Clearly the fortran built sources submodule is there, but why doesn't it show up at 'OMMBV.sources' after the simple 'import OMMBV'? I've probably being doing "old school" editable installs too long but it doesn't seem like that would be an issue here since the system clearly can find a working .sources.
Yes, I use the "old school" approach on my local machine for convenience. OMMBV did work outside of my machine but I'm not sure anyone tried to run the tests. I haven't got the tests working yet but I'll be back on that next week. Thanks again for the assistance. |
It should work fine, it does for me locally using the Meson built version. The issue which traditionally causes this is that |
.... aha. I git pulled the new code, and that changes. Now
diff --git a/meson.build b/meson.build
index 772f5d1..eeb597d 100644
--- a/meson.build
+++ b/meson.build
@@ -106,6 +106,9 @@ py.install_sources(
'OMMBV/utils.py',
'OMMBV/vector.py',
'OMMBV/__init__.py',
+ 'OMMBV/tests/__init__.py',
+ 'OMMBV/tests/test_apex.py',
+ 'OMMBV/tests/test_core.py',
pure: false,
subdir: 'OMMBV'
)
\ No newline at end of file This is installing
Alternatively, the files installed to |
Describe the bug
I can't sort out how to use Meson to build a Python package incorporating Fortran that is working under numpy.distutils. I've found the documentation over at numpy (https://numpy.org/doc/stable/f2py/buildtools/meson.html) but following that hasn't worked for me so far.
I also found this discussion, #10536, for help moving the Python package apexpy to Meson. I've used apexpy's meson.build file as a guide but unfortunately it isn't working correctly for me.
The installation appears to run just fine but I can't import any of the compiled Fortran modules. I get an ImportError. This is using GitHub Actions computers.
I would greatly appreciate some assistance or direction.
As a secondary issue on my local Mac I get "ld: library not found for -lcrt1.o
collect2: error: ld returned 1 exit status"
when trying to install my OMMBV package on a fresh virtual environment of Python 3.12 using conda and "pip install ." I can install the package on this machine using numpy.distutils.
To Reproduce
The public repo I'm having issues with is over here: CosmicStudioSoftware/OMMBV#63
Full meson.build file is below.
Expected behavior
My expectation was that swapping out numpy.distutils for Meson using numpy docs would produce the same functional package
system parameters
meson --version
ninja --version
if it's a Ninja buildThe text was updated successfully, but these errors were encountered: