TODO:py3 packages: Difference between revisions

From Alpine Linux
(py-dateutil ported)
(py-virtualenv not needed for py3)
Line 481: Line 481:
|-
|-
| py-urwid-examples
| py-urwid-examples
|
|-
| py-virtualenv
|
|
|-
|-

Revision as of 16:37, 18 September 2016

Most of the Python packages in Alpine don’t support Python 3, although the packaged module supports it. We would like to support Python 3 wherever it’s possible and would be happy if you can help us with it!

Explanation

Python 2 and 3 installs modules into different directories, the compiled bytecode (*.pyc files) is different and native extensions are linked against different Python shared library. Therefore to support both versions, we need to build two packages. Since the source is the same, we do it as one APKBUILD that provides two subpackages: py2- and py3-. Base package py- is then a metapackage that pulls py2- subpackage if python2 is installed or py3- subpackage if python3 is installed.

How to do it

Before you start, prepare your environment for building packages (Creating an Alpine package).

  1. Take some package from the list below. Higher priority have packages with some compiled code (those have arch="all").
  2. Check if the Python package is compatible with Python 3. Tip: When you look into the package’s setup.py file, there are usually declared some classifiers like Programming Language :: Python :: 2 and Programming Language :: Python :: 3.
    1. If it’s not compatible with Python 3, then write it into the table below as a note.
    2. If it’s compatible with Python 3, then continue with next steps.
  3. Check if requirements in the package’s setup.py corresponds with the abuild’s depends. Some Python packages have additional dependencies depending on the Python version (for Alpine is relevant just 2.7 and 3.5).
  4. Adjust the APKBUILD (see below).
  5. Try to build it.
  6. If everything is okay, commit the change (use commit message like <repo>/<pkgname>: add py2/py3 subpackages).
  7. Send pull request to https://github.com/alpinelinux/aports.

If you have any questions, then don’t hesitate to ask on IRC #alpine-devel!

APKBUILD

APKBUILD for a package supporting both Python 2 and Python 3 should look like this:

pkgname=py-foo
_pkgname=PyFoo
pkgver=1.0.0
pkgrel=1
pkgdesc="A package description"
url="https://github.com/example/foo"
arch="noarch"
license="MIT"
depends=""
makedepends="python2-dev python3-dev py-setuptools"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

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="$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").
  • If the package uses variable _builddir, then replace it with builddir (the former is older format).

Notes:

  • _pkgname is the package’s real name on PyPI.


List of abuilds without Python 3 support

main

Pkgname Notes
py-alabaster
py-avahi
py-babel
py-backports.ssl_match_hostname
py-backports_abc
py-bluez
py-boto
py-cairo
py-certifi
py-cliapp
py-configshell
py-country
py-curl
py-dbus
py-django
py-django-contact-form
py-django-djblets
py-django-extra-views
py-django-haystack
py-django-oscar
py-django-pipeline
py-django-registation
py-django-simple-captcha
py-django-sorl-thumbnail
py-django-tables2
py-django-treebeard
py-django-widget-tweaks
py-ediarpc
py-egenix-mx-base
py-exifread
py-eyed3
py-factory-boy
py-farstream0.1
py-feedparser
py-flask
py-flask-assets
py-flask-oauthlib
py-flask-script
py-flask-wtf
py-flup
py-funcsigs
py-fuse
py-gamin
py-gdbm
py-genshi
py-gflags
py-gnome
py-gnome-bonobo
py-gnome-gconf
py-gnome-gnomevfs
py-gnome-libgnome
py-gnutls
py-gobject
py-gobject3
py-google-api-python-client
py-gst0.10
py-gtk
py-gtk-demo
py-gunicorn
py-gv
py-hgtools
py-hiredis
py-hoedown
py-httplib2
py-icu
py-imagesize
py-imaging
py-irc
py-irc-scripts
py-itsdangerous
py-jwt
py-larch
py-ldb
py-libmount
py-libproxy
py-libxml2
py-libxslt
py-lockfile
py-mako
py-mccabe
py-meld3
py-mock
py-munkres
py-musicbrainzngs
py-mutagen
py-mysqldb
py-newt
py-nose
py-oauth2
py-oauth2client
py-oauthlib
py-parsing
py-pbr
py-pep8
py-pgen
py-phonenumbers
py-pillow
py-psycopg2
py-purl
py-pygments
py-pylast
py-redis
py-roman
py-rrd
py-rsa
py-samba
py-simplejson
py-simpleparse
py-singledispatch
py-snowballstemmer
py-sphinx
py-sphinx_rtd_theme
py-subversion
py-talloc
py-tdb
py-templayer
py-tevent
py-tornado
py-tracing
py-ttystatus
py-twisted
py-twitter
py-tz
py-unbound
py-unidecode
py-uritemplate
py-urlgrabber
py-urlnorm
py-urwid
py-urwid-examples
py-vobject
py-webassets
py-werkzeug
py-wtforms
py-xml
py-zope-interface

community

Pkgname Notes
py-acme
py-argh
py-configargparse
py-crcmod
py-dialog
py-distutils-extra
py-django-appconf
py-django-compressor
py-django1.5 unmaintained version
py-ethtool
py-gammu
py-gpiozero
py-graphviz
py-gtkglext
py-impacket
py-ipaddr
py-jellyfish
py-libplist
py-libteam
py-livereload
py-lz4
py-mechanize
py-ndg_httpsclient
py-numpy
py-opencl
py-opengl-accelerate
py-parsedatetime
py-pathtools
py-pysqlite
py-rencode
py-rfc3339
py-rpigpio
py-rpm
py-rtslib
py-sensehat
py-skywriter-hat
py-slowaes
py-sphinx-autobuild
py-tempita
py-udev
py-watchdog
py-zope-component
py-zope-event
py2-impacket
py2-pysqlite
py2-tempita