Open michaelnowotny opened 6 years ago
It's probably a missing path issue somewhere in setup.py. In date.cpp do you have a line saying #include "ql/time/date.hpp" ? And what's the compiler command used to compile date.cpp? If it contains -I/usr/local/include this should compile fine.
Yes, on line 620 in date.cpp, I have the following include:
The compiler command is as follows (from a different machine with MacOS on which I get the same error): building 'quantlib.time.date' extension gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/michaelnowotny/anaconda/include -arch x86_64 -I/Users/michaelnowotny/anaconda/include -arch x86_64 -I/usr/local/include -I. -I../sources/boost_1_55_0 -I./cpp_layer -I/Users/michaelnowotny/anaconda/lib/python3.6/site-packages/numpy/core/include -I/Users/michaelnowotny/anaconda/include/python3.6m -c quantlib/time/date.cpp -o build/temp.macosx-10.7-x86_64-3.6/quantlib/time/date.o
Any chance that you haven't defined QL_HIGH_RESOLUTION_DATE
? That would explain why the intraday part of the dates are not defined.
@dpinte is right of course, this must be the issue. You need to configure quantlib with --enable-intraday, same as issue #200
Thank you very much for your advice @thrasibule and @dpinte!
I had indeed not defined this option. The name of the option in homebrew is "--with-intraday" (rather than "--enable-intraday") and this enables QL_HIGH_RESOLUTION_DATE. The compilation goes through, but when running the unit tests via "make tests3" or "make tests" I get a segmentation fault:
python -m unittest discover -v make: *** [tests] Segmentation fault: 11
This happens on two macs I have tried it on (one with Sierra and the other one with High Sierra).
Any idea what might be causing this?
Thanks,
Michael
BTW: I am getting these clang warnings when compiling pyql:
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated] ld: warning: object file (build/temp.macosx-10.7-x86_64-3.6/quantlib/time_series.o) was built for newer OSX version (10.7) than being linked (10.6)
The segfaults happens right away?? no tests at all go through? From the directory you compiled pyql can you import quantlib at least? For instance try something like that.
from quantlib.time.date import today
today()
If I run the code above in the Python interpreter, I get the following error:
from quantlib.time.date import today Traceback (most recent call last): File "
", line 1, in ImportError: dlopen(/Volumes/GIT/pyql/quantlib/time/date.cpython-36m-darwin.so, 2): Symbol not found: _ZN8QuantLib10DateParser14parseFormattedERKSsS2 Referenced from: /Volumes/GIT/pyql/quantlib/time/date.cpython-36m-darwin.so Expected in: flat namespace in /Volumes/GIT/pyql/quantlib/time/date.cpython-36m-darwin.so
This happens on both Macs. I am going to try this on a third Mac which has Python installed via homebrew rather than Anaconda.
Ok, unit tests are running on the third Mac that does not use Anaconda. I am getting the same clang warnings:
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated] ld: warning: object file (build/temp.macosx-10.13-x86_64-3.6/quantlib/time/calendars/united_states.o) was built for newer OSX version (10.13) than being linked (10.6)
So these can not be causing the problem on the other computers. Any ideas what can be going on?
A few unit tests are failing but this is likely not connected:
Traceback (most recent call last): File "/Volumes/GIT/pyql/quantlib/test/test_mlab.py", line 198, in test_zero_rate maturity_dates=None) File "/Volumes/GIT/pyql/quantlib/mlab/term_structure.py", line 68, in zbt_libor_yield calendar=TARGET()) File "quantlib/time/schedule.pyx", line 63, in quantlib.time.schedule.Schedule.init self._thisptr = new _schedule.Schedule( RuntimeError: null termination date
Traceback (most recent call last): File "/Volumes/GIT/pyql/quantlib/test/test_piecewise_yield_curve.py", line 154, in test_bump_yieldcurve old_discount = ts.discount(ts.max_date) File "quantlib/termstructures/yield_term_structure.pyx", line 161, in quantlib.termstructures.yield_term_structure.YieldTermStructure.discount discount_value = term_structure.discount( RuntimeError: year 1900 out of bound. It must be in [1901,2199]
Traceback (most recent call last): File "/Volumes/GIT/pyql/quantlib/test/test_zero_coupon.py", line 110, in test_extrapolation "1st iteration: failed at 2nd alive instrument")) AssertionError: False is not true
@michaelnowotny do you know how brew build quantlib? You need to make sure it has been built with -stdlib=libc++ -mmacosx-version-min=10.9
(see http://www.quantlib.org/install/macosx.shtml) and same when building pyql.
This message seem to indicate it's not the case:
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: object file (build/temp.macosx-10.7-x86_64-3.6/quantlib/time_series.o) was built for newer OSX version (10.7) than being linked (10.6)
Hi @dpinte,
I do not know specifically know how quantlib is built in homebrew. The clang error message appears on all three macs I have tried it, including the one where everything works. The issue seems to be related to Anaconda. The issue appears on both computers which use Anaconda.
Furthermore, I have uninstalled Anaconda on one of the Macs and installed Python via hombrew. After that everything works. So there must be some issue with Anaconda. I will uninstall Python from homebrew and reinstall Anaconda. Who knows, perhaps the installation had been referring to an out-of-date compiler, even though I kept conda up-to-date.
But at this point, the problem seems to be unlikely to be causes by pyql or quantlib.
Thank you both for your help!
Michael
Installed Anaconda again from scratch and the segmentation fault reappears. This is very likely an issue with Anaconda on the Mac.
@michaelnowotny I can suggest using edm which is known to work as expected (https://www.enthought.com/product/enthought-deployment-manager).
Thank you @dpinte. I will take a closer look. It is currently not clear to me if this will work with Anaconda or is an alternative to Anaconda. For the time being, I can simply keep using hombrew on Mac.
Thanks again for your help!
Dear pyql developers,
I am experiencing the following compilation error on my platform:
quantlib/time/date.cpp:1722:80: error: no type named 'Hour' in namespace 'QuantLib' ...PyObject* Pyx_PyInt_From_QuantLib_3a3a_Hour(QuantLib::Hour value);