[GRASS-dev] getting vdigit to compile correctly on the Mac

Here is a link to discussion that may help explain why vdigit is not compiling correctly on a Mac–especially with OX X 10.5 (Leopard) that comes with Python 2.5–and a couple of solutions to fixing it.

http://mail.python.org/pipermail/pythonmac-sig/2008-January/019628.html

Michael


C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

On Sep 13, 2008, at 10:54 AM, Michael Barton wrote:

Here is a link to discussion that may help explain why vdigit is not compiling correctly on a Mac--especially with OX X 10.5 (Leopard) that comes with Python 2.5--and a couple of solutions to fixing it.

http://mail.python.org/pipermail/pythonmac-sig/2008-January/019628.html

I've suggested distutils before. It just needs someone to write the setup.py script.

Also, your problem may be a bit different - it may be configure that's messing up. Are the python flags in your platform.make pointing to the system python or the python.org python?

Configure uses python-config to get the configuration of python includes and libs. If you just say "--with-python" (as I have in the example in the GRASS OSX readme) configure will try to find it in your PATH, and may be getting it wrong.

Try setting a path to python-config when configuring. It should be /usr/local/bin/python-config (symlinks installed by python.org installer). ie:

--with-python=/usr/local/bin/python-config

If configure is getting it right and it's still messing up the linking, another possibility is that the python.org python doesn't install lib symlinks in /usr/local/lib, so even though the library path is specified it may get the system python from /usr/lib. It's not supposed to, but I've seen it happen with the system sqlite vs. my sqlite framework (though not recently, maybe the new Xcode has fixed this).

I could try it, but I don't want to mess up my MacBook by installing (for real) the python.org python (I like the system python), though I could try it on my Mini.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

[Trillian] What are you supposed to do WITH a maniacally depressed robot?

[Marvin] You think you have problems? What are you supposed to do if you ARE a maniacally depressed robot? No, don't try and answer, I'm 50,000 times more intelligent than you and even I don't know the answer...

- HitchHiker's Guide to the Galaxy

Thanks William,

I'll give these a whirl and report back.

Michael
____________________
C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

On Sep 13, 2008, at 10:20 AM, William Kyngesburye wrote:

On Sep 13, 2008, at 10:54 AM, Michael Barton wrote:

Here is a link to discussion that may help explain why vdigit is not compiling correctly on a Mac--especially with OX X 10.5 (Leopard) that comes with Python 2.5--and a couple of solutions to fixing it.

[Pythonmac-SIG] Path Issues when using Swig (and OSX Leopard)

I've suggested distutils before. It just needs someone to write the setup.py script.

Also, your problem may be a bit different - it may be configure that's messing up. Are the python flags in your platform.make pointing to the system python or the python.org python?

Configure uses python-config to get the configuration of python includes and libs. If you just say "--with-python" (as I have in the example in the GRASS OSX readme) configure will try to find it in your PATH, and may be getting it wrong.

Try setting a path to python-config when configuring. It should be /usr/local/bin/python-config (symlinks installed by python.org installer). ie:

--with-python=/usr/local/bin/python-config

If configure is getting it right and it's still messing up the linking, another possibility is that the python.org python doesn't install lib symlinks in /usr/local/lib, so even though the library path is specified it may get the system python from /usr/lib. It's not supposed to, but I've seen it happen with the system sqlite vs. my sqlite framework (though not recently, maybe the new Xcode has fixed this).

I could try it, but I don't want to mess up my MacBook by installing (for real) the python.org python (I like the system python), though I could try it on my Mini.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

[Trillian] What are you supposed to do WITH a maniacally depressed robot?

[Marvin] You think you have problems? What are you supposed to do if you ARE a maniacally depressed robot? No, don't try and answer, I'm 50,000 times more intelligent than you and even I don't know the answer...

- HitchHiker's Guide to the Galaxy

On Sep 13, 2008, at 10:20 AM, William Kyngesburye wrote:

On Sep 13, 2008, at 10:54 AM, Michael Barton wrote:

Here is a link to discussion that may help explain why vdigit is not compiling correctly on a Mac--especially with OX X 10.5 (Leopard) that comes with Python 2.5--and a couple of solutions to fixing it.

[Pythonmac-SIG] Path Issues when using Swig (and OSX Leopard)

I've suggested distutils before. It just needs someone to write the setup.py script.

Also, your problem may be a bit different - it may be configure that's messing up. Are the python flags in your platform.make pointing to the system python or the python.org python?

Answer #1: looks like platform make is pointing to the correct Python. eg...

PYTHONINC = -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5

Michael

Configure uses python-config to get the configuration of python includes and libs. If you just say "--with-python" (as I have in the example in the GRASS OSX readme) configure will try to find it in your PATH, and may be getting it wrong.

Try setting a path to python-config when configuring. It should be /usr/local/bin/python-config (symlinks installed by python.org installer). ie:

--with-python=/usr/local/bin/python-config

If configure is getting it right and it's still messing up the linking, another possibility is that the python.org python doesn't install lib symlinks in /usr/local/lib, so even though the library path is specified it may get the system python from /usr/lib. It's not supposed to, but I've seen it happen with the system sqlite vs. my sqlite framework (though not recently, maybe the new Xcode has fixed this).

I could try it, but I don't want to mess up my MacBook by installing (for real) the python.org python (I like the system python), though I could try it on my Mini.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

[Trillian] What are you supposed to do WITH a maniacally depressed robot?

[Marvin] You think you have problems? What are you supposed to do if you ARE a maniacally depressed robot? No, don't try and answer, I'm 50,000 times more intelligent than you and even I don't know the answer...

- HitchHiker's Guide to the Galaxy

Answer #2
On Sep 13, 2008, at 10:20 AM, William Kyngesburye wrote:

On Sep 13, 2008, at 10:54 AM, Michael Barton wrote:

Here is a link to discussion that may help explain why vdigit is not compiling correctly on a Mac--especially with OX X 10.5 (Leopard) that comes with Python 2.5--and a couple of solutions to fixing it.

[Pythonmac-SIG] Path Issues when using Swig (and OSX Leopard)

I've suggested distutils before. It just needs someone to write the setup.py script.

Also, your problem may be a bit different - it may be configure that's messing up. Are the python flags in your platform.make pointing to the system python or the python.org python?

Configure uses python-config to get the configuration of python includes and libs. If you just say "--with-python" (as I have in the example in the GRASS OSX readme) configure will try to find it in your PATH, and may be getting it wrong.

Try setting a path to python-config when configuring. It should be /usr/local/bin/python-config (symlinks installed by python.org installer). ie:

--with-python=/usr/local/bin/python-config

If configure is getting it right and it's still messing up the linking, another possibility is that the python.org python doesn't install lib symlinks in /usr/local/lib, so even though the library path is specified it may get the system python from /usr/lib. It's not supposed to, but I've seen it happen with the system sqlite vs. my sqlite framework (though not recently, maybe the new Xcode has fixed this).

There are lib symlinks to the system python in /usr/lib but none in /usr/local/lib.

I'll try compiling with specifying /usr/local/bin/python-config to see if that works. If not, it may be necessary to make the symlinks in /usr/local/lib

Michael

I could try it, but I don't want to mess up my MacBook by installing (for real) the python.org python (I like the system python), though I could try it on my Mini.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

[Trillian] What are you supposed to do WITH a maniacally depressed robot?

[Marvin] You think you have problems? What are you supposed to do if you ARE a maniacally depressed robot? No, don't try and answer, I'm 50,000 times more intelligent than you and even I don't know the answer...

- HitchHiker's Guide to the Galaxy

Answer #3

On Sep 13, 2008, at 10:20 AM, William Kyngesburye wrote:

On Sep 13, 2008, at 10:54 AM, Michael Barton wrote:

Here is a link to discussion that may help explain why vdigit is not compiling correctly on a Mac--especially with OX X 10.5 (Leopard) that comes with Python 2.5--and a couple of solutions to fixing it.

[Pythonmac-SIG] Path Issues when using Swig (and OSX Leopard)

I've suggested distutils before. It just needs someone to write the setup.py script.

Also, your problem may be a bit different - it may be configure that's messing up. Are the python flags in your platform.make pointing to the system python or the python.org python?

Configure uses python-config to get the configuration of python includes and libs. If you just say "--with-python" (as I have in the example in the GRASS OSX readme) configure will try to find it in your PATH, and may be getting it wrong.

Try setting a path to python-config when configuring. It should be /usr/local/bin/python-config (symlinks installed by python.org installer). ie:

--with-python=/usr/local/bin/python-config

If configure is getting it right and it's still messing up the linking, another possibility is that the python.org python doesn't install lib symlinks in /usr/local/lib, so even though the library path is specified it may get the system python from /usr/lib. It's not supposed to, but I've seen it happen with the system sqlite vs. my sqlite framework (though not recently, maybe the new Xcode has fixed this).

