Re: How do I depend on a python port without caring about flavor

From: Kubilay Kocak <koobs_at_FreeBSD.org>
Date: Fri, 20 Aug 2021 00:30:32 UTC
On 20/08/2021 7:07 am, Tatsuki Makino wrote:
> I also want to know the official way :)
> 
> I think the following ports are strange for python.
> 
> devel/llvm{-devel,12,11,10,90,80,70}
> databases/rrdtool
> graphics/opencv
> and astro/geographiclib (which are maintained by me :) )
> 
> They do not seem to be able to support non-default versions of python.
> So they are not transparent to FLAVOR, even if they are libraries.
> 
> I am thinking of the following changes for the next version of astro/geographiclib.
> 
> - sphinx-build:textproc/py-sphinx
> + ${PYTHON_PKGNAMEPREFIX}sphinx>=0:textproc/py-sphinx@${PY_FLAVOR}
> 
> If there is python:env in variable USES, it seems that variables such as PY_FLAVOR will be present.
> 
> ... So, I'm not sure, what should I do? :)
> 
> Regards.
> 
> 

Yep so:

  *_DEPENDS=${PYTHONPKGNAMEPREFIX}foo<vspec>:port/origin@${PY_FLAVOR}

Is the correct method, in which PY_FLAVOR gets derived from 
DEFAULT_VERSIONS, following the frameworks default versions over time, 
and honoring user default preferences and selection.

With USES=python:env to bring in the relevant variables for use.

One just needs to *also* make sure that for any scripts provided in the 
dependent port, they use ${PYTHON_CMD} for shebangs, etc, rather than 
env python env python2, env python3, who's targets change over time 
(depending on the default version)