getting python version used by another port

Jeremy Lavergne jeremy at lavergne.gotdns.org
Mon Nov 28 09:01:20 PST 2011


> Mercurial supports (according to it's web page) 2.4 through 2.7
>
> In the Portfile there is the line
> python.default_version 27
> I didn't find that documented and could not figure out what exactly it
> means.
> Is it either
> - PortGroup python now knows that there is a dependency on exactly this
> version?
> - or PortGroup python knows somehow automagically that some version in the
> 2 series
>   is sufficient?

If someone or a portfile requests "py-NAME" without specifying the python
version in the prefix, e.g. py27-NAME, then it will become replaced_by the
"python.default_version" of the port by inserting it into the prefix. That
is, py-NAME is replaced_by py27-NAME.

This is meant to make maintaining the multiple versions of a port easier,
not necessarily making the dependency tree easier.

> However, you only implicitely answered the original question:
> So there is no canonical way to figure out the python version actually
> used by another port?

For now, the "best" way to figure out the version is specify it, letting
everything else get built for that version. By using default_version, you
can set which one gets used if a version of your port is not specified.

The default_version only works in that way.

If your port is installed py27-me then depend on py27-other, regardless if
that dependency has a default_version. The only time a versionless
dependency should be used is when the version truly doesn't matter,
however python modules ALWAYS matter since they becomes inaccessible to
different python versions based on their different installation locations.

As far as the "currently installed version" of python, that doesn't
actually exist. There can be zero, one or more, and the default one can
switch around on a user's whim. As soon as anything changes, your careful
version matching from build-time is ruined.

Similarly, you can set your default version to the default version of the
dependency but unless you control all the ports involved, you can't really
naively stick to just "the version installed"--you must pick one and let
the dependency tree do its thing.




More information about the macports-dev mailing list