The Ports Collection supports parallel installation of
multiple Python versions. Ports should make sure to use a
correct python
interpreter, according to
the user-settable PYTHON_VERSION
variable.
Most prominently, this means replacing the path to
python
executable in scripts with the value
of PYTHON_CMD
variable.
Ports that install files under
PYTHON_SITELIBDIR
should use the
pyXY-
package name prefix, so their package
name embeds the version of Python they are installed
into.
USE_PYTHON | The port needs Python. Minimal required version
can be specified with values such as
2.6+ . Version ranges can also be
specified, by separating two version numbers with a
dash, e.g.: 2.6-2.7 |
USE_PYDISTUTILS | Use Python distutils for configuring, compiling
and installing. This is required when the port comes
with setup.py . This overrides
the do-build and
do-install targets and may
also override do-configure if
GNU_CONFIGURE is not
defined. |
PYTHON_PKGNAMEPREFIX | Used as a PKGNAMEPREFIX to
distinguish packages for different Python versions.
Example: py24- |
PYTHON_SITELIBDIR | Location of the site-packages tree, that contains
installation path of Python (usually
LOCALBASE ). The
PYTHON_SITELIBDIR variable can be
very useful when installing Python modules. |
PYTHONPREFIX_SITELIBDIR | The PREFIX-clean variant of PYTHON_SITELIBDIR.
Always use %%PYTHON_SITELIBDIR%% in
pkg-plist when possible. The
default value of
%%PYTHON_SITELIBDIR%% is
lib/python%%PYTHON_VERSION%%/site-packages |
PYTHON_CMD | Python interpreter command line, including version number. |
PYNUMERIC | Dependency line for numeric extension. |
PYNUMPY | Dependency line for the new numeric extension, numpy. (PYNUMERIC is deprecated by upstream vendor). |
PYXML | Dependency line for XML extension (not needed for Python 2.0 and higher as it is also in base distribution). |
USE_TWISTED | Add dependency on twistedCore. The list of
required components can be specified as a value of
this variable. Example:
web lore pair flow |
USE_ZOPE | Add dependency on Zope, a web application
platform. Change Python dependency to Python 2.7.
Set ZOPEBASEDIR containing a
directory with Zope installation. |
A complete list of available variables can be found in
/usr/ports/Mk/bsd.python.mk
.
Note that some of the Python applications claim to have
DESTDIR
support (which would be required for
staging) but it is broken (Mailman up to 2.1.16, for instance).
This can be worked around by recompiling the scripts. This can
be done, for example, in the post-build
target. Assuming the Python scripts are supposed to reside in
PYTHONPREFIX_SITELIBDIR
after
installation, the following solution can be applied:
This recompiles the sources with a path relative to the
stage directory, and prepends the value of
PREFIX
to the file name recorded in the
byte-compiled output file by -d
. The
-f
flag is required to force recompilation,
and the :S;${PREFIX}/;;
strips prefixes from
the value of the PYTHONPREFIX_SITELIBDIR
variable to make it relative to
PREFIX
.
This requires Python 2.7 or newer, and does not work with Python 2.6.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.