New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #24318 (new enhancement)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: mattiafrancescomoro@… Owned by: markd@…
Priority: Normal Milestone:
Component: guide Version:
Keywords: Cc: ryandesign@…
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

comment:1 Changed 3 years ago by jmr@…

  • Version 1.8.2 deleted
  • Type changed from request to enhancement

comment:2 follow-up: ↓ 3 Changed 3 years ago by ryandesign@…

  • Cc ryandesign@… added
  • Summary changed from assign variable value in variant to Document 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 3 years ago by ryandesign@…

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 3 years ago by mattiafrancescomoro@…

Thank you

Note: See TracTickets for help on using tickets.