TODO:py3 packages: Difference between revisions
(Created page with "Most of the Python packages in Alpine don’t support Python 3, although the packaged module supports it. TBD == List of packages == === main === {|class="wikitable" ! Pkg...") |
(Add more information) |
||
Line 1: | Line 1: | ||
Most of the Python packages in Alpine don’t support Python 3, although the packaged module supports it. | 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 (<tt>*.pyc</tt> 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: <tt>py2-</tt> and <tt>py3-</tt>. | |||
Base package <tt>py-</tt> is then a metapackage that pulls <tt>py2-</tt> subpackage if <tt>python2</tt> is installed or <tt>py3-</tt> subpackage if <tt>python3</tt> is installed. | |||
== How to do it == | |||
Before you start, prepare your environment for building packages ([[Creating_an_Alpine_package#Setup_your_system_and_account|Creating an Alpine package]]). | |||
# Take some package from the list below. Higher priority have packages with some compiled code (those have <tt>arch="all"</tt>). | |||
# Check if the Python package is compatible with Python 3. Tip: When you look into the package’s <tt>setup.py</tt> file, there are usually declared some classifiers like <tt>Programming Language :: Python :: 2</tt> and <tt>Programming Language :: Python :: 3</tt>. | |||
## If it’s '''not''' compatible with Python 3, then write it into the table below as a note. | |||
## If it’s compatible with Python 3, then continue with next steps. | |||
# Check if requirements in the package’s <tt>setup.py</tt> corresponds with the abuild’s <tt>depends</tt>. Some Python packages have additional dependencies depending on the Python version (for Alpine is relevant just 2.7 and 3.5). | |||
# Adjust the APKBUILD (see below). | |||
# Try to build it. | |||
# If everything is okay, commit the change (use commit message like ''<repo>/<pkgname>: add py2/py3 subpackages''). | |||
# Send pull request to https://github.com/alpinelinux/aports. | |||
If you have any questions, then don’t hesitate to ask on IRC [irc://irc.freenode.net/alpine-devel #alpine-devel]! | |||
=== APKBUILD === | |||
APKBUILD for a package supporting both Python 2 and Python 3 should look like this: | |||
<pre> | |||
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" | |||
} | |||
</pre> | |||
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). | |||
* …doesn’t have any dependencies, then omit <tt>depends=""</tt> in the <tt>_py2()</tt>/<tt>_py3()</tt> function. | |||
* …uses variable <tt>_builddir</tt>, then replace it with <tt>builddir</tt> (the former is older format). | |||
Notes: | |||
* _pkgname is the package’s real name on PyPI. | |||
== List of packages == | == List of packages == |
Revision as of 19:59, 31 August 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).
- Take some package from the list below. Higher priority have packages with some compiled code (those have arch="all").
- 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.
- If it’s not compatible with Python 3, then write it into the table below as a note.
- If it’s compatible with Python 3, then continue with next steps.
- 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).
- Adjust the APKBUILD (see below).
- Try to build it.
- If everything is okay, commit the change (use commit message like <repo>/<pkgname>: add py2/py3 subpackages).
- 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).
- …doesn’t have any dependencies, then omit depends="" in the _py2()/_py3() function.
- …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 packages
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-dateutil | |
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-virtualenv | |
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 | |
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 |