Slide 1

Slide 1 text

@ben_nuttall Running a Python Package Index for Raspberry Pi

Slide 2

Slide 2 text

@ben_nuttall Ben Nuttall ● Senior Software Engineer, BBC News Labs ● Former Community Manager at Raspberry Pi ● Based in Cambridgeshire, UK ● bennuttall.com ● twitter.com/ben_nuttall ● github.com/bennuttall

Slide 3

Slide 3 text

@ben_nuttall Pure Python package Binary distribution (bdist) .whl Source distribution (sdist) .zip .tar.gz

Slide 4

Slide 4 text

@ben_nuttall Compiled Python package Python version 3.5 3.6 3.7 3.8 3.9 Windows (win32) Windows (amd64) Mac OS (x86_64) Linux (i686) Linux (x86_64) Source (sdist)

Slide 5

Slide 5 text

@ben_nuttall pip

Slide 6

Slide 6 text

@ben_nuttall pip

Slide 7

Slide 7 text

@ben_nuttall What is piwheels? ● Open source project maintained by: – Ben Nuttall – Dave Jones ● Tooling to automate building wheels of everything on PyPI – Wheels are pre-compiled binary distributions of Python packages ● Pip-compatible index (PEP-503) – Can be used by pip as an "extra index" alongside PyPI ● Tailored towards the Arm platform – linux_armv6l and linux_armv7l platform tags

Slide 8

Slide 8 text

@ben_nuttall piwheels Stretch (Python 3.5) Buster (Python 3.7) Bullseye (Python 3.9) linux_armv6l linux_armv7l

Slide 9

Slide 9 text

@ben_nuttall piwheels.org ● Website comprises: ● Simple index (for pip) ● Project pages (for people) ● Blog & info pages (for people)

Slide 10

Slide 10 text

@ben_nuttall Mythic Beasts Pi Cloud

Slide 11

Slide 11 text

@ben_nuttall piwheels stack ● Master – Web server hosts index and wheel files – Monitors PyPI events – Logs build attempts & downloads in DB ● Postgres database – Generates build queue ● Builders – Get given build jobs – 5 × Pi 3 (Stretch / Python 3.5) – 5 × Pi 4 (Buster / Python 3.7) – 5 × Pi 4 (Bullseye / Python 3.9) – Easy to scale up/down

Slide 12

Slide 12 text

@ben_nuttall Following PyPI’s event log 36195 scipy 2007-10-15 20:47:37 remove Owner edschofield 36257 scipy 2007-10-15 20:47:56 add Maintainer edschofield 36634 scipy 2007-10-16 03:59:41 add Owner jarrodmillman 2416 scipy 0.6.0 2007-10-17 08:53:30 new release 36699 scipy 0.6.0 2007-10-17 08:57:23 update _pypi_hidden 26010 scipy 0.6.0 2007-10-17 08:57:56 update description

Slide 13

Slide 13 text

@ben_nuttall Following PyPI’s event log ● We care about: – Package creation/deletion – Version creation/deletion – Source distribution upload/removal – Yank/Unyank version ● Update database ● Add builds to queue ● Remove files ● Rewrite web pages as necessary

Slide 14

Slide 14 text

@ben_nuttall piwheels build queue

Slide 15

Slide 15 text

@ben_nuttall Using piwheels ● Raspberry Pi OS is pre- configured to use piwheels.org as an additional index to PyPI ● Users get platform wheels without knowing it’s there

Slide 16

Slide 16 text

@ben_nuttall Using piwheels ● Raspberry Pi OS is pre- configured to use piwheels.org as an additional index to PyPI ● Users get platform wheels without knowing it’s there

Slide 17

Slide 17 text

@ben_nuttall Stats

Slide 18

Slide 18 text

@ben_nuttall Static site build ● Once/periodically: – Homepage & single pages ● When changed: – Simple index – Package simple index (create, update and delete) – Package project page (create, update and delete) – Wheel files (create and delete)

Slide 19

Slide 19 text

@ben_nuttall piwheels.org/simple/scipy/

Slide 20

Slide 20 text

@ben_nuttall piwheels.org/project/scipy/

Slide 21

Slide 21 text

@ben_nuttall apt dependencies

Slide 22

Slide 22 text

@ben_nuttall apt dependencies

Slide 23

Slide 23 text

@ben_nuttall apt dependencies ● ldd cv2.cpython-35m-arm-linux-gnueabihf.so – libhdf5_serial.so.100 => not found ● apt-file search libhdf5_serial.so.100 – libhdf5-100 ● sudo apt install libhdf5-100 https://blog.piwheels.org/how-to-work-out-the-missing-dependencies-for-a-python-package/

Slide 24

Slide 24 text

@ben_nuttall apt dependencies

Slide 25

Slide 25 text

@ben_nuttall JSON API ● piwheels.org/project//json – Info about a specific package (versions, builds, files, etc) ● piwheels.org/packages.json – List of all packages, with per-package download stats

Slide 26

Slide 26 text

@ben_nuttall Package issues

Slide 27

Slide 27 text

@ben_nuttall Package issues

Slide 28

Slide 28 text

@ben_nuttall Package issues

Slide 29

Slide 29 text

@ben_nuttall Running a Python Package Index for Raspberry Pi