getting GDCM to work (on Mac)

1,086 views
Skip to first unread message

mike

unread,
May 17, 2011, 2:34:56 AM5/17/11
to PyInstaller
Hi all,

Below is the patch file (everything in between the starred lines) to
get the Python bindings for GDCM (http://sourceforge.net/apps/
mediawiki/gdcm/index.php) to work with PyInstaller. In this case, I
added '/usr/local/lib' to the fwpaths, which is used to determine
whether the results from otool should be included.

In this case, I believe that /usr/local/lib is a common install
location for 3rd party applications and libraries on the mac, so
should be included.

Cheers
Mike


********************************
Index: PyInstaller/bindepend.py
===================================================================
--- PyInstaller/bindepend.py (revision 1406)
+++ PyInstaller/bindepend.py (working copy)
@@ -462,7 +462,7 @@
This implementation is for otool platforms"""
# dyld searches these paths for framework libs
# we ignore DYLD_FALLBACK_LIBRARY_PATH for now (man dyld)
- fwpaths = ['/Library/Frameworks', '/Network/Library/Frameworks',
'/System/Library/Frameworks']
+ fwpaths = ['/Library/Frameworks', '/Network/Library/Frameworks',
'/System/Library/Frameworks', '/usr/local/lib']
for p in reversed(os.environ.get('DYLD_FRAMEWORK_PATH',
'').split(':')):
if p:
fwpaths.insert(0, p)
********************************

Hartmut Goebel

unread,
May 17, 2011, 5:31:02 AM5/17/11
to pyins...@googlegroups.com
Am 17.05.2011 08:34, schrieb mike:
> In this case, I believe that /usr/local/lib is a common install
> location for 3rd party applications and libraries on the mac, so
> should be included.

IMHO these applications do not honor the OS X coding style (same for
pyside). /usr/lib and /usr/local/lib are typical Unix paths, while OS X
used pathes like /Library/Frameworks.

Nevertheless it looks as if we need to support these paths :-(

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult mit Mitglied bei http://www.7-it.de


mike

unread,
May 17, 2011, 5:39:37 AM5/17/11
to PyInstaller

> > In this case, I believe that /usr/local/lib is a common install
> > location for 3rd party applications and libraries on the mac, so
> > should be included.
>
> IMHO these applications do not honor the OS X coding style (same for
> pyside). /usr/lib and /usr/local/lib are typical Unix paths, while OS X
> used pathes like /Library/Frameworks.

I believe that paths like /Library/Frameworks are for Mac specific
libraries, but as OS X is BSD based, its support of such paths is in
addition to its support of common Unix paths used by generic Unix
libraries.

> Nevertheless it looks as if we need to support these paths :-(

If that's the decision, then there will also need to be a list to
exclude the libraries that the current implementation is trying to
excluded, eg libstdc++.6.dylib and libSystem.B.dylib


Cheers
Mike

Hartmut Goebel

unread,
May 17, 2011, 5:56:39 AM5/17/11
to pyins...@googlegroups.com
Am 17.05.2011 11:39, schrieb mike:
> If that's the decision, then there will also need to be a list to
> exclude the libraries that the current implementation is trying to
> excluded, eg libstdc++.6.dylib and libSystem.B.dylib
IC. Are these libraries standard libs on every OS X system?

So we should try first to find another solution.

Did you try a hook which adds the pyside/gdmc files fro /usr/local/lib,
/usr/lib as `data` files to the pyinstaller archive? Something like:

datas = [
("/usr/lib/pyside.so", ""),
]

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen

http://www.goebel-consult.de/blog

mike

unread,
May 17, 2011, 7:24:49 AM5/17/11
to PyInstaller
> IC. Are these libraries standard libs on every OS X system?

For me, except for PySide and gdcm, I would imagine that every other
OS X developer has them, which is why the assumption to exclude
everything in /usr/lib and /usr/local/lib has worked so far.

> Did you try a hook which adds the pyside/gdmc files fro /usr/local/lib,
> /usr/lib as `data` files to the pyinstaller archive? Something like:

This may work. Hardcoding the required files does copy them over, but
there are some things to consider
* This is only required on OS X, ie both PySide and gdcm work on
Windows w/o hooks
* The libraries have names like /usr/lib/libpyside-
python2.6.1.0.2.dylib, usr/lib/libpyside-python2.6.1.0.dylib, /usr/lib/
libpyside-python2.6.dylib, of which 2 are simlinked to the 3rd. That
and because there may be version differences (eg 2.6 vs 2.7), we can't
hardcode it
* Even if we knew which version of the software, we don't know which
version of the dylib is actually needed, so otool is still the command
to call to determine which one to copy over.
* If we're going to use otool anyway, it seems like too much of an
overhead to do the same thing in the hook, except to exclude/include
different things than what's happening in bindepend.py

Cheers
Mike

Martin Zibricky

unread,
May 17, 2011, 5:22:11 PM5/17/11
to pyins...@googlegroups.com
mike píše v Út 17. 05. 2011 v 04:24 -0700:

> * Even if we knew which version of the software, we don't know which
> version of the dylib is actually needed, so otool is still the command
> to call to determine which one to copy over.
> * If we're going to use otool anyway, it seems like too much of an
> overhead to do the same thing in the hook, except to exclude/include
> different things than what's happening in bindepend.py

What exclude/include list does py2app use?

mike

unread,
May 19, 2011, 5:01:18 AM5/19/11
to PyInstaller

> What exclude/include list does py2app use?

From this file, it looks like py2app uses the macholib for a lot of
the heavy lifting
http://svn.pythonmac.org/py2app/py2app/trunk/py2app/filters.py

macholib
http://packages.python.org/macholib/

Cheers
Mike

Martin Zibricky

unread,
May 19, 2011, 5:19:07 AM5/19/11
to pyins...@googlegroups.com
mike píše v Čt 19. 05. 2011 v 02:01 -0700:

How much work would it be to start using macholib for some mac specific
stuff?

mike

unread,
May 20, 2011, 2:43:38 AM5/20/11
to PyInstaller
> How much work would it be to start using macholib for some mac specific
> stuff?

I guess it depends on who will be doing the work and how much
knowledge that person has about PyInstaller and macholib. If that
person were me, the answer would be "a lot of work and a long time",
because I know not much about either :)

Cheers
Mike

Martin Zibricky

unread,
May 20, 2011, 4:27:52 AM5/20/11
to pyins...@googlegroups.com
mike píše v Čt 19. 05. 2011 v 23:43 -0700:

> I guess it depends on who will be doing the work and how much
> knowledge that person has about PyInstaller and macholib. If that
> person were me, the answer would be "a lot of work and a long time",
> because I know not much about either :)

Could you please investigate what macholib can be used in pyinstaller
for?

We already know that it could replace calling the otool (similar to ldd
on linux). Could it be use for anything else?

mike

unread,
May 24, 2011, 3:37:22 AM5/24/11
to PyInstaller
I'd like to help out more, but at this point, I don't have the time
for the due diligence required for such an investigation. I also
think we are getting sidetracked. The problem today isn't with any of
the tools that PyInstaller is using.

Going back to the original issue for PySide, GDCM, etc, otool reports
the dependency libraries just fine. It's PyInstaller that's
improperly filtering out libraries in /usr/lib and /usr/local/lib.
That would still be a problem if PyInstaller switches to macholib.
So, my opinion of what really needs to be changed is how PyInstaller
filters the dependency libraries.

Cheers
Mike

Hartmut Goebel

unread,
May 24, 2011, 4:38:16 AM5/24/11
to pyins...@googlegroups.com
Am 24.05.2011 09:37, schrieb mike:
> Going back to the original issue for PySide, GDCM, etc, otool reports
> the dependency libraries just fine. It's PyInstaller that's
> improperly filtering out libraries in /usr/lib and /usr/local/lib.
> [...]

> So, my opinion of what really needs to be changed is how PyInstaller
> filters the dependency libraries.

AS you may know, bindepend already include an exclude/include mechanism
for filtering. So your proposed changes will come down to:

1) Add /usr/lib and /usr/local/lib the the lib-search-path (fwpath) with
ootool. Okay for me.

2) Do some "hacks" with pyside and shiboken. As far as I understood,
this includes all libs which's name contains pyside or shiboken. We
should use the already implemented include mechanism for that. Simply
add a regex to the (yet empty) "includes" dict.

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/

michael j pan

unread,
Aug 13, 2011, 7:30:01 AM8/13/11
to pyins...@googlegroups.com

AS you may know, bindepend already include an exclude/include mechanism
for filtering. So your proposed changes will  come down to:

1) Add /usr/lib and /usr/local/lib the the lib-search-path (fwpath) with
ootool. Okay for me.

So I looked closer at the code, and right now, it ignores DYLD_FALLBACK_LIBRARY_PATH
        # dyld searches these paths for framework libs
        # we ignore DYLD_FALLBACK_LIBRARY_PATH for now (man dyld)
when I do a "man dyld", it says "By default, [DYLD_FALLBACK_LIBRARY_PATH] is set to $(HOME)/lib:/usr/local/lib:/lib:/usr/lib."  Is there a reason for ignorning DYLD_FALLBACK_LIBRARY_PATH?  If not, instead of hardcoding /usr/lib and /usr/local/lib, could Pyinstall just not ignore it?
 

Reply all
Reply to author
Forward
0 new messages