Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#21824 closed defect (invalid)

python26 framework broken

Reported by: stromnov (Andrey Stromnov) Owned by: blb@…
Priority: Normal Milestone:
Component: ports Version: 1.8.1
Keywords: Cc: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Port: python26

Description

python2.6 framework broken in macports

man ld

-framework name[,suffix]
            This option tells the linker to search for `name.framework/name' the framework search path.  If the
            optional suffix is specified the framework is first searched for the name with the suffix and then
            without (e.g. look for `name.framework/name_suffix' first, if not there try `name.framework/name').

If we want to link with something like -framework Python, we need ${prefix}/Library/Framework/Python.framework/Python in ours paths

stromnov@stromnov:~$ ls -la /System/Library/Frameworks/Python.framework/Python 
lrwxr-xr-x  1 root  wheel  23 Oct  2 23:59 /System/Library/Frameworks/Python.framework/Python -> Versions/Current/Python
stromnov@stromnov:~$ ls -la /opt/local/Library/Frameworks/Python.framework/Python
ls: /opt/local/Library/Frameworks/Python.framework/Python: No such file or directory

cat test.c

#include <Python.h>

int main(const int argc, const char *argv[]) {
    Py_Initialize();
    Py_Finalize();
    return 0;
}

Trying to compile with default paths turned off (-Z):

stromnov@stromnov:~$ gcc -Z -F/opt/local/Library/Frameworks -I/opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -framework Python test.c
ld: framework not found Python
collect2: ld returned 1 exit status

Explicitly create proper framework link:

stromnov@stromnov:~$ (cd /opt/local/Library/Frameworks/Python.framework/; sudo ln -s Versions/2.6/Python Python)

Compiling:

stromnov@stromnov:~$ gcc -Z -F/opt/local/Library/Frameworks -I/opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -framework Python test.c
stromnov@stromnov:~$

Change History (8)

comment:1 Changed 15 years ago by stromnov (Andrey Stromnov)

Problem detected while investigating #21444.

comment:2 Changed 15 years ago by skymoo (Adam Mercer)

Cc: blb@… mcalhoun@… added

comment:3 Changed 15 years ago by mf2k (Frank Schima)

Cc: blb@… removed
Owner: changed from macports-tickets@… to blb@…

comment:4 Changed 15 years ago by blb@…

Resolution: invalid
Status: newclosed

Install python_select and use that to select which framework is to be used for linking like that.

Also, if you use

#include <Python/Python.h>

you won't need the -I argument as the framework stuff will get that for you.

comment:5 Changed 15 years ago by stromnov (Andrey Stromnov)

Hmm, so it completely wrong to link ports to frameworks?

I'm using macports python2.5, but need to build port, that links to python2.6 framework. It's impossible without using of python_select two times.

comment:6 Changed 15 years ago by blb@…

That's the thing, if python25 and python26 were to setup full framework stuff (Current and whatnot), then they'd conflict and you could have only one of them installed (or at least active) at a time.

You should be able to link to the library directly with -L${prefix}/lib -lpython2.6 or for the linking stage, using distutils:

$ /opt/local/bin/python2.6
...
>>> import distutils.sysconfig
>>> print distutils.sysconfig.get_config_var('LINKFORSHARED')
-u _PyMac_Error  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python

comment:7 Changed 15 years ago by stromnov (Andrey Stromnov)

When port is native MacOSX application that need explicit linkage with framework, we can link that application against fake framework, something like this (last lines in python_select sequence):

PortGroup python25
...
set fwkdir ${workdir}/Frameworks/Python.framework
cd ${workdir}
mkdir -p ${fwkdir}/Versions
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5 ${fwkdir}/Versions/Current
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5/Headers ${fwkdir}/Headers
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5/Resources ${fwkdir}/Resources
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5/Python ${fwkdir}/Python
...
CFLAGS+=-F${fwkdir} -framework Python
...

Every port, that installed as framework, can store (in registry?) some meta information for creating fake framework at build time.

comment:8 in reply to:  7 Changed 15 years ago by Veence (Vincent)

Replying to stromnov@…:

When port is native MacOSX application that need explicit linkage with framework, we can link that application against fake framework, something like this (last lines in python_select sequence):

PortGroup python25
...
set fwkdir ${workdir}/Frameworks/Python.framework
cd ${workdir}
mkdir -p ${fwkdir}/Versions
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5 ${fwkdir}/Versions/Current
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5/Headers ${fwkdir}/Headers
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5/Resources ${fwkdir}/Resources
ln -s ${prefix}/Library/Frameworks/Python.framework/Versions/2.5/Python ${fwkdir}/Python
...
CFLAGS+=-F${fwkdir} -framework Python
...

Every port, that installed as framework, can store (in registry?) some meta information for creating fake framework at build time.

That's precisely what I do for an upcoming port. See also #21614.

Note: See TracTickets for help on using tickets.