Opened 11 years ago

Last modified 2 years ago

#40734 new enhancement

python PortGroup: add variants instead of subports with python.versions in apps

Reported by: mojca (Mojca Miklavec) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version:
Keywords: portgroup Cc: cooljeanius (Eric Gallager), pixilla (Bradley Giesbrecht), petrrr
Port:

Description

This is related to a request in #38535 to support multiple python versions in an app. I checked other ports what they do and here's an example from gnuradio where a lot of code could be greatly simplified with an appropriate option in the PortGroup, in particular the last few lines (which seem to be slightly wrong anyway):

foreach s ${pythons_suffixes} {
    set p python${s}
    set v [join [split ${s} ""] "."]
    set i [lsearch -exact ${pythons_ports} ${p}]
    set c [lreplace ${pythons_ports} ${i} ${i}]
    eval [subst {
        variant ${p} description "Build GNU Radio using Python ${v}" \
            conflicts ${c} {

            set chosen_python_suffix ${s}

            # specify the Python dependencies

            depends_lib-append \
                port:${p} \
                port:py${s}-numpy \
                port:py${s}-cheetah

            depends_run-append \
                port:py${s}-opengl \
                port:py${s}-scipy

            # specify the Python version to use

            configure.args-append \
                -DPYTHON_EXECUTABLE=${prefix}/bin/python${v} \
                -DPYTHON_INCLUDE_DIR=${prefix}/Library/Frameworks/Python.framework/Versions/${v}/Headers \
                -DPYTHON_LIBRARY=${prefix}/Library/Frameworks/Python.framework/Versions/${v}/Python \
...

My request would be to add functionality to the existing python PortGroup which would create a bunch of variants for apps instead of subports (like for python modules).

My request would be to treat

python.versions "25 26 27"

in an app equivalent to

variant python25 conflicts python26 python27 description {Use Python 2.5} {
   ...
}
variant python26 conflicts python25 python27 description {Use Python 2.6} {
   ...
}
variant python27 conflicts python25 python26 description {Use Python 2.7} {
   ...
}
if {![variant_isset python25] && ![variant_isset python26] && ![variant_isset python27]} {
    default_variants +python${python.default_version}
}

while still allowing easy settings like

depends_lib-append  port:py${python.version}-wxpython-3.0

or is that impossible?

In addition to this it would be nice if the PortGroup could work flawlessly with C as well, so that a setting similar to

python.use_python_compiler no

would only set variables like ${python.version}, ${python.bin}, ... and likewise create variants (if more than one python version is supported) rather than redefining all compile/make steps which render the PortGroup useless in contexts other than proper Python code.

Attachments (1)

patch-PortGroup-python-1.0.diff (1.4 KB) - added by pixilla (Bradley Giesbrecht) 10 years ago.
Add python variants

Download all attachments as: .zip

Change History (8)

comment:1 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:2 Changed 11 years ago by petrrr

Cc: Peter.Danecek@… added

Cc Me!

comment:3 Changed 11 years ago by jul_bsd@…

Need to fix: Pymol (#38534)

comment:4 Changed 10 years ago by pixilla (Bradley Giesbrecht)

Cc: pixilla@… added

Cc Me!

Changed 10 years ago by pixilla (Bradley Giesbrecht)

Add python variants

comment:5 Changed 10 years ago by petrrr

Cc: petr@… added

Cc Me!

comment:6 Changed 10 years ago by petrrr

Cc: Peter.Danecek@… removed

comment:7 Changed 2 years ago by mascguy (Christopher Nielsen)

Keywords: portgroup added

Add keyword portgroup, to pg-related tickets

Note: See TracTickets for help on using tickets.