8000 Bug cpython c_ext_L2.c compilation · Issue #307 · mtuqorg/mtuq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bug cpython c_ext_L2.c compilation #307

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

Open
SeismoFelix opened this issue Apr 5, 2025 · 8 comments
Open

Bug cpython c_ext_L2.c compilation #307

SeismoFelix opened this issue Apr 5, 2025 · 8 comments

Comments

@SeismoFelix
Copy link
Member

Hello,

Something happened in the latest approved pull request that changed the compilation of c_ext_L2.c during the execution of

conda env update --file env.yaml

After the installation, the file c_ext_L2.cpython-312-darwin.so created in the same directory where c_ext_L2.c is located, did not work. I got this error message when I simply tried to import a mtuq library.

from mtuq import read
/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/waveform/init.py:13: SyntaxWarning: invalid escape sequence '|'
""" Waveform misfit function
Traceback (most recent call last):
File "", line 1, in
File "/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/init.py", line 35, in
from mtuq.misfit import PolarityMisfit, WaveformMisfit
File "/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/init.py", line 2, in
from mtuq.misfit.waveform import WaveformMisfit
File "/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/waveform/init.py", line 5, in
from mtuq.misfit.waveform import level0, level1, level2
File "/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/waveform/level2.py", line 14, in
from mtuq.misfit.waveform import c_ext_L2
ImportError: dlopen(/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so, 0x0002): tried: '/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so' (malformed load command #14 of 16 at 0x10258f610 with mh=0x10258f000, size (0x0) too small), '/System/Volumes/Preboot/Cryptexes/OS/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so' (no such file), '/Users/felix/Documents/Software/mtuq_test/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so' (malformed load command #14 of 16 at 0x10258f610 with mh=0x10258f000, size (0x0) too small)

Fortunately, I had installed mtuq before the latest commit and I changed the c_ext_L2.cpython-312-darwin.so file that was not working for another one compiled in a different mtuq environment from a previous installation. Then eveything worked as expected (at least with the examples).

Of course, this is a temporary patch that only works for me, but I have not found what may have changed that caused this behavior.

I tested the installation in two MacOS computers and the error is the same.

Thanks for your help.

Image

Image

@rmodrak
Copy link
Member
rmodrak commented Apr 5, 2025 via email

@SeismoFelix
Copy link
Member Author

Thanks Ryan,

Fun thing: It doe not work because the instruction: rm mtuq/misfit/*.so does not work because the *so file is in mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so. But it has been like this always.

I modified the file to be rm mtuq/misfit/waveform/*.so and I got this:

/Users/felix/Documents/software/mtuq_felix/mtuq/./setup.py:7: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated.
!!

    ********************************************************************************
    Please remove any references to `setuptools.command.test` in all supported versions of the affected package.

    This deprecation is overdue, please update your project and remove deprecated
    calls to avoid build errors in the future.
    ********************************************************************************

!!
from setuptools.command.test import test as test_command
running build_ext
building 'mtuq.misfit.waveform.c_ext_L2' extension
creating build/temp.macosx-10.13-x86_64-cpython-312/mtuq/misfit/waveform
x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fstack-protector-strong -O2 -pipe -isystem /Users/felix/anaconda3/envs/mtuq_felix/include -D_FORTIFY_SOURCE=2 -isystem /Users/felix/anaconda3/envs/mtuq_felix/include -I/Users/felix/anaconda3/envs/mtuq_felix/lib/python3.12/site-packages/numpy/core/include -I/Users/felix/anaconda3/envs/mtuq_felix/include/python3.12 -c mtuq/misfit/waveform/c_ext_L2.c -o build/temp.macosx-10.13-x86_64-cpython-312/mtuq/misfit/waveform/c_ext_L2.o -Ofast
In file included from mtuq/misfit/waveform/c_ext_L2.c:3:
In file included from /Users/felix/anaconda3/envs/mtuq_felix/lib/python3.12/site-packages/numpy/core/include/numpy/arrayobject.h:5:
In file included from /Users/felix/anaconda3/envs/mtuq_felix/lib/python3.12/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /Users/felix/anaconda3/envs/mtuq_felix/lib/python3.12/site-packages/numpy/core/include/numpy/ndarraytypes.h:1929:
/Users/felix/anaconda3/envs/mtuq_felix/lib/python3.12/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
17 | #warning "Using deprecated NumPy API, disable it with "
| ^
mtuq/misfit/waveform/c_ext_L2.c:144:17: warning: use of infinity via a macro is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
144 | next_iter = INFINITY;
| ^
2 warnings generated.
creating build/lib.macosx-10.13-x86_64-cpython-312/mtuq/misfit/waveform
x86_64-apple-darwin13.4.0-clang -bundle -undefined dynamic_lookup -Wl,-rpath,/Users/felix/anaconda3/envs/mtuq_felix/lib -L/Users/felix/anaconda3/envs/mtuq_felix/lib -Wl,-rpath,/Users/felix/anaconda3/envs/mtuq_felix/lib -L/Users/felix/anaconda3/envs/mtuq_felix/lib -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/felix/anaconda3/envs/mtuq_felix/lib -L/Users/felix/anaconda3/envs/mtuq_felix/lib -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fstack-protector-strong -O2 -pipe -isystem /Users/felix/anaconda3/envs/mtuq_felix/include -D_FORTIFY_SOURCE=2 -isystem /Users/felix/anaconda3/envs/mtuq_felix/include build/temp.macosx-10.13-x86_64-cpython-312/mtuq/misfit/waveform/c_ext_L2.o -o build/lib.macosx-10.13-x86_64-cpython-312/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so
ld: warning: duplicate -rpath '/Users/felix/anaconda3/envs/mtuq_felix/lib' ignored
ld: warning: duplicate -rpath '/Users/felix/anaconda3/envs/mtuq_felix/lib' ignored
copying build/lib.macosx-10.13-x86_64-cpython-312/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so -> mtuq/misfit/waveform

Unfortunately, I got the same error when I try to import mtuq read

from mtuq import read
Traceback (most recent call last):
File "", line 1, in
File "/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/init.py", line 35, in
from mtuq.misfit import PolarityMisfit, WaveformMisfit
File "/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/misfit/init.py", line 2, in
from mtuq.misfit.waveform import WaveformMisfit
File "/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/misfit/waveform/init.py", line 5, in
from mtuq.misfit.waveform import level0, level1, level2
File "/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/misfit/waveform/level2.py", line 14, in
from mtuq.misfit.waveform import c_ext_L2
ImportError: dlopen(/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so, 0x0002): tried: '/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so' (malformed load command #13 of 15 at 0x1059b45c8 with mh=0x1059b4000, size (0x0) too small), '/System/Volumes/Preboot/Cryptexes/OS/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so' (no such file), '/Users/felix/Documents/software/mtuq_felix/mtuq/mtuq/misfit/waveform/c_ext_L2.cpython-312-darwin.so' (malformed load command #13 of 15 at 0x1059b45c8 with mh=0x1059b4000, size (0x0) too small)

@rmodrak
Copy link
Member
rmodrak commented Apr 5, 2025

Hi Felix, Recently, the installation procedure was changed with the addition of "c-compiler" from conda itself. This seemed to help some users, but it could breaking things in your case? You might try experimenting with different compiler settings via the CC environment variable? https://mtuqorg.github.io/mtuq/install/issues.html#cython-compilation-settings

@SeismoFelix
Copy link
Member Author

Thanks Ryan,

Could you please elaborate in how the installation prrocedure changed (where was added the c-compiler). I would like (if possible) just to modify the installation file for myself and avoid the conflicts that the new installlation approach is causing to me. I tried to check the modified files in the last commit but I did not see any change related with the installation.

@rmodrak
Copy link
Member
rmodrak commented Apr 5, 2025

Sure, here is the change

- c-compiler

I think it was from about two weeks ago or so.

(I may be away from the computer for a while starting soon)

@SeismoFelix
Copy link
Member Author
SeismoFelix commented Apr 5, 2025

Thanks Ryan,

I appreciate you dedicate part of your Saturday to this. I simply used an old mtuq/env_default.yaml version where -c-compiler is not included. But did not work:

channels:

  • conda-forge
  • defaults

dependencies:

But I am not surprised. I need to become familiar in how to test different compilers settings. I do not know how to this right know, but I will check.

I am also surprised that I did sync my forked version with the master a week ago, before sumitting the pull request, and I could install my mtuq forkerd version for testing the modifications. I could install without any issue. If the installation procedure changed a month ago, then this modification should have affected the installation of my forked version a week ago. But this did not happen.

Thanks,

Felix

@SeismoFelix
Copy link
Member Author

I deleted the environment and the package, then I cloned MTUQ and repeat from scratch the installation process. Before running conda env update --file env.yaml I replaced the env_default.yaml by this old one:

channels:

  • conda-forge
  • defaults

dependencies:

And the installation worked. So, in the meantime I will stick with this old file while I figure out what compiler settings use for making the installation worhk with the new env_default.yaml version.

Thanks!

@rmodrak
Copy link
Member
rmodrak 5B1C commented Apr 6, 2025

Hi Felix, Glad to hear the good progress. I will try looking at this from my end as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0