ericmandel / pyds9

Python connection to SAOimage DS9 via XPA
76 stars 41 forks source link

Mac OS X issues #17

Closed cdeil closed 6 years ago

cdeil commented 9 years ago

I wanted to try out pyds9 on my Mac, but it doesn't work with Python 2 or 3.

The build log shows that somehow gcc 4.9 from Macports is picked as compiler and there's these linker errors:

mklib: Making Darwin shared library:  libxpa.1.0.dylib
ld: warning: could not create compact unwind for _XPAProxyAccept.isra.5: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPAClientStart: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPAClientConnect: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPACmdLookup: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _Find: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPARemote: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _launch_fork_exec: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPAError: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPAMessage: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPANSOpen: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPANSAdd.part.8: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPANSLookup: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _XPAHandler: stack subq instruction is too different from dwarf stack size

Importing pyds9 works, but when I try to create a DS9 object, the DS9 Window comes up, but the Python prompt hangs for a few seconds and then errors out like this (leaving the DS9 Window open after the Python interpreter exists):

$ cd /tmp
$ python -c 'import pyds9; pyds9.DS9()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/deil/Library/Python/3.4/lib/python/site-packages/pyds9.py", line 403, in __init__
    raise ValueError('no active ds9 running for target: %s' % target)
ValueError: no active ds9 running for target: ds9

@montefra @ericmandel Any idea what the issue is or how I can debug / try to fix it?

cdeil commented 9 years ago

Ah ... so pyds9 does have some tests! I'm getting this:

$ python -c 'import pyds9; pyds9.test()'
starting quick test for pyds9 version 1.7
looking for our 'pytest' ds9 ...
starting ds9 ...

waiting for ds9 to be available 
.
.
.
.
.
.
.
.
.
.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/deil/Library/Python/3.4/lib/python/site-packages/pyds9.py", line 769, in test
    raise ValueError("tired of waiting for ds9!")
ValueError: tired of waiting for ds9!
montefra commented 9 years ago

for the compilation error I have no idea. I can compile with without problem under ubuntu with gcc 4.9.2 and opensuse with gcc 5.x.x (I don't remember the exact version).

For the test: if you are in the source directory you can also run it with python pyds9.py.

I had a similar problem and @ericmandel wrote this

ericmandel commented 9 years ago

I just built successfully on my Mac, using the Apple-supplied gcc (which is clang-602.0.53).

But here and here are discussions. I hate to add and commit the recommended link switch without actually seeing the problem and then seeing it go away. So @cdeil, if you could edit your setup.py on the machine where this is happening, and add "-Wl,-no_compact_unwind" to CFLAGS (which will then be passed to the linker), that would tell us something.

ericmandel commented 9 years ago

If I add "-Wl,-no_compact_unwind" to CFLAGS for the default Mac compiler (ggg -> clang), I get a warning:

gcc -c -I. -O2 -Wl,-no_compact_unwind -DHAVE_CONFIG_H xpamb.c
clang: warning: -Wl,-no_compact_unwind: 'linker' input unused

It looks like we can add it to LDFLAGS safely, without any warnings. So, @cdeil, instead of the above, please try editing your setup.py as follows:

diff --git a/setup.py b/setup.py
index 55da589..450ce01 100644
--- a/setup.py
+++ b/setup.py
@@ -28,11 +28,15 @@ def make(which):
     if which == 'all':
         os.system('echo "building XPA shared library ..."')
         cflags = ''
+        ldflags = ''
         if 'CFLAGS' not in os.environ and struct.calcsize("P") == 4:
             if ulist[0] == 'Darwin' or ulist[4] == 'x86_64':
                 os.system('echo "adding -m32 to compiler flags ..."')
                 cflags = ' CFLAGS="-m32"'
-        os.system('./configure --enable-shared --without-tcl'+cflags)
+        if 'LDFLAGS' not in os.environ:
+            if ulist[0] == 'Darwin':
+                ldflags = ' LDFLAGS="-no_compact_unwind"'
+        os.system('./configure --enable-shared --without-tcl'+cflags+ldflags)
         os.system('make clean; make; rm -f *.o')
     elif which == 'clean':
         os.system('echo "cleaning XPA ..."')

and see of the warning goes away.

montefra commented 6 years ago

I close this issue: the build system has changed (now it uses astropy-helpers) and pyds9 builds on one osx instance in travis-ci.