Opened 15 years ago

Last modified 7 years ago

#24318 new enhancement

Document how to get the result of a program from within a Portfile

Reported by: mattiafrancescomoro@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: guide Version:
Keywords: Cc: ryandesign (Ryan Carsten Schmidt)
Port:

Description

Please add a guide wich explain how i can add in a variant box a code execution ie:

variant python description {Builds port with python support} {
    pythonincdir=`python-config --includes | sed -e 's/-I//' | awk '{print \$1}'`
    
    configure.args-delete   --disable-python`
    configure.args-append   --enable-python  \
                            --with-python-incdir=pythonincdir \
							--with-python-libdir="${prefix}/lib"

}

Thank you!

Change History (6)

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

Type: requestenhancement
Version: 1.8.2

comment:2 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added
Summary: assign variable value in variantDocument how to get the result of a program from within a Portfile

You're looking for the exec procedure. Also, you have to wait to call it until pre-configure time; any time before that, python is not guaranteed to have been installed yet.

Also, you must revise this to call a specific python-config that was provided by a specific MacPorts python port (e.g. python26, python25, etc.), and declare a dependency on it. It's not ok to just call "python-config" and have it be "whatever" version of python the user has. So, the following would be acceptable:

variant python26 description {Include Python 2.6 support} {
    depends_lib-append      port:python26
    configure.args-delete   --disable-python
    configure.args-append   --enable-python \
                            --with-python-incdir=[exec ${prefix}/bin/python2.6-config --includes | sed -e 's/-I//' | awk '{print \$1}'] \
                            --with-python-libdir=${prefix}/lib
}

comment:3 in reply to:  2 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Oh, I forgot the pre-configure bit. I'll try again:

variant python26 description {Include Python 2.6 support} {
    depends_lib-append          port:python26
    pre-configure {
        configure.args-delete   --disable-python
        configure.args-append   --enable-python \
                                --with-python-incdir=[exec ${prefix}/bin/python2.6-config --includes | sed -e 's/-I//' | awk '{print \$1}'] \
                                --with-python-libdir=${prefix}/lib
    }
}

comment:4 Changed 14 years ago by mattiafrancescomoro@…

Thank you

comment:5 Changed 10 years ago by mf2k (Frank Schima)

Owner: changed from markd@… to macports-tickets@…

markd has retired. See #44782.

comment:6 Changed 7 years ago by raimue (Rainer Müller)

In my opinion, exec should only be used under special circumstances. It is probably not a good idea not to expose it that widely in the guide.

Note: See TracTickets for help on using tickets.