Can we create proc{} Portfile?

Ryan Schmidt ryandesign at macports.org
Tue May 12 22:13:13 PDT 2009


On May 12, 2009, at 18:39, Darren Weber wrote:

> On Tue, May 12, 2009 at 3:52 PM, Darren Weber wrote:
>
>> Can we create a proc within a Portfile?

Yes, you can. You can see the not-quite-finished minivmac v3 portfile  
in my users directory in the repository for an example port that  
defines a few procedures of its own (e.g. to mount a disk image).

http://trac.macports.org/browser/users/ryandesign/minivmac/Portfile#L255


>> I'm currently using this in several places for the vtk-devel port  
>> (to set different python version variables):
>>
>>     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}
>>
>>
>> Can we create a global proc in a Portfile?  Something like this:
>>
>> proc setPython { major minor } {
>>     global pyver python pyport pyframe
>>     set pyver        ${major}.${minor}
>>     set python       python${pyver}
>>     set pyport       python${major}${minor}
>>     set pyframe      ${prefix}/Library/Frameworks/Python.framework/ 
>> Versions/${pyver}
>> }
>
>
> I've tried something that is not working (it doesn't crash, but  
> it's not effective), i.e.:
>
>
> # Set some default python variables
> set pyver        2.6
> set python       python${pyver}
> set pyport       [join [lrange [split ${python} .] 0 1] ""]
> set pyframe      Library/Frameworks/Python.framework/Versions/${pyver}
> global pyver python pyport pyframe
>
> # A function to reset the python variables
> proc setPython { major minor } {
>     global pyver python pyport pyframe
>     set pyver        ${major}.${minor}
>     set python       python${pyver}
>     set pyport       python${major}${minor}
>     set pyframe      Library/Frameworks/Python.framework/Versions/$ 
> {pyver}
> }
>
> variant py25 conflicts py26 requires shared description {python 2.5  
> wrapper} {
>     pre-configure {
>         setPython 2 5
>     }

Here you are calling your setPython proc at pre-configure time.

>     #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}

Here you are expecting the pyport variable to have been defined way  
before pre-configure time.

As long as the proc only sets variables, you can call it directly,  
outside of the pre-configure phase, and that might work. (I haven't  
tried, or completely evaluated the rest of your code.)

>     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
>     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.5
>         #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 (create a symlink  
> to the
>         # version specific installation, in case other apps look  
> for vtkpython)
>         move ${destroot}${prefix}/bin/vtkpython ${destroot}$ 
> {prefix}/bin/vtk-${branch}-${pyport}
>         ln -f -s ${destroot}${prefix}/bin/vtk-${branch}-${pyport} $ 
> {destroot}${prefix}/bin/vtkpython
>         # 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}${prefix}/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}"
>                 }
>             }
>         }
>     }
> }
>
>
> What is wrong here?  Does it require global declarations in the  
> variant?

I'm not sure.




More information about the macports-dev mailing list