Created
September 26, 2026 17:53
-
-
Save OscarL/52ae1b5f0ca1503b8a48cf419f0e5d58 to your computer and use it in GitHub Desktop.
Some HaikuPorter .recipe templates for working with Python packages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Template for Python packages that provide a pre-built wheel (.whl) file suitable for use | |
| # in several Python versions (eg.: "-py3-none-any.whl" ones). | |
| # | |
| # This template variant is for packages that DO NOT provide commands under /bin/ | |
| # | |
| # Fill in the blanks, rename recipe according to package name and version. | |
| # | |
| # Remove the [hint] comments before submitting. | |
| SUMMARY="" | |
| DESCRIPTION="" | |
| HOMEPAGE="" | |
| COPYRIGHT="" | |
| LICENSE="MIT" | |
| REVISION="1" | |
| # [hint]: might need to use 'py2.py3' instead of 'py3' here, depending on what the wheel targets. | |
| SOURCE_URI="https://files.pythonhosted.org/packages/py3/${portName:0:1}/$portName/$portName-$portVersion-py3-none-any.whl#noarchive" | |
| CHECKSUM_SHA256="" | |
| ARCHITECTURES="any" | |
| # [template hint]: No PROVIDES to avoid having an empty "base" package. | |
| BUILD_REQUIRES=" | |
| haiku_devel | |
| " | |
| # Add more versions here as necessary: | |
| PYTHON_VERSIONS=(3.10 3.14) | |
| for pythonVersion in ${PYTHON_VERSIONS[@]}; do | |
| pythonPackage=python${pythonVersion//.} | |
| # Not renaming 3.10 packages to avoid needing massive packages rebuilds. | |
| # No need for REPLACES then. ToDo: remove the conditional after dropping 3.10. | |
| if [ $pythonVersion != 3.10 ]; then | |
| # Allows using dot in sub-package names (eg: "_python3.14" vs "_python314"): | |
| eval "PACKAGE_NAME_$pythonPackage=${portName}_python$pythonVersion" | |
| eval "PROVIDES_$pythonPackage=\" | |
| ${portName}_python$pythonVersion = $portVersion | |
| \"" | |
| fi | |
| eval "PROVIDES_$pythonPackage+=\" | |
| ${portName}_$pythonPackage = $portVersion | |
| \"" | |
| eval "REQUIRES_$pythonPackage=\" | |
| haiku | |
| cmd:python$pythonVersion | |
| \"" | |
| BUILD_REQUIRES+=" | |
| installer_$pythonPackage | |
| " | |
| BUILD_PREREQUIRES+=" | |
| cmd:python$pythonVersion | |
| " | |
| done | |
| INSTALL() | |
| { | |
| for pythonVersion in ${PYTHON_VERSIONS[@]}; do | |
| pythonPackage=python${pythonVersion//.} | |
| python=python$pythonVersion | |
| $python -m installer -p $prefix $portName-$portVersion-*-none-any.whl | |
| packageEntries $pythonPackage \ | |
| $prefix/lib/$python | |
| done | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Template for Python packages that provide a pre-built wheel (.whl) file suitable for use | |
| # in several Python versions (eg.: "-py3-none-any.whl" ones). | |
| # | |
| # This template variant is for those that provide commands under /bin/ | |
| # | |
| # Fill in the blanks, rename recipe according to package name and version, and replace "XXX" | |
| # where needed. | |
| # | |
| # Remove the [hint] comments before submitting. | |
| SUMMARY="" | |
| DESCRIPTION="" | |
| HOMEPAGE="" | |
| COPYRIGHT="" | |
| LICENSE="MIT" | |
| REVISION="1" | |
| # [hint]: might need to use 'py2.py3' instead of 'py3' here, depending on what the wheel targets. | |
| SOURCE_URI="https://files.pythonhosted.org/packages/py3/${portName:0:1}/$portName/$portName-$portVersion-py3-none-any.whl#noarchive" | |
| CHECKSUM_SHA256="" | |
| ARCHITECTURES="any" | |
| # [template hint]: No PROVIDES to avoid having an empty "base" package. | |
| BUILD_REQUIRES=" | |
| haiku_devel | |
| " | |
| # Add more versions here as necessary: | |
| PYTHON_VERSIONS=(3.10) | |
| # And don't forget to change this if the default Python version on Haiku changes: | |
| defaultVersion=3.10 | |
| for pythonVersion in ${PYTHON_VERSIONS[@]}; do | |
| pythonPackage=python${pythonVersion//.} | |
| # Not renaming 3.10 packages to avoid needing massive packages rebuilds. | |
| # No need for REPLACES then. ToDo: remove the conditional after dropping 3.10. | |
| if [ $pythonVersion != 3.10 ]; then | |
| # Allows using dot in sub-package names (eg: "_python3.14" vs "_python314"): | |
| eval "PACKAGE_NAME_$pythonPackage=${portName}_python$pythonVersion" | |
| eval "PROVIDES_$pythonPackage=\" | |
| ${portName}_python$pythonVersion = $portVersion | |
| \"" | |
| fi | |
| eval "PROVIDES_$pythonPackage+=\" | |
| ${portName}_$pythonPackage = $portVersion | |
| cmd:XXX_$pythonVersion = $portVersion | |
| \"" | |
| if [ $pythonVersion = $defaultVersion ]; then | |
| eval "PROVIDES_$pythonPackage+=\" | |
| cmd:XXX = $portVersion | |
| \"" | |
| fi | |
| eval "REQUIRES_$pythonPackage=\" | |
| haiku | |
| cmd:python$pythonVersion | |
| \"" | |
| BUILD_REQUIRES+=" | |
| installer_$pythonPackage | |
| " | |
| BUILD_PREREQUIRES+=" | |
| cmd:python$pythonVersion | |
| " | |
| done | |
| INSTALL() | |
| { | |
| for pythonVersion in ${PYTHON_VERSIONS[@]}; do | |
| pythonPackage=python${pythonVersion//.} | |
| python=python$pythonVersion | |
| $python -m installer -p $prefix $portName-$portVersion-*-none-any.whl | |
| # Version suffix all the scripts | |
| for f in $binDir/*; do | |
| mv $f $f-$pythonVersion | |
| done | |
| # And provide suffix-less symlinks for the default version | |
| if [ $pythonVersion = $defaultVersion ]; then | |
| for f in $binDir/*; do | |
| ln -sr $f ${f%-$pythonVersion} | |
| done | |
| fi | |
| packageEntries $pythonPackage \ | |
| $prefix/lib/$python \ | |
| $binDir | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment