|
From: Luigi B. <lui...@gm...> - 2024-11-04 17:15:16
|
No problem, glad it worked!
On Mon, Nov 4, 2024 at 6:11 PM Matthew Hancock <mat...@gm...>
wrote:
> Hi Luigi,
>
> I installed a new version of python compiled for arm and also installed
> via the wheel as suggested and now QuantLib is importing correctly. Thanks
> for your help!!
>
> Best
> Matthew
>
> On Nov 4, 2024, at 9:14 AM, Luigi Ballabio <lui...@gm...>
> wrote:
>
> Hi, there might be a couple of things you can try.
>
> The first is checking if the problem is the mismatch between x86 and arm:
> is the Python coming with Anaconda compiled for x86? If so, and if you
> can't upgrade to a version for arm, you can try cross-compiling QuantLib
> for x86 so it matches the architecture. Running
>
> ./configure --with-boost-include=/opt/homebrew/include/ \
> --prefix=${HOME}/Documents/QuantLib-1.36_build
> --disable-shared \
> CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9 -arch
> x86_64' \
> LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9 -arch x86_64’
>
> should do that.
>
> The second thing is to try to build a wheel instead, and install that. As
> of 1.36, the commands would be
>
> cd QuantLib-SWIG-1.36
> ./configure \
> CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9’ \
> LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9’ \
> PYTHON=/Users/matthew/opt/anaconda3/envs/py39/bin/python3
> make -C Python
>
> To make it work, you might have to `pip install build` in your
> environment, or whatever conda requires to install modules.
> When the make step completes, you should have a QuantLib wheel
> in QuantLib-SWIG-1.36/Python/dist that you can try installing with pip or
> conda instead of running "python setup.py install" (that I don't trust a
> lot).
>
> Let me know how it goes.
>
> Luigi
>
>
>
> On Mon, Nov 4, 2024 at 3:06 PM Matthew Hancock <mat...@gm...>
> wrote:
>
>> Hi Luigi,
>>
>> Thanks for your response. I am attempting to build QuantLib myself to
>> turn on higher-resolution dates for intraday analysis.
>>
>> Here are the commands I am using to build QuantLib:
>>
>> (base) matthew@Matthews-MacBook-Pro-5 Documents % tar xzvf
>> QuantLib-1.36.tar.gz
>>
>> (base) matthew@Matthews-MacBook-Pro-5 Documents % cd QuantLib-1.36
>>
>> (base) matthew@Matthews-MacBook-Pro-5 QuantLib-1.36 % ./configure
>> --with-boost-include=/opt/homebrew/include/ \
>> --prefix=${HOME}/Documents/QuantLib-1.36_build
>> --disable-shared \
>> CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9' \
>> LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9’
>>
>> (base) matthew@Matthews-MacBook-Pro-5 QuantLib-1.36 % make -j8
>>
>> (base) matthew@Matthews-MacBook-Pro-5 QuantLib-1.36 % make install
>>
>> I can compile and run the C++ examples successfully.
>>
>> I then try and build QuantLib-SWIG-1.36:
>>
>> (base) matthew@Matthews-MacBook-Pro-5 Documents % tar xzf
>> QuantLib-SWIG-1.36.tar.gz
>>
>> (base) matthew@Matthews-MacBook-Pro-5 Documents % cd
>> QuantLib-SWIG-1.36/Python
>>
>> (base) matthew@Matthews-MacBook-Pro-5 QuantLib-SWIG-1.36 % export
>> CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9’
>>
>> (base) matthew@Matthews-MacBook-Pro-5 QuantLib-SWIG-1.36 % export
>> LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9’
>>
>> Here I am using a conda python39 environment to build/install:
>>
>> (py39) matthew@Matthews-MacBook-Pro-5 Python %
>> /Users/matthew/opt/anaconda3/envs/py39/bin/python3 setup.py build
>>
>> This generates some warnings related to compatibility between arm and x86
>> (I’m building on M1):
>>
>> running build
>> running build_py
>> creating build/lib.macosx-10.15-x86_64-cpython-39/QuantLib
>> copying src/QuantLib/__init__.py ->
>> build/lib.macosx-10.15-x86_64-cpython-39/QuantLib
>> copying src/QuantLib/QuantLib.py ->
>> build/lib.macosx-10.15-x86_64-cpython-39/QuantLib
>> running build_ext
>> building 'QuantLib._QuantLib' extension
>> creating build/temp.macosx-10.15-x86_64-cpython-39/src/QuantLib
>> clang++ -O2 -stdlib=libc++ -mmacosx-version-min=10.9
>> -DPy_LIMITED_API=0x03080000 -DNDEBUG
>> -I/Users/matthew/Documents/QuantLib-1.36_build/include
>> -I/Users/matthew/opt/anaconda3/envs/py39/include/python3.9 -c
>> src/QuantLib/quantlib_wrap.cpp -o
>> build/temp.macosx-10.15-x86_64-cpython-39/src/QuantLib/quantlib_wrap.o
>> -std=c++17 -Wno-unused -O2 -stdlib=libc++ -mmacosx-version-min=10.9
>> clang++ -O2 -stdlib=libc++ -mmacosx-version-min=10.9 -bundle -undefined
>> dynamic_lookup -stdlib=libc++ -mmacosx-version-min=10.9 -O2 -stdlib=libc++
>> -mmacosx-version-min=10.9
>> build/temp.macosx-10.15-x86_64-cpython-39/src/QuantLib/quantlib_wrap.o
>> -L/Users/matthew/Documents/QuantLib-1.36_build/lib -lQuantLib -o
>> build/lib.macosx-10.15-x86_64-cpython-39/QuantLib/_QuantLib.abi3.so
>> <http://quantlib.abi3.so/> -stdlib=libc++ -mmacosx-version-min=10.9
>> ld: warning: ignoring file
>> /Users/matthew/Documents/QuantLib-1.36_build/lib/libQuantLib.a, building
>> for macOS-x86_64 but attempting to link with file built for macOS-arm64
>>
>> (py39) matthew@Matthews-MacBook-Pro-5 Python %
>> /Users/matthew/opt/anaconda3/envs/py39/bin/python3 setup.py install
>>
>> This appears to run successfully (though the package name contains x86):
>>
>> Installed
>> /Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg
>> Processing dependencies for QuantLib==1.36
>> Finished processing dependencies for QuantLib==1.36
>>
>> Then trying to import QuantLib raises an error:
>>
>> (py39) matthew@Matthews-MacBook-Pro-5 Python % python
>> Python 3.9.20 (main, Oct 3 2024, 02:27:54)
>> [Clang 14.0.6 ] :: Anaconda, Inc. on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import QuantLib as ql
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File
>> "/Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg/QuantLib/__init__.py",
>> line 19, in <module>
>> from .QuantLib import *
>> File
>> "/Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg/QuantLib/QuantLib.py",
>> line 10, in <module>
>> from . import _QuantLib
>> ImportError:
>> dlopen(/Users/matthew/opt/anaconda3/envs/py39/lib/python3.9/site-packages/QuantLib-1.36-py3.9-macosx-10.15-x86_64.egg/QuantLib/_
>> QuantLib.abi3.so <http://quantlib.abi3.so/>, 0x0002): symbol not found
>> in flat namespace ‘__ZN8QuantLib12SmileSection6updateEv'
>>
>> Thanks for your help!
>>
>> Best
>> Matthew
>>
>>
>> On Nov 4, 2024, at 4:38 AM, Luigi Ballabio <lui...@gm...>
>> wrote:
>>
>> Hi Matthew,
>> I assume you've changed something in the library so you can't just
>> use `pip install QuantLib`, correct?
>> May you post the exact commands you're using to build the library and
>> Python module? Thanks!
>>
>> Luigi
>>
>>
>> On Sun, Nov 3, 2024 at 2:30 AM Matthew Hancock <
>> mat...@gm...> wrote:
>>
>>> Hi QuantLib team,
>>>
>>> I am running into an issue building QuantLib-SWIG-1.36 on a Mac M1
>>> running Mac OS 10.14. I am using an Anaconda version of Python 3.8.
>>>
>>> I can build QuantLib-1.36 with no issue (I added the --disabled-shared
>>> flag).
>>>
>>> However, when I build QuantLib-SWIG-1.36 and try to import the Python
>>> library, I get an import error:
>>>
>>> >>> import QuantLib
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> File
>>> "/Users/matthew/opt/anaconda3/lib/python3.8/site-packages/QuantLib-1.36-py3.8-macosx-10.9-x86_64.egg/QuantLib/__init__.py",
>>> line 19, in <module>
>>> from .QuantLib import *
>>> File
>>> "/Users/matthew/opt/anaconda3/lib/python3.8/site-packages/QuantLib-1.36-py3.8-macosx-10.9-x86_64.egg/QuantLib/QuantLib.py",
>>> line 10, in <module>
>>> from . import _QuantLib
>>> ImportError:
>>> dlopen(/Users/matthew/opt/anaconda3/lib/python3.8/site-packages/QuantLib-1.36-py3.8-macosx-10.9-x86_64.egg/QuantLib/_
>>> QuantLib.abi3.so <http://quantlib.abi3.so/>, 0x0002): symbol not found
>>> in flat namespace '__ZN8QuantLib12SmileSection6updateEv'
>>>
>>> Any help would be much appreciated, thanks!
>>>
>>> Best
>>> Matthew
>>>
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> Qua...@li...
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>>
>>
>
|