Still doesn't work. So I'll have to try manually creating the symlinks.

Dumb question: What is the command for creating the symlinks in the right way?

Michael

I could try it, but I don't want to mess up my MacBook by installing (for real) the python.org python (I like the system python), though I could try it on my Mini.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

[Trillian] What are you supposed to do WITH a maniacally depressed robot?

[Marvin] You think you have problems? What are you supposed to do if you ARE a maniacally depressed robot? No, don't try and answer, I'm 50,000 times more intelligent than you and even I don't know the answer...

- HitchHiker's Guide to the Galaxy

On Sep 13, 2008, at 1:38 PM, Michael Barton wrote:

There are lib symlinks to the system python in /usr/lib but none in /usr/local/lib.

I'll try compiling with specifying /usr/local/bin/python-config to see if that works.

Well, if the python settings in platform.make are correct, as you found, this won't help.

If not, it may be necessary to make the symlinks in /usr/local/lib

Michael

Python is not broken, so we should try to avoid "fixing" it with symlinks. it's more a problem of a confused or broken linker.

Either someone figures out distutils, or we work around it by editing platform.make (until a better fix is found) or do something in configure.

I could try it, but I don't want to mess up my MacBook by installing (for real) the python.org python (I like the system python), though I could try it on my Mini.

I just tried it on my Mini.

OSX 10.5.4
Xcode 3.1
MacPython 2.5.2
wxpython 2.8.8.1

It configures fine, but for some reason it's linking the system python (but it IS linking the correct wxpython).

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

The equator is so long, it could encircle the earth completely once.

On Sep 13, 2008, at 2:05 PM, William Kyngesburye wrote:

If not, it may be necessary to make the symlinks in /usr/local/lib

Michael

Python is not broken, so we should try to avoid "fixing" it with symlinks. it's more a problem of a confused or broken linker.

Either someone figures out distutils, or we work around it by editing platform.make (until a better fix is found) or do something in configure.

Here's a mostly proper way to do it - technically, binary python extensions on OSX don't need to link directly to python (as I've mentioned before). Either you use the -bundle-loader link flag (the standard way, what distutils would do) or use -undefined dynamic_lookup (the alternative).

Since we already use -undefined dynamic_lookup to handle the libgdi problem, we don't need any of the python ldflags. In the vdigit makefile, like this:

EXTRA_LIBS = $(VECTLIB) $(GISLIB) $(GDALLIBS) $(VEDITLIB) $(WXWIDGETSLIB)
ifeq ($(findstring darwin,$(ARCH)),darwin)
EXTRA_LIBS := -bundle -undefined dynamic_lookup $(EXTRA_LIBS)
else
EXTRA_LIBS := $(EXTRA_LIBS) $(PYTHONLDFLAGS) -lgdi
endif

I moved the PYTHONLDFLAGS into the non-OSX extra-libs. In the same manner, since wxnviz also has a binary python extension, we should do the same thing in the wxpython nviz makefile (just without the -lgdi bit):

EXTRA_LIBS = $(GISLIB) $(WXWIDGETSLIB) $(XLIBPATH) $(XMLIB) $(XTLIB) $(XLIB) $(XEXTRALIBS) $(OGSFLIB) $(NVIZLIB)
ifeq ($(findstring darwin,$(ARCH)),darwin)
EXTRA_LIBS := -bundle -undefined dynamic_lookup $(EXTRA_LIBS)
else
EXTRA_LIBS := $(EXTRA_LIBS) $(PYTHONLDFLAGS)
endif

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"I ache, therefore I am. Or in my case - I am, therefore I ache."

- Marvin

William Kyngesburye wrote:

> Here is a link to discussion that may help explain why vdigit is not
> compiling correctly on a Mac--especially with OX X 10.5 (Leopard)
> that comes with Python 2.5--and a couple of solutions to fixing it.
>
> http://mail.python.org/pipermail/pythonmac-sig/2008-January/
> 019628.html

I've suggested distutils before. It just needs someone to write the
setup.py script.

I think that using distutils is likely to be inevitable. Too many
systems seem to have broken (or missing) python-config scripts. Also,
if you have multiple versions of Python, there's no guarantee that
python-config will use the correct one.

However, if we use distutils for building the extensions, we also need
to use it for the configure checks. IOW, configure needs to compile
and link a dummy Python extension.

Or just give up on having configure checks; the user will find out if
Python extensions can be built when we try to build them.

Somehow, I doubt that any of this is going to work with
cross-compilation.

--
Glynn Clements <glynn@gclements.plus.com>