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...") |
m (RfD: This page is now useless as Alpine exclusively uses python3 now.) |
||
(30 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Delete|Alpine exclusively uses python3 now}} | |||
== Explanation == | |||
== List of | 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 [ircs://irc.oftc.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="py-bar" | |||
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 | |||
python3 setup.py build | |||
} | |||
package() { | |||
mkdir -p "$pkgdir" | |||
} | |||
_py2() { | |||
replaces="$pkgname" | |||
depends="${depends//py-/py2-}" | |||
_py python2 | |||
} | |||
_py3() { | |||
depends="${depends//py-/py3-}" | |||
_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). | |||
* 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 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 abuilds without Python 3 support == | |||
=== main === | === main === | ||
Line 21: | Line 100: | ||
|- | |- | ||
| py-backports.ssl_match_hostname | | py-backports.ssl_match_hostname | ||
| | | Not needed for >=py3.4 | ||
|- | |- | ||
| py-bluez | | py-bluez | ||
Line 33: | Line 109: | ||
|- | |- | ||
| py-cairo | | py-cairo | ||
| | | | ||
|- | |- | ||
Line 45: | Line 118: | ||
|- | |- | ||
| py-country | | py-country | ||
| | | | ||
|- | |- | ||
Line 99: | Line 166: | ||
|- | |- | ||
| py-egenix-mx-base | | py-egenix-mx-base | ||
| | | doesn’t support py3 | ||
|- | |- | ||
| py-exifread | | py-exifread | ||
Line 114: | Line 181: | ||
|- | |- | ||
| py-feedparser | | py-feedparser | ||
| | | | ||
|- | |- | ||
| py-flask-assets | | py-flask-assets | ||
| | | | ||
|- | |- | ||
Line 219: | Line 280: | ||
|- | |- | ||
| py-irc-scripts | | py-irc-scripts | ||
| | | | ||
|- | |- | ||
Line 282: | Line 340: | ||
|- | |- | ||
| py-oauth2client | | py-oauth2client | ||
| | | | ||
|- | |- | ||
Line 303: | Line 358: | ||
|- | |- | ||
| py-pillow | | py-pillow | ||
| | | | ||
|- | |- | ||
Line 330: | Line 382: | ||
|- | |- | ||
| py-samba | | py-samba | ||
| | | | ||
|- | |- | ||
Line 339: | Line 388: | ||
|- | |- | ||
| py-singledispatch | | py-singledispatch | ||
| | | Not needed for >=py3.3 | ||
|- | |- | ||
| py-snowballstemmer | | py-snowballstemmer | ||
Line 363: | Line 412: | ||
|- | |- | ||
| py-tevent | | py-tevent | ||
| | | | ||
|- | |- | ||
Line 378: | Line 424: | ||
|- | |- | ||
| py-twitter | | py-twitter | ||
| | | | ||
|- | |- | ||
Line 402: | Line 445: | ||
|- | |- | ||
| py-urwid-examples | | py-urwid-examples | ||
| | | | ||
|- | |- | ||
Line 411: | Line 451: | ||
|- | |- | ||
| py-webassets | | py-webassets | ||
| | | | ||
|- | |- | ||
Line 420: | Line 457: | ||
|- | |- | ||
| py-xml | | py-xml | ||
| | | | ||
|- | |- | ||
Line 458: | Line 492: | ||
|- | |- | ||
| py-django1.5 | | py-django1.5 | ||
| | | [https://www.djangoproject.com/download/#supported-versions unmaintained version] | ||
|- | |- | ||
| py-ethtool | | py-ethtool | ||
Line 521: | Line 555: | ||
|- | |- | ||
| py-rencode | | py-rencode | ||
| | | | ||
|- | |- | ||
Line 569: | Line 600: | ||
|- | |- | ||
| py2-tempita | | py2-tempita | ||
|- | |||
|} | |} | ||
[[Category:Python]] |
Latest revision as of 05:25, 26 August 2023
This material is proposed for deletion ... Alpine exclusively uses python3 now
(Discuss) |
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="py-bar" 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 python3 setup.py build } package() { mkdir -p "$pkgdir" } _py2() { replaces="$pkgname" depends="${depends//py-/py2-}" _py python2 } _py3() { depends="${depends//py-/py3-}" _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 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 | Not needed for >=py3.4 |
py-bluez | |
py-boto | |
py-cairo | |
py-cliapp | |
py-configshell | |
py-country | |
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 | doesn’t support py3 |
py-exifread | |
py-eyed3 | |
py-factory-boy | |
py-farstream0.1 | |
py-feedparser | |
py-flask-assets | |
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-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-parsing | |
py-pbr | |
py-pep8 | |
py-pgen | |
py-phonenumbers | |
py-pillow | |
py-purl | |
py-pygments | |
py-pylast | |
py-redis | |
py-roman | |
py-rrd | |
py-rsa | |
py-samba | |
py-simpleparse | |
py-singledispatch | Not needed for >=py3.3 |
py-snowballstemmer | |
py-sphinx | |
py-sphinx_rtd_theme | |
py-subversion | |
py-talloc | |
py-tdb | |
py-templayer | |
py-tevent | |
py-tracing | |
py-ttystatus | |
py-twisted | |
py-twitter | |
py-unbound | |
py-unidecode | |
py-uritemplate | |
py-urlgrabber | |
py-urlnorm | |
py-urwid | |
py-urwid-examples | |
py-vobject | |
py-webassets | |
py-wtforms | |
py-xml |
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-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 |