Status: Defacto. If in doubt, check with the FreeBSD Python Team
This policy document is used:
FreeBSD currently supports Python (CPython) branches until they are end-of-life (EoL) as defined upstream.
Note: Upstream currently only provides bug fixes for the latest minor release (and Python 2.7 at the time of this writing). In order to reduce maintenance overheads and inconsistencies between ports, it is likely that the FreeBSD Python team will modify its branch support policy to only support branches that are also supported by upstream in the future.
Guideline: Prefix all ports unless Python version is entirely irrelevant.
py-PORTNAME)py-, named category/py-<PORTNAME>, unless there is a compelling case not to.py- prefix, A. BUT …Guideline: Match port names to upstream names exactly.
IMPORTANT
Check if a package is registered in PyPI (CHEESESHOP), even when using alternate code sources.
PORTNAME MUST exactly match the registered PyPI package name, including casing.setup.py:namePORTNAME MUST exactly match setup.py:name value.py, python, python-* or similar prefix or suffixMASTER_SITES or DISTFILES. Example: USE_GITHUB=yesGuideline: Prefix all ports unless Python version is entirely irrelevant.
PKGNAMEPREFIX, unless there is a compelling case not to.PKGNAMEPREFIX MUST be set to ${PYTHON_PKGNAMEPREFIX}Guideline: Always include python category unless use of Python is entirely irrelevant.
python as a secondary category, unless there is a compelling reason not to.CATEGORIES as needed to aid discovery by users.Guideline: Match upstream metadata as completely and closely as possible.
setup.py:descriptionGuideline: Use standard Python ecosystem infrastructure whenever possible.
MASTER_SITES=CHEESESHOP if a Python package is registered on PyPI, unless there is a compelling (temporary) case not to.Examples where temporarily using an alternate MASTER_SITES is warranted:
In these cases, issues or pull request SHOULD be created upstream to rectify the problem, and MASTER_SITES switched to CHEESESHOP when the change is released in a later version.
This ensures upstreams packaging and deployment pipeline is well tested and standardised (Python standards), as it is heavily relied upon (setuptools, autoplist, documentation, discoverability, etc).
Guideline: Python ports are declarative (“this supports x,y,z”, not imperative (“install/use x,y,z”). Guideline: Match upstream metadata as completely and closely as possible.
:<version-spec> as completely and accurately as possible, without being incorrect, given existing syntax constraints.:<version-spec> MUST match the Python versions declared supported by upstream exactly. If upstream declarations are incorrect or incomplete, fix them in the port and send the changes upstream.:version-spec.:<version-spec> empty (Note: transitionary guideline. This will eventually be a MUST)Guideline: Use all standard Python ecosystem infrastructure whenever possible.
Note: autoplist can be used in combination with PLIST_FILES, PLIST_DIRS and explicit entries in pkg-plist
concurrent MUST be set when any files (pathnames/filenames) installed by a package are NOT Python-version specific, like /usr/local/bin/script.concurrent SHOULD be set, even in cases where no such filenames are installed, as this may change in future versions.Guideline: Match upstream metadata as completely and closely as possible.
IMPORTANT:
Be careful when referencing dependencies only from requirements.txt files. Unless the setup.py parses those requirements.txt entries, only setup.py defined dependencies are canonical/actual.
Be careful, dependencies are often declared inconsistently, incompletely or in multiple places (Eg: requirements.txt, test_requirements, tox.ini)
setup.py:setup_requires for BUILD_DEPENDSsetup.py:install_requires for RUN_DEPENDSsetup.py:tests_require for TEST_DEPENDS==, <=, <== (pinned) dependencies to >= or removing maximum version <X.Y version specifiers.setup.py:extras_require or otherwise OPTIONAL dependencies, SHOULD be reflected in equivalent port OPTIONS.extras_require{ optional: ..., ...} list.Guideline: Ports should be testable unless they cannot be.
do-test target if the package includes tests. @(cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} ${PYDISTUTILS_SETUP} test)TEST_DEPENDS referring to the package tests_require dependencies.Guideline: Document downstream patches & changes that diverge from upstream.
Guideline: Upstream is a first priority.
install_requires, tests_require, setup_requiresextras_requirepython setup.py test command (for regression testing)LICENSE to repository and sdist${PYTHON_SITELIBDIR}), MUST use ${PYTHON_CMD} at build and installation time, not python, python2 or python3.${PYTHON_CMD} as shebang line. See: Mk/Uses/shebangfix.mk${PYTHON_CMD} for the build system/command invocation.python, python2 or python3.This allows ports to be built with different default versions of Python.
${PYTHON_CMD}.${PYTHON_PKGNAMESUFFIX} and the script SHOULD be suffixed, too. If the port is installed for the default Python version, the script SHOULD be symlinked to the original name.Example:
A port devel/foobar provides a script foofoo.py, which requires textproc/py-barbar at runtime
USES=python,runRUN_DEPENDSfoofoo.py MUST use ${PYTHON_CMD} as shebangPKGNAMESUFFIX=${PYTHON_PKGNAMESUFFIX}foofoo.py MUST be installed as foofoo-${PYTHON_PKGNAMESUFFIX}.pyfoofoo-${PYTHON_PKGNAMESUFFIX}.py SHOULD symlink to foofoo.py, if the Python version of the port matches the default Python version being specified by the system (DEFAULT_VERSION)Description: Upstream issue summary or commit short log Issue ID: URL to upstream Issue Changeset: URL to upstream Commit TODO: Comments on what needs to be done to remove local patch