New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #21824 (closed defect: invalid)

Opened 5 years ago

Last modified 5 years ago

python26 framework broken

Reported by: stromnov@… Owned by: blb@…
Priority: Normal Milestone:
Component: ports Version: 1.8.1
Keywords: Cc: mcalhoun@…
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

comment:1 Changed 5 years ago by stromnov@…

Problem detected while investigating #21444.

comment:2 Changed 5 years ago by ram@…

  • Cc blb@…, mcalhoun@… added

comment:3 Changed 5 years ago by macsforever2000@…

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

comment:4 Changed 5 years ago by blb@…

  • Status changed from new to closed
  • Resolution set to invalid

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 5 years ago by 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 5 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 follow-up: ↓ 8 Changed 5 years ago by 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 5 years ago by vince@…

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.