PortGroup pythonPortGroup python allows for efficient porting of python-based open
source software.python PortGroup Specific KeywordsPortfiles using the python PortGroup allow for port authors to
set the following keywords in addition to the general Portfile
keywords.python.versionsDefines the python versions supported by this port. If the
port name starts with py-, then a subport will be defined for each
version in the list. For example, if a port named py-foo declares
python.versions 39 310, subports py39-foo and py310-foo will be
created, and will depend on python39 and python310, respectively.If the port name does not start with py-, it is interpreted
as an application written in python rather than a python module. In
this case, no subports are defined, and python.versions defaults to
the value of python.default_version, which must be set. For example,
if a port named mercurial sets python.default_version 310, then
python.versions will automatically be set to 310, and a dependency
on python310 will be added.Type: required for modules, optional for appsExample:python.versions 38 39 310python.default_versionFor modules (i.e., name starts with py-), this sets the
subport that will be installed if the user asks to install py-foo
rather than, e.g., py39-foo or py310-foo. If not explicitly set, a
reasonable default is chosen from the list in python.versions.For applications (i.e., name does not start with py-), this chooses
which version of python to use, and must be set. It can be changed
in variants if desired.Type: required for apps, optional for modulesExample:python.default_version 310python.pep517If set to yes, the port will be built as per
PEP 517.
Dependencies on appropriate front end tools will be added
automatically. This is supported when using Python 3.6 or later, though
the supporting module ports for 3.6 and other EOL Python versions may
be removed in future.If set to no, the port will be built with the
traditional distutils/setuptools setup.py commands.Type: optionalDefault (Python >= 3.7): yesDefault (Python <= 3.6): noExample:python.pep517 yespython.pep517_backendThis can be set to the name of the PEP 517 build back-end used by the port.
If python.pep517 is set to yes, dependencies on the
ports that provide the specified back-end will be added automatically.
Currently supported values are setuptools, flit,
poetry, hatch, maturin, and
meson. Clearing this option or setting it
to an unsupported value will result in no back-end dependencies being added.Type: optionalDefault: setuptoolsExample:python.pep517_backend flitpython.test_frameworkThis can be set to the name of testing framework used by the port.
If test.run is set to yes, dependencies on
the port that provides the specified framework will be added automatically.
Currently supported values are pytest, nose,
and unittest. Clearing this option or setting it to an
unsupported value will result in no framework dependency being added.Type: optionalDefault: pytestExample:python.test_framework nosepython.add_dependenciesIf set to yes, a dependency on a python interpreter will
be added as per python.version, and if python.pep517
is also set to yes, dependencies on appropriate front- and back-end
tools will also be added.If set to no, the portgroup will not add any dependencies,
and all required dependencies need to be declared in the Portfile.Type: optionalDefault: yesExample:python.add_dependencies nopython.link_binariesWhen yes (the default), tells the PortGroup to automatically
link any executable binaries installed in the bin/ directory within
the framework into
${prefix}/bin.Type: optionalExample:python.link_binaries nopython.link_binaries_suffixSuffix to add to the names of the links created in
${prefix}/bin when ${python.link_binaries}
is enabled. Can be cleared if no suffix is desired.Type: optionalDefault: -${python.branch}python.add_archflagsWhen yes (the default), the PortGroup will automatically
try to pass the correct arch-specific flags during build time
(via the standard CFLAGS, LDFLAGS, etc environment variables).
Set this to no and set up those variables in build.env manually
if the default does not work.Type: optionalExample:python.add_archflags nopython PortGroup Specific VariablesWhen the python PortGroup is declared within a Portfile, the
following variables are provided.python.versionThe python version in use in the current subport. This will be
one of the versions listed in python.versions.python.branchThe python version in use in the current subport, in normal
dotted notation. For example, if python.version is 310,
python.branch will be 3.10.python.prefixThe prefix in which the current python version is installed.
For framework builds, this is ${frameworks_dir}/Python.framework/Versions/${python.branch},
whereas for non-framework builds, it is the same as ${prefix}.python.binThe path to the MacPorts Python executable.python.libThe Python dynamic library path, i.e.,
${python.prefix}/Python (framework builds) or
${prefix}/lib/libpython2.7.dylib (python27).python.libdirThe path to python's lib directory, i.e.,
${python.prefix}/lib/python${python.branch}.python.includePath to the Python include directory.python.pkgdPath to the Python site-packages directory. (i.e.,
${python.prefix}/lib/python${python.branch}/site-packages).python PortGroup SugarPortfiles using PortGroup python do not need to define the
following variables:categoriesDefault: pythondepends_libDefault: port:python${python.version}use_configureDefault: nobuild.cmdDefault (python.pep517 no): ${python.bin} setup.py --no-user-cfgDefault (python.pep517 yes): ${python.bin} -m build --wheel --no-isolation --outdir ${workpath}build.targetDefault (python.pep517 no): buildDefault (python.pep517 yes): (empty)destroot.cmdDefault (python.pep517 no): ${python.bin} setup.py --no-user-cfgDefault (python.pep517 yes): ${python.bin} -m install --verbosedestroot.destdirDefault (python.pep517 no): --prefix=${python.prefix} --root=${destroot}Default (python.pep517 yes): --destdir ${destroot}pre-destrootDefault: creates directory
${destroot}${prefix}/share/doc/${subport}/examples.