What should be in scripts shebangs for python2?

Marcus von Appen mva at freebsd.org
Wed Feb 19 16:01:26 UTC 2014


Lev Serebryakov <lev at freebsd.org>:

> Hello, Freebsd-ports.
>
>  My port uses some pythons scripts to configure (it is not pythonn-related
> by itself, only authors of this software use python scripts on build
> stage).
>
>  How should I patch these scripts to work? It looks like
> /usr/local/bin/python2 is installed by devel/python2 port, and
> USE_PYTHON_BUILD=yes doesn't depends on this port, but on python27, which

USE_PYTHON_BUILD=yes indicates that the port supports any python  
version, no matter,
if the user chooses python2.X or python3.x as the default for the system.

If your port is compatible with any python version and only uses  
python for configuring
some bits, but does *not* need python at run-time, you should patch  
the scripts to
use ${PYTHON_CMD},  via a ${REINPLACE_CMD} or the proper python_CMD=  
${PYTHON_CMD} command
for the shebang USES.

If your port is only compatible for a specific branch (either 2.x OR  
3.x), use the proper
major number for USE_PYTHON_BUILD, e.g. USE_PYTHON_BUILD=2. If the  
port is only compatible
with a specific release (e.g. 3.2), use USE_PYTHON_BUILD=X.Y. For  
those cases, you also can
rely on ${PYTHON_CMD}, which points to whatever is the most  
appropriate version.

In short:
* Use ${PYTHON_CMD} to replace the shebang lines or references of the  
python command
* Use the proper supported python version (yes for any, 2 or 3 for a  
branch, X.Y for a release)
   for USE_PYTHON_BUILD

> could be changed in future or by users's request, so I don't want to
> hardcode /usr/local/bin/python2.7, too...

Indeed, do not do this.

Cheers
Marcus



More information about the freebsd-ports mailing list