We Buy Cheese in a Cheese Shop

717 views

Published on

NOTE: SlideShare seems to have problems rendering some of my screenshots. Please visit

https://speakerdeck.com/uranusjr/we-buy-cheese-in-a-cheese-shop

for a correctly-displayed version.

ORIGINAL DESCRIPTION:
Python packaging is ______. But PyPA is trying to solve the problem. Let's take a look at how we got into this mess in the first place, and how did/will PyPA do to fix it.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
717
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

We Buy Cheese in a Cheese Shop

  1. 1. We Buy Cheese in a Cheese Shop
  2. 2. Cheese Shop
  3. 3. Cheese Shop Sketch http://en.wikipedia.org/wiki/Cheese_Shop_sketch
  4. 4. https://pypi.python.org/pypi
  5. 5. Click this!
  6. 6. “I buy my eggs at the cheese shop” ] E G A U G - Aaron Straup Cope N O O [M DjangoCon 2008 N A L 59 Why I Hate Django by Cal Henderson at DjangoCon 2008
  7. 7. Me • Call me TP • Follow @uranusjr • RTFM • http://uranusjr.logdown.com/pages/about
  8. 8. Terminology
  9. 9. PyPI
  10. 10. Python Package Index aka The Cheese Shop
  11. 11. PyPA
  12. 12. Python Packaging Authority Nobody Expects the Python Packaging Authority by Nick Coghlan at PyCon Australia 2013
  13. 13. The Spanish Inquisition http://en.wikipedia.org/wiki/The_Spanish_Inquisition_(Monty_Python)
  14. 14. Egg
  15. 15. Eggs are to Pythons as Jars are to Java http://peak.telecommunity.com/DevCenter/PythonEggs
  16. 16. Wheel
  17. 17. Wheels as in Cheese Shops
  18. 18. http://www.pythonwheels.com (retrieved on 2013-11-30)
  19. 19. http://www.python.org/dev/peps/pep-0427/
  20. 20. Wheel is… • The replacement of egg • Standardized • Alternative Python implementation • API tag • Packaged with better structure and metadata • Performance • Security
  21. 21. But Why? If It Ain’t Broke, Don’t Fix It
  22. 22. Because Eggs Are Broken No pun intended
  23. 23. Where We Are Now
  24. 24. Server Package Author You
  25. 25. Server Package Author You
  26. 26. distutils • I am no expert on neither itself nor its history • Built-in since Python 1.6 (2000) • Nothing really changed since about 10 years ago Full documentation: http://docs.python.org/library/distutils.html
  27. 27. Container What you want to deploy Full documentation: http://docs.python.org/library/distutils.html
  28. 28. The “Makefile” Full documentation: http://docs.python.org/library/distutils.html
  29. 29. Extra rules on non-module information Full documentation: http://docs.python.org/library/distutils.html
  30. 30. setup.py from distutils.core import setup! ! setup(! name='mypackage',! version='1.0',! packages=['mymodule'],! description='My package',! url='http://myawesomepackage.com',! author='Me the Author',! author_email='im@aweso.me'! ) Documentation: http://docs.python.org/distutils/setupscript.html
  31. 31. MANIFEST.in include README.rst! recursive-exclude * __pycache__! recursive-exclude * *.py[co]! include docs! prune docs/build Documentation: http://docs.python.org/distutils/sourcedist.html
  32. 32. $ python setup.py sdist! ! $ python setup.py bdist_wininst Documentation: http://docs.python.org/distutils/sourcedist.html
  33. 33. from setuptools import setup! ! setup(! # ...! ) $ python setup.py bdist_egg Documentation: http://peak.telecommunity.com/DevCenter/PythonEggs
  34. 34. Source distribution
  35. 35. Binary egg
  36. 36. Windows installer
  37. 37. “I buy my eggs at the cheese shop” - Aaron Straup Cope DjangoCon 2008 58 Does this make sense now?
  38. 38. Package metadata (collected from setup)
  39. 39. The “zip safety” flag
  40. 40. Top level modules
  41. 41. Files in the package
  42. 42. Depended packages
  43. 43. Package information (as seen on PyPI)
  44. 44. Where to find packages (aside from PyPI)
  45. 45. Server Package Author You
  46. 46. $ python setup.py register! ! $ python setup.py sdist bdist_egg upload Documentation: http://docs.python.org/distutils/packageindex.html
  47. 47. Server Package Author You
  48. 48. PyPI Package Author You
  49. 49. PyPI mirror mirror Package Author You
  50. 50. PyPI Package Author Self-hosted Server You
  51. 51. [Y]ou don't have to worry about it. They've figured it all out already. The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) by Joel Spolsky
  52. 52. Actually they did not; I just don’t want to talk about it.
  53. 53. Server Package Author You
  54. 54. The Manual Way 1. Go to PyPI and search for a package 2. Download 3. Install • Extract • python setup.py install
  55. 55. With Setuptools 1. Install Setuptools 2. Run easy_install <package>! 3. Profit! Documentation: https://pypi.python.org/pypi/setuptools#installation-instructions
  56. 56. Problem?
  57. 57. LIAR!!!1
  58. 58. What is zip-safe, anyway?
  59. 59. Why PIP? • All packages are downloaded before installation • Flat installation by default • Uninstallation • Clean code™ • PyPI with HTTPS by default http://www.pip-installer.org/en/latest/other-tools.html#easy-install
  60. 60. Why NOT PIP? • Incompatible with certain legacy packages (rare) • Cannot install from bdist packages (except eggs) http://www.pip-installer.org/en/latest/other-tools.html#easy-install
  61. 61. 先別說 個了! 你聽過 distribute ?
  62. 62. Commit history of https://bitbucket.org/pypa/setuptools/
  63. 63. https://bitbucket.org/tarek/distribute/overview
  64. 64. distribute • Intended to replace Setuptools • Shares the same module names (setuptools and pkg_resources) • Active development https://bitbucket.org/tarek/distribute/overview
  65. 65. http://xkcd.com/927/
  66. 66. We Need a New Standard!
  67. 67. http://ziade.org/2010/03/03/the-fate-of-distutils-pycon-summit-packaging-sprint-detailed-report/
  68. 68. http://www.python.org/dev/peps/pep-0376/
  69. 69. o N e v E t in n t y P n o h .4 3
  70. 70. This is what you get when developers fight with each other. Panel: Directions for Packaging, PyCON US 2013
  71. 71. ./setup.py install must die! Panel: Directions for Packaging, PyCON US 2013
  72. 72. PyPA’s Schedule • Merge Distribute back to Setuptools (Done) • New binary distribution format (Done) • Built-in Setuptools and pip support in Python • Better security • …And more! The Future of Python Packaging, Python Packaging User Guide
  73. 73. https://github.com/pypa/pip/commit/b90fc1a
  74. 74. pip >= 1.4 setuptools >= 0.8 Upgrading notes: http://pythonhosted.org/setuptools/merge-faq.html
  75. 75. $ python setup.py bdist_wheel upload $ pip install --use-wheel <package> Documentation: docs.python.org/distutils/packageindex.html
  76. 76. MORE IS BETTER
  77. 77. Name Python tag Platform Pillow-2.2.1-cp32-none-win32.whl Version ABI tag I’m a wheel!
  78. 78. Replaces dashes with underscores Platform independent django_mosql-0.2-py27-none-any.whl Implementation not relevant Does not need ABI information
  79. 79. Description gets its own file!
  80. 80. Other metadata (similar to PKG-INFO)
  81. 81. Unchanged
  82. 82. ???
  83. 83. Metadata in JSON
  84. 84. Wheel format specification
  85. 85. SHA256 for each file in this directory
  86. 86. What Changed? • The One True Cheese Shop • Forward compatibility • Machine-friendliness • Safety
  87. 87. Wrapping Up • Python packaging is _____ • How did we get into this mess? • distutils • setuptools • PyPI • A way out
  88. 88. Wheel is the future. Adapt today!

×