Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#19559 closed enhancement (invalid)

variant variables not carried through to post-destroot

Reported by: dweber@… Owned by: macports-tickets@…
Priority: Low Milestone:
Component: base Version: 1.7.1
Keywords: variant variables Cc:
Port:

Description

Can we make variant variables carry through into the post-destroot stage definition within the variant (such that variables defined within the variant over-ride any global variables)?

For example:

variant python26 {
    set pyver    2.6
    set python   python${pyver}
    set pyport   [join [lrange [split ${python} .] 0 1] ""]
    set pyframe  ${prefix}/Library/Frameworks/Python.framework/Versions/${pyver}

    depends_lib-append port:${pyport}

    post-destroot {
        set pyPackage ${destroot}${pyframe}/lib/${python}/site-packages/THISPACKAGE
    }
}

In this mock-up example, the depends-lib will get the ${pyport} but anything within the post-destroot will not see any of the python variables defined in the variant. All of those variables have to be either global or set within the post-destroot clause (within the variant).

Change History (6)

comment:1 Changed 15 years ago by blb@…

Milestone: MacPorts 1.8.0MacPorts Future

I think this is a Tcl issue, you can use

global pyver python pyport pyframe

at the beginning of the variant section; otherwise, the only way to deal with it would be to automatically make such things global in base, though I don't know if that's feasible nor how difficult that would be.

comment:2 Changed 15 years ago by jmroot (Joshua Root)

Isn't this what option is for?

comment:3 Changed 15 years ago by dweber@…

Can't find TFM on 'option'. Is it a macports tcl extension? The only thing I found was the option database for tk, probably not what your talking about.

Here's a concrete example of what I'm doing in vtk-devel - any tips on how to tidy this up would be great! The idea is to provide two variants for python wrapping, one for py25 and another for py26 (and they must conflict, but only because of configure and build issues, not installation issues).

variant py25 conflicts py26 requires shared description {python 2.5 wrapper} {
    set pyver        2.5
    set python       python${pyver}
    set pyport       [join [lrange [split ${python} .] 0 1] ""]
    set pyframe      ${prefix}/Library/Frameworks/Python.framework/Versions/${pyver}
    depends_lib-append \
        port:${pyport}
    configure.args-delete \
        -DVTK_WRAP_PYTHON:BOOL=OFF \
    configure.args-append \
        -DVTK_WRAP_PYTHON:BOOL=ON \
        -DVTK_NO_PYTHON_THREADS:BOOL=OFF \
        -DPYTHON_INCLUDE_PATH:FILEPATH=${prefix}/include/${python} \
        -DPYTHON_LIBRARY:FILEPATH=${prefix}/lib/lib${python}.dylib \
        -DPYTHON_DEBUG_LIBRARY:FILEPATH=${prefix}/lib/lib${python}.dylib \
        -DPYTHON_EXECUTABLE:FILEPATH=${prefix}/bin/${python} \
        -DVTK_PYTHON_SETUP_ARGS:STRING='--prefix=${prefix} --root=${destroot}'
        # The VTK_PYTHON_SETUP_ARGS *MUST* be in single quotes 
}

variant py26 conflicts py25 requires shared description {python 2.6 wrapper} {
    set pyver        2.6
    set python       python${pyver}
    set pyport       [join [lrange [split ${python} .] 0 1] ""]
    set pyframe      ${prefix}/Library/Frameworks/Python.framework/Versions/${pyver}
    depends_lib-append \
        port:${pyport}
    configure.args-delete \
        -DVTK_WRAP_PYTHON:BOOL=OFF 
    configure.args-append \
        -DVTK_WRAP_PYTHON:BOOL=ON \
        -DVTK_NO_PYTHON_THREADS:BOOL=OFF \
        -DPYTHON_INCLUDE_PATH:FILEPATH=${prefix}/Library/Frameworks/Python.framework/Headers \
        -DPYTHON_LIBRARY:FILEPATH=${prefix}/lib/lib${python}.dylib \
        -DPYTHON_DEBUG_LIBRARY:FILEPATH=${prefix}/lib/lib${python}.dylib \
        -DPYTHON_EXECUTABLE:FILEPATH=${prefix}/bin/${python} \
        -DVTK_PYTHON_SETUP_ARGS:STRING='--prefix=${pyframe} --root=${destroot}'
        # For 2.6, it needs to be installed into ${pyframe}/lib/${python}/site-packages
        # The VTK_PYTHON_SETUP_ARGS *MUST* be in single quotes 
    post-destroot {
        # Redefine all the python variables in this clause (they are not carried
        # through from the definitions above in the variant).
        set pyver        2.6
        set python       python${pyver}
        set pyport       [join [lrange [split ${python} .] 0 1] ""]
        set pyframe      ${prefix}/Library/Frameworks/Python.framework/Versions/${pyver}
        # Reset the name of the vtkpython binary
        move ${destroot}${prefix}/bin/vtkpython ${destroot}${prefix}/bin/vtk-${branch}-${pyport}
        # Is it possible to change the python site-package name and have it all work OK?
        # from:  /opt/local/lib/python2.6/site-packages/vtk
        # to:    /opt/local/lib/python2.6/site-packages/vtk-5.4 
        # Reset the RPATH for all the python .so files
        set buildBinPath ${build.dir}/bin
        set vtkLibPath ${prefix}/lib/${distname}
        set vtkPythonPackage ${destroot}${pyframe}/lib/${python}/site-packages/vtk
        foreach f [glob ${vtkPythonPackage}/*.so] {
            foreach dep [exec otool -L ${f}] {
                if [string match "*libvtk*.dylib" ${dep}] {
                    set newdep [strsed ${dep} #${buildBinPath}#${vtkLibPath}#]
                    system "install_name_tool -change ${dep} ${newdep} ${f}"
                }
            }
        }
    }
}


comment:4 Changed 15 years ago by raimue (Rainer Müller)

Type: requestenhancement

comment:5 Changed 15 years ago by jmroot (Joshua Root)

Resolution: invalid
Status: newclosed

Variant bodies are run as procedures. Just using 'set' will create a local variable. Use 'global', or the 'options' infrastructure:

variant foo {
    options myoption1 myoption1
    myoption1 bar
    myoption2 baz
    post-destroot {
        ui_msg "my options are $myoption1 and $myoption2"
    }
}

comment:6 Changed 14 years ago by jmroot (Joshua Root)

Milestone: MacPorts Future
Note: See TracTickets for help on using tickets.