Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 24353

Python Bytes: #322 Python Packages, Let Me Count The Ways

$
0
0
<a href='https://www.youtube.com/watch?v=TtX32d5rFAo' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <a href="http://pythonbytes.fm/foundershub2022"><strong>Microsoft for Startups Founders Hub</strong></a>.</p> <p><strong>Connect with the hosts</strong></p> <ul> <li>Michael: <a href="https://fosstodon.org/@mkennedy"><strong>@mkennedy@fosstodon.org</strong></a></li> <li>Brian: <a href="https://fosstodon.org/@brianokken"><strong>@brianokken@fosstodon.org</strong></a></li> <li>Show: <a href="https://fosstodon.org/@pythonbytes"><strong>@pythonbytes@fosstodon.org</strong></a></li> <li>Special guest: <a href="https://fosstodon.org/@calvinhp"><strong>@calvinhp@fosstodon.org</strong></a></li> </ul> <p>Join us on YouTube at <a href="https://pythonbytes.fm/stream/live"><strong>pythonbytes.fm/stream/live</strong></a> to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.</p> <p><strong>Brian #1:</strong> <a href="https://packaging.python.org/en/latest/tutorials/packaging-projects/"><strong>Packaging Python Projects</strong></a></p> <ul> <li>Tutorial from PyPA</li> <li>This is a really good starting point to understand how to share Python code through packaging.</li> <li>Includes discussion of <ul> <li>directory layout</li> <li>creating package files, LICENSE, pyproject.toml, README.md, tests and src dir</li> <li>how to fill out <code>build-system</code> section of <code>pyproject.toml</code> <ul> <li>using either hatchling, setuptools, flit, or pdm as backends</li> </ul></li> <li>metadata</li> <li>using <code>build</code> to generate wheels and tarballs</li> <li>uploading with <code>twine</code></li> </ul></li> <li>However <ul> <li>For small-ish pure Python projects, I still prefer <a href="https://flit.pypa.io/en/latest/">flit</a> <ul> <li><code>flit init</code> creates pyproject.toml and LICENSE <ul> <li>will probably still need to hand tweak pyproject.toml</li> </ul></li> <li><code>flit build</code> replaces <code>build</code></li> <li><code>flit publish</code> replaces <code>twine</code></li> </ul></li> <li>The process <a href="https://hachyderm.io/@doughellmann/109807100255088176">can be confusing, even for seasoned professionals.</a></li> </ul></li> <li>Further discussion later in the show</li> </ul> <p><strong>Michael #2:</strong> <a href="https://github.com/stchris/untangle"><strong>untangle xml</strong></a></p> <ul> <li>Convert XML to Python objects</li> <li>Children can be accessed with <code>parent.child</code>, attributes with <code>element['attribute']</code>.</li> <li>Call the <code>parse()</code> method with a filename, an URL or an XML string.</li> <li>Given this XML: <pre><code> [HTML_REMOVED] [HTML_REMOVED] [HTML_REMOVED] [HTML_REMOVED] </code></pre></li> </ul> <p>Access the document:</p> <pre><code> obj.root.child['name'] # u'child1' </code></pre> <ul> <li>A little cleaner that <a href="https://docs.python.org/3/library/xml.etree.elementtree.html">ElementTree</a> perhaps.</li> </ul> <p><strong>Calvin</strong> <strong>#3:</strong> <a href="https://mypy-lang.blogspot.com/2023/02/mypy-10-released.html"><strong>Mypy 1.0 Released</strong></a></p> <ul> <li>Mypy is a static type checker for Python, basically a Python linter on steroids</li> <li>Started in 2012 and developed by a team at Dropbox lead by https://github.com/JukkaL</li> <li>What’s New? <ul> <li>New Release Numbering Scheme <ul> <li>not using symver</li> <li>Significant backward incompatible changes will be announced in the blog post for the previous feature release</li> <li>feature flags will allow users to upgrade and turn on the new behavior</li> </ul></li> <li>Mypy 1.0 is 40% faster than 0.991 against the Dropbox internal codebase <ul> <li>20 optimizations included in this release</li> </ul></li> <li>Mypy now warns about errors used before definition or possibly undefined variables <ul> <li>for example if a variable is used outside of a block of code that may not execute</li> </ul></li> <li>Mypy now supports the new <code>Self</code> type introduced in PEP 673 and Python 3.11</li> <li>Support <code>ParamSpec</code> in Type Aliases</li> <li>Also, <code>ParamSpec</code> and Generic <code>Self</code> types are no loner experimental</li> <li>Lots of Miscellaneous New Features</li> <li>Fixes to crashes</li> <li>Support for compiling Python <code>match</code> statements introduced in Python 3.10</li> </ul></li> </ul> <p><strong>Brian #4:</strong> <a href="https://pradyunsg.me/blog/2023/01/21/thoughts-on-python-packaging"><strong>Thoughts on the Python packaging ecosystem</strong></a></p> <ul> <li>Pradyun Gedam</li> <li>Some great background on the internal tension around packaging. </li> <li>Brian’s note: in the meantime <ul> <li>people are struggling to share Python code</li> <li>the “best practice” answer seems to shift regularly</li> <li>this might be healthy to arrive at better tooling in the long term, but in the short term, it’s hurting us. </li> </ul></li> <li>From the article: <ul> <li>The Python packaging ecosystem <em>unintentionally</em> became the type of competitive space that it is today.</li> <li>The community needs to make an explicit decision if it should continue operating under the model that led to status quo.</li> <li>Pick from N different tools that do N different things is a good model.</li> <li>Pick from N ~equivalent choices is a <em>really bad</em> user experience.</li> <li>Picking a default doesn’t make other approaches illegal.</li> <li>Communication about the Python packaging ecosystem is fragmented, and we should improve that.</li> </ul></li> <li>Pradyun: “Many of the users who write Python code are <em>not</em> primarily full-time software engineers or “developers”.”</li> <li>from Thea: “The reason there are so many tools for managing Python dependencies is because Python is not a monoculture and different folks need different things.”</li> <li>opening up the build backend through pyproject.toml-based builds was good</li> <li>but the fracturing of multiple “workflow” tools seems bad.</li> <li>“I am certain that it is not possible to create a single “workflow” tool for Python software. What we have today, an ecosystem of tooling where each makes different design choices and technical trade-offs, is a part of why Python is as widespread as it is today. This flexibility and availability of choice is, however, both a blessing and a curse.”</li> <li>On building a default workflow tool around pip <ul> <li>interesting idea</li> </ul></li> <li>There’s tension between “we need a default workflow tool” and “unix philosophy: many focused tools that can work together”.</li> </ul> <p><strong>Michael #5:</strong> <a href="https://hugovk.github.io/top-pypi-packages/"><strong>Top PyPI Packages</strong></a></p> <ul> <li>A monthly dump of the 5,000 most-downloaded packages from PyPI.</li> <li>Also, a full copy of PyPI info too: <a href="https://github.com/orf/pypi-data">github.com/orf/pypi-data</a></li> </ul> <p><strong>Calvin</strong> <strong>#6:</strong> <a href="https://www.sqlalchemy.org/blog/2023/01/26/sqlalchemy-2.0.0-released/"><strong>SQLAlchemy 2.0 Released</strong></a></p> <ul> <li>#57 on the Top PyPI Packages 😸 </li> <li>Will be giving a SQLAlchemy tutorial at Python Web Conf</li> <li>What’s New? <ul> <li>Significant API change from 1.4</li> <li>You’ll want to follow the <a href="https://docs.sqlalchemy.org/en/20/changelog/migration_20.html">migration guide</a> and see also the <a href="https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html">what’s new in 2.0 guide</a></li> <li>Fully takes advantage of Python 3 features such as dataclasses, enums and inline annotations</li> <li>Typing support in Core and ORM, but still should be considered <strong>beta</strong> <ul> <li><strong>all SQLAlchemy stubs packages must be uninstalled all SQLAlchemy stubs packages must be uninstalled</strong> for typing to work</li> <li><a href="https://docs.sqlalchemy.org/en/20/orm/extensions/mypy.html">Mypy Plugin</a> is considered deprecated now</li> </ul></li> <li>Major speed increase in the all new fully ORM-integrated bulk <code>INSERT</code>s <ul> <li>sorry if you are on MySQL, they don’t support <code>INSERT RETURNING</code> yet</li> <li>but MariaDB does support this</li> </ul></li> <li>All new bulk optimized schema reflection architecture <ul> <li>Currently enabled for PostgreSQL and Oracle</li> <li>250% perf increase for Postgres</li> <li>900% per increase for Oracle</li> </ul></li> <li>Native extensions ported to Cython <ul> <li>C extensions have been replaced by Cython</li> <li>Benchmarks as fast or sometimes faster than the previous C extensions</li> <li>Removes some risk of memory or stability issues introduced by C</li> </ul></li> <li>SQLAlchemy is now pep-517 enabled and has a <code>pyproject.toml</code> at the root <ul> <li>means that local source building with <code>pip</code> can auto install the Cython dependancy</li> </ul></li> </ul></li> </ul> <p><strong>Extras</strong> </p> <p>Brian:</p> <ul> <li>Nothing to share yet, but I’m building a new alternative Python build backend. <ul> <li>which if course will be followed with a new workflow tool that follows “my workflow”.</li> </ul></li> </ul> <p>Michael:</p> <ul> <li>“Create shortcut: New window” tip: <ul> <li><a href="https://talk-python-static.nyc3.digitaloceanspaces.com/window-apps.png">In the dock/task bar</a></li> <li><a href="https://talk-python-static.nyc3.digitaloceanspaces.com/proton-app.png">Running as an app</a></li> </ul></li> <li>Speaking of Proton, started using <a href="https://simplelogin.io">simplelogin.io</a></li> <li>What’s all this banning chips about? <a href="https://youtu.be/k_zz3239DA0">Great documentary</a></li> <li><a href="https://fosstodon.org/@mkennedy/109803554690967616">Talk Python is hiring</a>!</li> </ul> <p>Calvin: </p> <ul> <li>5th Annual <a href="https://2023.pythonwebconf.com">Python Web Conf 2023</a></li> </ul>

Viewing all articles
Browse latest Browse all 24353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>