python install anomalies - tcl code to set paths

Darren Weber dweber at macports.org
Fri May 22 13:17:29 PDT 2009


On Fri, May 22, 2009 at 12:07 PM, Darren Weber <dweber at macports.org> wrote:

>
> The python 2.x installs contain can variations in paths for the include and
> lib installations (python2.6 deviates from the prior patterns set by 2.4 and
> 2.5).
>
> The following tcl code should work for python 2.4, 2.5, and 2.6 (as of May
> 2009).  The nice thing about this tcl code is that a port can use it to set
> a python dependency for configuration that will be specific to a python
> version.  This proc can be called from within variants to set or reset a
> python dependency easily (e.g., say you want more than one python variant to
> depend on a specific python install).
>
> proc setPython { pyVer } {
>     global pyVer python pyPort pyFrame pyLib pyBin pySite pyInc
>     #set pyVer       2.5
>     set python      python${pyVer}
>     set pyPort      [join [split $python .] ""]
>     set pyFrame
> ${prefix}/Library/Frameworks/Python.framework/Versions/${pyVer}
>     set pyLib       ${pyFrame}/Python
>     set pyBin       ${prefix}/bin/${python}
>     set pySite      ${prefix}/lib/${python}/site-packages
>     set pyInc       ${prefix}/include/${python}
>     if [string match "2.6" ${pyVer}] {
>         # python2.6 is a true framework installation; whereas installs for
> 2.4
>         # and 2.5 contain symlinks in the framework path to the prefix
> path; and
>         # those symlinks can break the file_map stage of port activation.
>         set pyBin       ${pyFrame}/bin/${python}
>         set pySite      ${pyFrame}/lib/${python}/site-packages
>         set pyInc       ${pyFrame}/include/${python}
>     }
> }
> # Init the python variables
> setPython 2.5
>
>
> Regards, Darren
>
>


Some revisions on the tcl code above are required because it seems that
${prefix} is not defined when the proc is defined in a global scope for a
Portfile (not clear why that is the case).


proc setPython { {major 2} {minor 6} } {
    global pyVer python pyPort pyBin pyLib pyInc pyFrame pySite
    set pyVer       ${major}.${minor}
    set python      python${pyVer}
    set pyPort      python${major}${minor}
    set pyFrame     Library/Frameworks/Python.framework/Versions/${pyVer}
    set pyLib       ${pyFrame}/Python
    set pyBin       bin/${python}
    set pyInc       include/${python}
    set pySite      lib/${python}/site-packages
    if [string match "2.6" ${pyVer}] {
        # python2.6 is a true framework installation; whereas installs for
2.4
        # and 2.5 contain symlinks in the framework path to the prefix path;
and
        # those symlinks can break the file_map stage of port activation.
        set pyBin   ${pyFrame}/bin/${python}
        set pyInc   ${pyFrame}/include/${python}
        set pySite  ${pyFrame}/lib/${python}/site-packages
    }
}
setPython

# Here's some dummy variants that provide a "switch" between python25 or
python26

variant py26 conflicts py25 {
    setPython 2 6
    depends_lib-append \
        port:${pyPort}
    # Note how the ${prefix} must be included here:
    configure.args-append \
        -DPYTHON_EXECUTABLE:FILEPATH=${prefix}/${pyBin} \
        -DPYTHON_INCLUDE_PATH:FILEPATH=${prefix}/${pyInc} \
        -DPYTHON_LIBRARY:FILEPATH=${prefix}/${pyLib}
}

variant py25 conflicts py26 {
    setPython 2 5
    depends_lib-append \
        port:${pyPort}
    configure.args-append \
        -DPYTHON_EXECUTABLE:FILEPATH=${prefix}/${pyBin} \
        -DPYTHON_INCLUDE_PATH:FILEPATH=${prefix}/${pyInc} \
        -DPYTHON_LIBRARY:FILEPATH=${prefix}/${pyLib}
}


Regards,
Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20090522/d0acd19c/attachment.html>


More information about the macports-dev mailing list