APKBUILD examples:Python: Difference between revisions
(Add depends and arch to the snippet) |
(Declare common dependencies inside _py() function) |
||
Line 26: | Line 26: | ||
... | ... | ||
arch="noarch" | arch="noarch" | ||
makedepends="python2-dev python3-dev" | makedepends="python2-dev python3-dev" | ||
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3" | subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3" | ||
Line 55: | Line 54: | ||
local python="$1" | local python="$1" | ||
pkgdesc="$pkgdesc (for $python)" | pkgdesc="$pkgdesc (for $python)" | ||
depends=" | depends="$python" | ||
install_if="$pkgname=$pkgver-r$pkgrel $python" | install_if="$pkgname=$pkgver-r$pkgrel $python" | ||
Line 65: | Line 64: | ||
* If the package contains some compiled code (native extensions), then add <tt>arch="all"</tt> into the <tt>_py()</tt> function (between pkgdesc and depends). | * If the package contains some compiled code (native extensions), then add <tt>arch="all"</tt> into the <tt>_py()</tt> function (between pkgdesc and depends). | ||
* If the package doesn’t have any dependencies, then omit <tt>depends=""</tt> in the <tt>_py2()</tt> and <tt>_py3()</tt> functions. | * If the package doesn’t have any dependencies, then omit <tt>depends=""</tt> in the <tt>_py2()</tt> and <tt>_py3()</tt> functions. | ||
* If both subpackages (''py2-'' and ''py3-'') have some common (runtime) dependencies, then add them to the <tt>depends</tt> inside the <tt>_py()</tt> function (e.g. <tt>depends="$python libgit2"</tt>). | |||
Source located at [http://pypi.python.org PyPi] | Source located at [http://pypi.python.org PyPi] |
Revision as of 21:24, 14 September 2016
A lot of Python packages use the setuptools or distutils framework. This mean that the build() and the package() section looks a bit different compared to an application which uses make.
pkgname="py3-foo" ... depends="python3" makedepends="python3-dev" ... build() { cd "$builddir" python3 setup.py build } package() { cd "$builddir" python3 setup.py install --prefix=/usr --root="$pkgdir" }
If Python package support both Python 2 and Python 3, then the Alpine package should provide both variants as py2- and py3- subpackages.
pkgname="py-foo" _pkgname="PyFoo" ... arch="noarch" makedepends="python2-dev python3-dev" subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3" ... build() { cd "$builddir" python2 setup.py build || return 1 python3 setup.py build || return 1 } package() { mkdir -p "$pkgdir" } _py2() { replaces="$pkgname" depends="py2-bar" _py python2 } _py3() { depends="py3-bar" _py python3 } _py() { local python="$1" pkgdesc="$pkgdesc (for $python)" depends="$python" install_if="$pkgname=$pkgver-r$pkgrel $python" cd "$builddir" $python setup.py install --prefix=/usr --root="$subpkgdir" }
- If the package contains some compiled code (native extensions), then add arch="all" into the _py() function (between pkgdesc and depends).
- If the package doesn’t have any dependencies, then omit depends="" in the _py2() and _py3() functions.
- If both subpackages (py2- and py3-) have some common (runtime) dependencies, then add them to the depends inside the _py() function (e.g. depends="$python libgit2").
Source located at PyPi
_pkgname=ShortName ... source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"