r ethinking
play

R ETHINKING P YTHON P ACKAGING A thought experiment @pradyunsg - PowerPoint PPT Presentation

R ETHINKING P YTHON P ACKAGING A thought experiment @pradyunsg pradyunsg.me/talks W HO ? Pradyun Gedam @pradyunsg pradyunsg.me Member of Python Packaging Authority Maintainer of pip, virtualenv, packaging and more PSF


  1. R ETHINKING 
 P YTHON P ACKAGING A thought experiment @pradyunsg pradyunsg.me/talks

  2. W HO ? Pradyun Gedam 
 @pradyunsg 
 pradyunsg.me Member of 
 Python Packaging Authority Maintainer of 
 pip, virtualenv, packaging and more PSF Fellow College student!

  3. R ETHINKING P YTHON P ACKAGING

  4. Publisher User PyPI twine pip Distribution Distribution setuptools virtualenv virtualenv pip Working? Source Code Software

  5. R ETHINKING P YTHON P ACKAGING

  6. Free to ignore existing tooling Best practices as defaults Try to not break everything Easier to understand, use and maintain

  7. C ONSTRAINTS • No removal of functionality for: • infrastructure — PyPI • published packages • existing PyPA standards

  8. D ISCLAIMERS complete speculation 
 (sort of) other folks’ ideas + my opinions very little UX experience

  9. "T HINGS "

  10. Source Tree

  11. Source Distribution Wheel Distribution

  12. Environments Installed Packages Platform Details

  13. PyPI

  14. PEP 517’ S MODEL

  15. PEP 517’ S MODEL

  16. M ODERN P ACKAGING T OOLING ’ S MODEL

  17. M ODERN P ACKAGING T OOLING ’ S MODEL • Build Backend — like setuptools, fl it etc • Produce distributions from source trees • Build Frontend — like pip • is user-facing — user work fl ows • manages environment • handles distributions • orchestrates build backends

  18. B ACKEND O PERATIONS • Produce distributions from source trees • Handling of Python code • Handling of non-Python code / artefacts • Metadata generation • Properly place fi les into a distribution

  19. M ETADATA • setuptools allows for arbitrary logic, which can be used for generating metadata • What we’d want • Static metadata, by default • Dynamic metadata, by opt-in • Keep metadata in pyproject.toml • Allow specifying a script for enhancing it

  20. H ANDLING OF NON -P YTHON CODE / ARTEFACTS • setuptools invokes the compilers directly • complicated build process → complicated setup.py • What we’d want • Generate build instructions for *other* build tools • Invoke the build tools

  21. P ROPERLY PLACE FILES INTO A DISTRIBUTION • Idempotent source distributions • unpack sdist + build sdist → same as initial • Build non-Python "stuff" only for wheels

  22. Unpack Source Tree Source Distribution Build sdist Build wheel Wheel Distributions Unpack Installed Package @pradyunsg pradyunsg.me/talks

  23. BUILD SDIST • Load information from pyproject.toml • Generate metadata • Package relevant fi les into a .tar.gz fi le

  24. BUILD WHEEL • Load information from pyproject.toml • Build non-Python code into binaries • Generate metadata • Package relevant fi les into a .whl fi le

  25. F RONTEND O PERATIONS • Environment management • Dependency resolution (hah!) • Installation / Uninstallation / Upgrade • Handling distributions • Discovering and fetching distributions • Unpacking distributions correctly • Orchestrates build backends • Manage source tree → distribution

  26. H ANDLING D ISTRIBUTIONS • Discovering and fetching distributions • Index interaction • Networking — TLS, proxies, caching and more • Unpacking distributions • Placing the contents of a wheel correctly

  27. E NVIRONMENT M ANAGEMENT • Allow installation and uninstallation of projects into an environment. • Binary Compatibility — wheel compatibility tags • Reproducibility — lock fi le • Ensure all requirements are satis fi ed for all installed packages • Dependency Resolution

  28. F RONT E ND U SABILITY • Produce a local directory of artifacts for of fl ine usage • downloading from PyPI • producing wheels • Introspect the current state of installed packages, and get more information about them

  29. U PLOADING D ISTRIBUTIONS • Two Phase uploads — enable new work fl ows • https:/ /github.com/pypa/warehouse/issues/726 • Easier communication for deprecations • Stricter metadata requirements for new uploads • Better licensing information • Yanking releases • Yank due to security bugs

  30. O K , GREAT . N OW WHAT ?

  31. W E CHART A COURSE TO GET THERE .

  32. F URTHER R EADING • https:/ /discuss.python.org/t/876 • https:/ /discuss.python.org/t/2062 • https:/ /discuss.python.org/t/2570 • https:/ /discuss.python.org/t/2579 • https:/ /discuss.python.org/t/2584 • https:/ /discuss.python.org/t/2587 • https:/ /discuss.python.org/t/2591 • https:/ /www.curiousef fi ciency.org/posts/2016/09/ python-packaging-ecosystem.html

  33. T HANKS ! @pradyunsg pradyunsg.me/talks

Recommend


More recommend