rodluger / pysyzygy

A fast and general planet transit (syzygy) code written in C and in Python
MIT License
7 stars 5 forks source link

Errors in everest coming from pysyzygy failing to compile: transit.c:688:34: error: ‘HUGE’ undeclared #3

Open warrickball opened 6 years ago

warrickball commented 6 years ago

I'm having problems in everest which appear to come from pysyzygy failing to compile. I just installed everest with pip3 install everest-pipeline --user, which gave no error. On my first attempt to import it, I get

$ python3 -c "import everest"
[pysyzygy] Compiling C source code...
transit.c: In function ‘Interpolate’:
transit.c:688:34: error: ‘HUGE’ undeclared (first use in this function)
   transit->tN[transit->ntrans] = HUGE;                                                // A bit of a hack, but essential to get the last transit right below
                                  ^~~~
transit.c:688:34: note: each undeclared 
identifier is reported only once for each function it appears in
make: *** [Makefile:20: all] Error 1
Traceback (most recent call last):
  File "/home/wball/.local/lib/python3.6/site-packages/pysyzygy/transit.py", line 338, in <module>
    lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'transitlib.so'))
  File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /home/wball/.local/lib/python3.6/site-packages/pysyzygy/transitlib.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/wball/.local/lib/python3.6/site-packages/everest/__init__.py", line 23, in <module>
    from . import transit
  File "/home/wball/.local/lib/python3.6/site-packages/everest/transit.py", line 19, in <module>
    import pysyzygy as ps
  File "/home/wball/.local/lib/python3.6/site-packages/pysyzygy/__init__.py", line 26, in <module>
    from .transit import *
  File "/home/wball/.local/lib/python3.6/site-packages/pysyzygy/transit.py", line 340, in <module>
raise Exception("Can't find `transitlib.so`; please run `make` to compile `pysyzygy`.")
Exception: Can't find `transitlib.so`; please run `make` to compile `pysyzygy`.

I navigated to the pysyzygy folder and tried running make there myself, which just isolates the compile-time error above:

$ make
[pysyzygy] Compiling C source code...
transit.c: In function ‘Interpolate’:
transit.c:688:34: error: ‘HUGE’ undeclared (first use in this function)
   transit->tN[transit->ntrans] = HUGE;                                                // A bit of a hack, but essential to get the last transit right below
                                  ^~~~
transit.c:688:34: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:20: all] Error 1

I don't speak C but Googling the error gave me this hit, which suggested replacing HUGE with HUGE_VAL. That seemed to fix things for me. I hesitate to make a PR because I'm not sure if it my break compatibility on other systems.

I'm running Fedora 28 with gcc 8.1.1. Here's my detailed compiler information

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.1.1 20180712 (Red Hat 8.1.1-5) (GCC)
hippke commented 6 years ago

I had to fix the same line on Ubuntu 1804 (gcc 7.3). This must happen to many people. I recommend the fix suggested by @warrickball

rodluger commented 6 years ago

Thanks for bringing this up, and apologies for the delay in getting around to this. I'll push a fix and update the pip versions of everest and pysyzygy shortly.

rodluger commented 6 years ago

@warrickball @hippke Can you confirm that things work now after re-installing from pip?

warrickball commented 6 years ago

It appears to be fixed for me.