You are not logged in.

#1 2017-11-19 11:00:51

kalsan
Member
Registered: 2011-10-10
Posts: 119

[solved] Create an AUR for a python pip file

Hi there!

I'm creating a PKGBUILD for this nice software: https://github.com/miracle2k/onkyo-eiscp because I searched the aur for "onkyo" and found nothing, which was a frustrating experience. To fix this, I decided to follow https://wiki.archlinux.org/index.php/Py … guidelines to create an AUR package for onkyo-eiscp.

However, this is the first time I create a PKGBUILD for a pip package. The following works, but I'd like to ask if it's clean and nice:

# Maintainer: Sandro Kalbermatter <info.kalsan [ät-symbol] valaiscom.ch>

pkgname=python-onkyo-eiscp
pkgver=1.2.4
pkgrel=1
pkgdesc="Control Onkyo receivers over ethernet."
arch=('any')
url="https://github.com/miracle2k/onkyo-eiscp"
license=('MIT')
depends=('python')
provides=(onkyo)
makedepends=('python-pip')
options=()
source=()
md5sums=()

package() {
	PIP_CONFIG_FILE=/dev/null pip install --isolated --root="$pkgdir" --ignore-installed --no-deps onkyo-eiscp
}

I'm open to any feedback or discussion.

Best,
Kalsan

Last edited by kalsan (2018-02-07 09:50:01)

Offline

#2 2017-11-19 14:16:05

xsmile
Member
Registered: 2012-03-31
Posts: 31

Re: [solved] Create an AUR for a python pip file

Hi, you should still follow the general PKGBUILD guidelines from https://wiki.archlinux.org/index.php/PKGBUILD, they apply to Python packages too.
Look at other official Python packages for a reference, e.g. https://git.archlinux.org/svntogit/comm … thon-flask

The current PKGBUILD has following issues:
- empty source and md5sums arrays: a PKGBUILD is usually made for a specific version only and you should use the latest released version from the official repository
- the package function bypasses the package version and installs the latest available version
- Python dependencies 'docopt' and 'netifaces'  are missing, you can see them in setup.py at 'install_requires'
- MIT licenses need to be shipped with the package
- the provides array needs to match the package name and is not necessary here
- unused variables should be removed

A good practice is to create a universal PKGBUILD for both python3 and python2.

Offline

#3 2017-11-20 04:43:17

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [solved] Create an AUR for a python pip file

The Python Package Guidelines absolutely did not tell you to use pip. Pip is only meant to be used for .whl files as they do not have a setup.py, and even then the Python Package Guidelines instruct you to pass a *.whl file to pip rather than a package name to be downloaded from pypi.org

Look at the distutils example, and the setuptools example that builds on it.

Also as xsmile said the usual PKGBUILD guidelines still apply.

Last edited by eschwartz (2017-11-20 04:44:06)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2017-11-20 09:49:06

kalsan
Member
Registered: 2011-10-10
Posts: 119

Re: [solved] Create an AUR for a python pip file

Thanks for your replies! Learned a lot :-)

Here's an updated version:

# Maintainer: Sandro Kalbermatter <info.kalsan [ät-symbol] valaiscom.ch>

pkgname=('python-onkyo-eiscp-git' 'python2-onkyo-eiscp-git')
_pkgname=onkyo-eiscp
pkgver=1.2.4.r4.g1ebfb08
pkgrel=2
pkgdesc="Control Onkyo receivers over ethernet."
arch=('any')
url='https://github.com/miracle2k/onkyo-eiscp'
license=('custom:MIT')
makedepends=('git' 'python-setuptools' 'python2-setuptools')
options=()
source=('git://github.com/miracle2k/onkyo-eiscp.git')
md5sums=('SKIP')

pkgver() {
  cd $_pkgname
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build_python-onkyo-eiscp-git() {
  cd $_pkgname
  python setup.py build
}

build_python2-onkyo-eiscp-git() {
  cd $_pkgname
  python2 setup.py build
}

package_python-onkyo-eiscp-git() {
  depends=('python' 'python-docopt' 'python-netifaces')
  cd $_pkgname
  python setup.py install --root=${pkgdir} --optimize=1
  install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/python-onkyo-eiscp-git
}

package_python2-onkyo-eiscp-git() {
  depends=('python2' 'python2-docopt' 'python2-netifaces')
  cd $_pkgname
  python2 setup.py install --root=${pkgdir} --optimize=1
  install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/python2-onkyo-eiscp-git
}

Now, only one of the two packages can be installed since both provide /usr/bin/onkyo. Is that fine?

Last edited by kalsan (2017-11-20 10:04:59)

Offline

#5 2017-11-21 22:38:57

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [solved] Create an AUR for a python pip file

As a general rule, you would have the Python 3 version install the library and the tool in /usr/bin and have the Python 2 version install only the library.

If there is some particular reason why users might specifically want to run the tool with Python 2, then you could mv the python2 version from /usr/bin/onkyo to /usr/bin/onkyo2 but this only really applies when the Python 2 and Python 3 versions behave differently. Most commonly, when the tool is coupled with the Python ecosystem, e.g. pip2, tox2, ipython2, bpython2, flake8-python2, pylint2, virtualenv2, and things of that nature.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB