1.\" $OpenBSD: python-module.5,v 1.3 2021/07/27 13:21:50 espie Exp $ 2.\" 3.\" Copyright (c) 2008 Marc Espie 4.\" 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd $Mdocdate: July 27 2021 $ 28.Dt PYTHON-MODULE 5 29.Os 30.Sh NAME 31.Nm python-module 32.Nd lang/python port module 33.Sh DESCRIPTION 34This manual page documents the behavior of setting 35.Li MODULES=lang/python 36in the 37.Xr ports 7 38tree. 39.Pp 40By default, the module sets 41.Ev MODPY_VERSION 42to the appropriate python version 43.Po 44depending on the existence/presence of a 45.Sq python3 46.Ev FLAVOR 47.Pc . 48but 49.Ev MODPY_VERSION 50may be set manually to ${MODPY_DEFAULT_VERSION_2} 51for legacy ports. 52.Pp 53The module then sets 54.Ev MODPY_BIN , 55.Ev MODPY_INCDIR , 56.Ev MODPY_LIBDIR , 57.Ev MODPY_SITEPKG , 58.Ev MODPY_SETUP , 59.Ev MODPY_TEST_DIR , 60.Ev MODPY_TEST_LOCALE , 61.Ev MODPY_WANTLIB , 62.Ev MODPY_LIB_DEPENDS , 63.Ev MODPY_RUN_DEPENDS , 64.Ev MODPY_TEST_DEPENDS , 65.Ev MODPY_BUILD_DEPENDS , 66and 67.Ev MODPY_ADJ_FILES 68accordingly. 69.Pp 70The module also appends to 71.Bl -bullet 72.It 73.Ev RUN_DEPENDS 74unless 75.Ev MODPY_RUNDEP 76is set to No, 77.It 78.Ev BUILD_DEPENDS 79unless 80.Ev MODPY_BUILDDEP 81is set to No or 82.Ev NO_BUILD 83is set to Yes, 84.It 85.Ev TEST_DEPENDS 86if 87.Ev MODPY_PYTEST 88is set to Yes 89unless 90.Ev MODPY_TESTDEP 91is set to No. 92.El 93.Pp 94It also appends 95.Ev MODPY_TEST_LOCALE 96to 97.Ev TEST_ENV 98and changes to the directory specified in 99.Ev MODPY_TEST_DIR 100.Po 101by default ${WRKSRC} 102.Pc 103before running tests. 104.Pp 105Ports which use the setuptools module should set 106.Ev MODPY_SETUPTOOLS 107to Yes. 108.Pp 109Ports which use the pytest module should set 110.Ev MODPY_PYTEST 111to Yes. 112Arguments can be passed to pytest during 113.Cm test 114with 115.Ev MODPY_PYTEST_ARGS . 116.Pp 117All ports that generate egg-info files should set 118.Ev MODPY_EGG_VERSION 119to the version string used by the 120.Fn setup 121function in the port's 122.Pa setup.py . 123Arguments can be passed to setup.py during 124.Cm configure 125with 126.Ev MODPY_SETUP_ARGS . 127Extra arguments to the build and install commands can be passed via 128.Ev MODPY_DISTUTILS_BUILDARGS 129and 130.Ev MODPY_DISTUTILS_INSTALLARGS . 131.Pp 132If any files have a python shebang line where the interpreter should be 133${MODPY_BIN}, list them in 134.Ev MODPY_ADJ_FILES . 135These filenames can be relative to ${WRKSRC} and will be modified 136at the end of 137.Cm pre-configure . 138.Pp 139This module also affects 140.Ev CATEGORIES , 141.Ev MAKE_ENV , 142.Ev CONFIGURE_ENV , 143and 144.Ev SUBST_VARS , 145and it may affect the 146.Cm test 147target. 148.Pp 149If 150.Ev MODPY_PI 151is set to 152.Sq Yes 153the module will provide a default for 154.Ev HOMEPAGE 155and set 156.Ev MASTER_SITES 157.Po 158the subdirectory can be overridden with 159.Ev MODPY_PI_DIR 160.Pc . 161.Ss Packing-list generation 162Python 2.x places .pyc files in the same directory as the associated .py file. 163Python 3.x places these in a separate __pycache__ directory and uses an 164additional suffix. 165In some cases, an ABI tag is also used for names of compiled extensions. 166The python module defines variables to allow a single 167.Pa PLIST 168to be 169used for both versions: 170generate or update the 171.Pa PLIST 172using the python3 173.Ev FLAVOR , 174then edit it to prefix any lines creating 175.Ev MODPY_PYCACHE 176directories with 177.Ev MODPY_COMMENT . 178As python2 and python3 packages should permit being installed together, 179it may be necessary to suffix names of common binaries or directories, 180or split common files into a subpackage. 181If updating the PLIST without using the python3 flavor, 182take care not to remove ${MODPY_PYCACHE}, ${MODPY_PYC_MAGIC_TAG}, or 183${MODPY_ABI_TAG} variables from the PLIST. 184.Sh SEE ALSO 185.Xr port-modules 5 186