$30 off During Our Annual Pro Sale. View Details »

We Store Cheese in A Warehouse

We Store Cheese in A Warehouse

Context of this talk: https://speakerdeck.com/uranusjr/we-buy-cheese-in-a-cheese-shop

What Python Packaging went through in the past few years, how it is at year 2017, and looking ahead.

Tzu-ping Chung

September 21, 2017
Tweet

More Decks by Tzu-ping Chung

Other Decks in Programming

Transcript

  1. We Store Cheese in the
    Warehouse

    View Slide

  2. View Slide

  3. View Slide

  4. http://lucumr.pocoo.org/2012/6/22/hate-hate-hate-everywhere/

    View Slide

  5. 2012

    View Slide

  6. Party Like It’s 2012
    • Setuptools
    • site and .pth files
    • Eggs

    View Slide

  7. Setuptools
    • Package metadata
    • Dependency resolution!
    • easy_install

    View Slide

  8. LIAR!!!1

    View Slide

  9. View Slide

  10. .pth
    • Path configuration file
    • Placed in site-packages
    • Populate sys.path at runtime

    View Slide

  11. A PIL Tutorial
    >>> import Image
    >>> im = Image.open("louie.jpg")
    >>> im.show()
    https://gist.github.com/bradmontgomery/3125124
    ?

    View Slide

  12. $ ls $LIB/python2.7/site-packages
    PIL pkg_resources
    PIL.pth setuptools
    easy_install.py setuptools-36.5.0.dist-info
    easy_install.pyc wheel
    pip wheel-0.30.0.dist-info
    pip-9.0.1.dist-info

    View Slide

  13. >>> import Image
    >>> print(Image.__file__)
    lib/python2.7/site-packages/PIL/Image.pyc
    >>> import sys
    >>> for path in sys.path:
    ... print path
    ...
    (more...)
    lib/python2.7/site-packages/PIL
    (more...)

    View Slide

  14. $ ls $LIB/python2.7/site-packages
    PIL pkg_resources
    PIL.pth setuptools
    easy_install.py setuptools-36.5.0.dist-info
    easy_install.pyc wheel
    pip wheel-0.30.0.dist-info
    pip-9.0.1.dist-info
    This

    View Slide

  15. PTH FILES
    PTH FILES EVERYWHERE

    View Slide

  16. 2014

    View Slide

  17. View Slide

  18. View Slide

  19. View Slide

  20. View Slide

  21. View Slide

  22. Now

    View Slide

  23. PyPA’s Schedule
    • Merge back Distribute
    • New binary format (wheel)
    • Built-in Setuptools and Pip
    • Better Security

    View Slide

  24. View Slide

  25. View Slide

  26. HTTPS support on PyPI

    View Slide

  27. https://packaging.python.org

    View Slide

  28. Next

    View Slide

  29. Package
    Author
    Server
    User

    View Slide

  30. https://pypi.org

    View Slide

  31. https://github.com/pypa/warehouse

    View Slide

  32. Package
    Author
    Server
    User

    View Slide

  33. https://pipenv.org

    View Slide

  34. Pipfile
    • “Requirements 2.0”
    • Eventual pip -p integration
    • https://github.com/pypa/pipfile

    View Slide

  35. Pipfile
    • The “lock” concept
    • PEP 508 environment markers
    • Robust file format

    View Slide

  36. Package
    Author
    Server
    User

    View Slide

  37. SETUP.PY INSTALL
    MUST DIE

    View Slide

  38. View Slide

  39. setup.py
    • Ad-hoc executable is always wrong
    • Don’t know what will happen until they
    actually happen
    • Wrong assumptions on top of wrong
    assumptions

    View Slide

  40. https://en.wikipedia.org/wiki/Catch-22_(logic)

    View Slide

  41. pyproject.toml
    • Declarative data file
    • PEP 508 for requirement specification
    • Eventual support in Pip

    View Slide

  42. Summary
    • Use Pipenv to manage projects
    • Use modern tools to distribute packages
    • Adopt PEP 508, prepare for PEP 518

    View Slide

  43. Summary
    • A lot can happen in five years
    • PyPA rocks, please help them
    • Looking forward to the next five!

    View Slide

  44. View Slide