Python package policies: Difference between revisions

From Alpine Linux
(Initial page creation)
 
m (Add note about watching build logs)
Line 12: Line 12:
* Update the version number, pkgdesc, url, and license
* Update the version number, pkgdesc, url, and license
* Build it and address any issues that come up
* Build it and address any issues that come up
* Read the build output and be vigilant for issues listed in the following sections - the build may complete successfully even though these issues are present


<pre># Maintainer: Joe Bloe <joe@example.org>
<pre># Maintainer: Joe Bloe <joe@example.org>

Revision as of 17:36, 6 March 2019

Python packages in Alpine Linux should follow a general set of standards for their APKBUILDs.

This material is work-in-progress ...

Pending consensus on this approach
(Last edited by Ddevault on 6 Mar 2019.)

General Template

This APKBUILD template includes a split py2-/py3- package and a py- metapackage, and downloads the source package from PyPI. Be sure to make the following changes:

  • Update maintainer to yourself
  • Set the pkgname to the Alpine package name (prefixed with "py-")
  • Set _pkgname to the name of the package on PyPI
  • Update the version number, pkgdesc, url, and license
  • Build it and address any issues that come up
  • Read the build output and be vigilant for issues listed in the following sections - the build may complete successfully even though these issues are present
# Maintainer: Joe Bloe <joe@example.org>
pkgname=py-alpine-name
_pkgname=pypi-name
pkgver=1.2.3
pkgrel=0
pkgdesc="Example Python package"
url=http://example.org/
arch=noarch
license=MIT
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
makedepends="py-setuptools"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
builddir=$srcdir/$_pkgname-$pkgver

prepare() {
	cp -r "$builddir" "$builddir"-py3
}

build() {
	cd "$builddir"
	python2 setup.py build
	cd "$builddir"-py3
	python3 setup.py build
}

check() {
	cd "$builddir"
	python2 setup.py test
	cd "$builddir"-py3
	python3 setup.py test
}

package() {
	mkdir -p "$pkgdir"
}

_py2() {
	cd "$builddir"
	_py python2
}

_py3() {
	cd "$builddir"-py3
	_py python3
}

_py() {
	python="$1"
	pkgdesc="$pkgdesc (for $python)"
	depends="$depends $python"
	install_if="$pkgname=$pkgver-r$pkgrel $python"
	$python setup.py install --prefix=/usr --root="$subpkgdir"
}

Common issues

No source package available (only the wheel is on PyPI)

Seek out the upstream source (e.g. GitHub) and swap out the URL.

No tests in PyPI package "(0 tests run)"

Seek out the upstream source (e.g. GitHub) and swap out the URL.

setup.py test downloads a lot of dependencies

Watch out for this and be sure to add any of these packages to checkdepends so that setuptools isn't downloading and testing against packages/versions which aren't in aports.

No python2 support

In this case, rename the package to "py3-example" and remove the "py-" metapackage and "py2-" subpackage.

Different dependencies between py2 and py3 versions

Add depends="..." to the respective _py2 or _py3 subpackage functions.