Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#33574 closed defect (fixed)

from PySide import QtCore fails

Reported by: blair (Blair Zajac) Owned by: mamoll (Mark Moll)
Priority: Normal Milestone:
Component: ports Version: 2.0.3
Keywords: Cc:
Port: py-pyside

Description

Using the latest PySide package with Python 2.7, this fails for me:

/opt/local/bin/python
Python 2.7.2 (default, Jan 13 2012, 20:57:55) 
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Setting tab completion.
>>> from PySide import QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtCore.so, 2): Symbol not found: _PyUnicodeUCS2_Compare
  Referenced from: /opt/local/lib/libshiboken-python2.7.1.1.dylib
  Expected in: flat namespace
 in /opt/local/lib/libshiboken-python2.7.1.1.dylib

This occurs on two separate systems, a MacBook Pro and MacPro, both running Lion.

Change History (11)

comment:1 Changed 12 years ago by mf2k (Frank Schima)

Port: py-pyside added; python-pyside removed

comment:2 Changed 12 years ago by mamoll (Mark Moll)

I cannot reproduce this on 10.7.3 with Xcode 4.3.1. Could trying uninstalling and reinstalling like so?:

sudo port -f uninstall python27 py27-shiboken py27-pyside
sudo port install py27-pyside

comment:3 Changed 12 years ago by blair (Blair Zajac)

I did those steps and I'm getting the same result. I'll update to the latest MacPorts and XCode and try again.

comment:4 Changed 12 years ago by blair (Blair Zajac)

I updated MacPorts, installed the latest Xcode, uninstalled python27 py27-shiboken py27-pyside, reinstalled py27-pyside and I'm getting the same error.

I install Python with the ucs4 variant to match our Linux installs, so that's probably the cause, since the error I'm getting is about a missing _PyUnicodeUCS2_Compare symbol.

comment:5 Changed 12 years ago by mamoll (Mark Moll)

UCS4 is not the same as UCS2. I don't understand why shiboken or pyside is looking for _PyUnicodeUCS2_Compare when you installed python27 +ucs4. UCS2 doesn't appear to be hard-coded in the shiboken or pyside code.

comment:6 Changed 12 years ago by blair (Blair Zajac)

Some progress in figuring this out. Looking at the output from 'port -d -v install py27-shiboken' it appears that the correct flags are not making it to the compiler, such as -DPYTHON_EXECUTABLE=${prefix}/bin/python${python.branch}. In fact, this is a cmake build so why are 'use_configure' and 'configure.args-append' used?

Here's a snippet from the build where it's compiling sbkstring.cpp which calls the offending PyUnicode_Compare() macro:

cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-shiboken/py27-shiboken/work/shiboken-1.1.0/libshiboken && /usr/bin/clang++   -DLIBSHIBOKEN_EXPORTS -DNDEBUG -pipe -O2 -arch x86_64  -Wall -fvisibility=hidden -Wno-strict-aliasing -O3 -DNDEBUG -arch x86_64 -fPIC -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-shiboken/py27-shiboken/work/shiboken-1.1.0/libshiboken -I/System/Library/Frameworks/Python.framework/Headers -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-shiboken/py27-shiboken/work/shiboken-1.1.0/ext/sparsehash    -o CMakeFiles/libshiboken.dir/sbkstring.cpp.o -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-shiboken/py27-shiboken/work/shiboken-1.1.0/libshiboken/sbkstring.cpp

Since the system's Python it built with ucs2 and my Python with ucs4, it explains the link failure.

Doing a 'port -v build py27-shiboken' and then compiling sbkstring.cpp by hand through cpp shows it's picking up the incorrect header files. I can confirm this by running the compiler with -E so it shows the preprocessor output:

$ /usr/bin/clang++   -DLIBSHIBOKEN_EXPORTS -DNDEBUG -pipe -O2 -arch x86_64  -Wall -fvisibility=hidden -Wno-strict-aliasing -O3 -DNDEBUG -arch x86_64 -fPIC -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-shiboken/py27-shiboken/work/shiboken-1.1.0/libshiboken -I/System/Library/Frameworks/Python.framework/Headers -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-shiboken/py27-shiboken/work/shiboken-1.1.0/ext/sparsehash -E /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-shiboken/py27-shiboken/work/shiboken-1.1.0/libshiboken/sbkstring.cpp | grep ^#|grep Python|head
# 1 "/System/Library/Frameworks/Python.framework/Headers/Python.h" 1
# 1 "/System/Library/Frameworks/Python.framework/Headers/patchlevel.h" 1
# 8 "/System/Library/Frameworks/Python.framework/Headers/Python.h" 2
# 1 "/System/Library/Frameworks/Python.framework/Headers/pyconfig.h" 1
# 9 "/System/Library/Frameworks/Python.framework/Headers/Python.h" 2

So it looks like fixing the port file to tell cmake the correct Python will be sufficient.

comment:7 Changed 12 years ago by mamoll (Mark Moll)

use_configure is used to run cmake (the python port group disables the configure stage). I checked in a fix in r90897. It wasn't picking up the right headers as you had noticed. Please confirm if it works now.

comment:8 Changed 12 years ago by blair (Blair Zajac)

Great, it's past this issue. Now its the _PyUnicodeUCS2_AsASCIIString symbol from py-side package.

$ python
Python 2.7.2 (default, Mar 11 2012, 10:30:33) 
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Setting tab completion.
>>> from PySide import QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtCore.so, 2): Symbol not found: _PyUnicodeUCS2_AsASCIIString
  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtCore.so
  Expected in: flat namespace
 in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtCore.so

comment:9 Changed 12 years ago by blair (Blair Zajac)

Taking your code from py-shiboken and applying it to py-pyside worked, now 'from PySide import QtGui' works. Here's the diff I used:

--- Portfile.orig	2012-01-02 20:00:28.000000000 -0800
+++ Portfile	2012-03-17 12:24:29.000000000 -0700
@@ -35,7 +35,11 @@
                         port:python${python.version}
     use_configure   yes
     configure.args-append -DBUILD_TESTS:BOOL=FALSE \
-                        -DSITE_PACKAGE=${prefix}/Library/Frameworks/Python.framework/Versions/${python.branch}/lib/python${python.branch}/site-packages
+                    -DPYTHON_EXECUTABLE=${python.bin} \
+                    -DPYTHON_LIBRARY=${python.lib} \
+                    -DPYTHON_INCLUDE_DIR=${python.include} \
+                    -DSITE_PACKAGE=${prefix}/Library/Frameworks/Python.framework/Versions/${python.branch}/lib/python${python.branch}/site-packages
+

Do we need SITE_PACKAGE given that py-shiboken doesn't use it?

comment:10 Changed 12 years ago by mamoll (Mark Moll)

Resolution: fixed
Status: newclosed

committed pyside change in r90908. Closing this ticket.

comment:11 Changed 12 years ago by blair (Blair Zajac)

Thanks for the help on this ticket, I appreciate it!

Regards, Blair

Note: See TracTickets for help on using tickets.