Wednesday, October 20, 2021

Python Bytes: #255 Closember eve, the cure for Hacktoberfest?

<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=ICp8eD6uENI' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <strong>us:</strong></p> <ul> <li>Check out the <a href="https://training.talkpython.fm/courses/all"><strong>courses over at Talk Python</strong></a></li> <li>And <a href="https://pythontest.com/pytest-book/"><strong>Brian’s book too</strong></a>!</li> </ul> <p>Special guest: <strong>Will McGugan</strong></p> <p><strong>Michael #1:</strong> <a href="https://azhpushkin.me/posts/cython-cpp-intro"><strong>Wrapping C++ with Cython</strong></a></p> <ul> <li>By <a href="https://azhpushkin.me/">Anton Zhdan-Pushkin</a></li> <li>A small series showcasing the implementation of a Cython wrapper over a C++ library.</li> <li>C library: <strong>yaacrl - Y</strong>et <strong>A</strong>nother <strong>A</strong>udio <strong>R</strong>ecognition <strong>L</strong>ibrary is a small Shazam-like library, which can recognize songs using a small recorded fragment.</li> <li>For Cython to consume yaacrl correctly, we need to “teach” it about the API using `cdef extern </li> <li>It is convenient to put such declarations in <code>*.pxd</code> files.</li> <li>One of the first features of Cython that I find extremely useful — aliasing. With aliasing, we can use names like <code>Storage</code> or <code>Fingerprint</code> for Python classes without shadowing original C++ classes.</li> <li><strong>Implementing a wrapper: pyaacrl</strong> - The most common way to wrap a C++ class is to use <a href="https://docs.python.org/3/extending/newtypes_tutorial.html">Extension types</a>. As an extension type a just a C struct, it can have an underlying C++ class as a field and act as a proxy to it.</li> <li>Cython documentation has a whole page dedicated to the pitfalls of <a href="https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html">“Using C++ in Cython</a>.”</li> <li>Distribution is hard, but there is a tool that is designed specifically for such needs: scikit-build.</li> <li><a href="https://pybind11.readthedocs.io/en/stable/"><strong>PyBind11 too</strong></a></li> </ul> <p><strong>Brian #2:</strong> <a href="https://github.com/dmerejkowsky/tbump"><strong>tbump</strong></a> <a href="https://github.com/dmerejkowsky/tbump"></a><a href="https://github.com/dmerejkowsky/tbump"><strong>: bump software releases</strong></a></p> <ul> <li><a href="https://twitter.com/geosephi/status/1437697175987920896">suggested by Sephi Berry</a></li> <li>limits the manual process of updating a project version</li> <li><code>tbump init 1.2.2</code> initializes a <code>tbump.toml</code> file with customizable settings <ul> <li><code>--pyproject</code> will append to <code>pyproject.toml</code> instead</li> </ul></li> <li><code>tbump 1.2.3</code> will <ul> <li>patch files: wherever the version listed</li> <li>(optional) run configured commands before commit <ul> <li>failing commands stop the bump.</li> </ul></li> <li>commit the changes with a configurable message</li> <li>add a version tag</li> <li>push code</li> <li>push tag</li> <li>(optional) run post publish command</li> <li>Tell you what it’s going to do before it does it. (can opt out of this check)</li> </ul></li> <li>pretty much everything is customizable and configurable.</li> <li>I tried this on a flit based project. Only required one change</li> </ul> <pre><code> # For each file to patch, add a [[file]] config # section containing the path of the file, relative to the # tbump.toml location. [[file]] src = "pytest_srcpaths.py" search = '__version__ = "{current_version}"' </code></pre> <ul> <li>cool example of a pre-commit check:</li> </ul> <pre><code> # [[before_commit]] # name = "check changelog" # cmd = "grep -q {new_version} Changelog.rst" </code></pre> <p><strong>Will #3:</strong> <strong><a href="https://closember.org/">Closember</a></strong> by <strong>Matthias Bussonnier</strong></p> <p><strong>Michael #4:</strong> <a href="https://twitter.com/btskinn/status/1441597030934011909?s=12"><strong>scikit learn goes 1.0</strong></a></p> <ul> <li>via Brian Skinn</li> <li>The library has been stable for quite some time, releasing version 1.0 is recognizing that and signalling it to our users.</li> <li>Features:</li> <li>Keyword and positional arguments - To improve the readability of code written based on scikit-learn, now users have to provide most parameters with their names, as keyword arguments, instead of positional arguments.</li> <li>Spline Transformers - One way to add nonlinear terms to a dataset’s feature set is to generate spline basis functions for continuous/numerical features with the new <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.SplineTransformer.html#sklearn.preprocessing.SplineTransformer">SplineTransformer</a>.</li> <li>Quantile Regressor - Quantile regression estimates the median or other quantiles of Y conditional on X</li> <li>Feature Names Support - When an estimator is passed a <a href="https://pandas.pydata.org/docs/user_guide/dsintro.html#dataframe">pandas’ dataframe</a> during <a href="https://scikit-learn.org/stable/glossary.html#term-fit">fit</a>, the estimator will set a <code>feature_names_in_</code> attribute containing the feature names.</li> <li>A more flexible plotting API</li> <li>Online One-Class SVM</li> <li>Histogram-based Gradient Boosting Models are now stable</li> <li>Better docs</li> </ul> <p><strong>Brian #5:</strong> <a href="https://blog.jaraco.com/devpi-as-offline-pypi-cache/"><strong>Using devpi as an offline PyPI cache</strong></a></p> <ul> <li>Jason R. Coombs</li> <li>This is the devpi tutorial I’ve been waiting for.</li> <li>Single machine local server mirror of PyPI (mirroring needs primed), usable in offline mode.</li> </ul> <pre><code> $ pipx install devpi-server $ devpi-init $ devpi-server </code></pre> <ul> <li>now in another window, prime the cache by grabbing whatever you need, with the index redirected</li> </ul> <pre><code> (venv) $ export PIP_INDEX_URL=http://localhost:3141/root/pypi/ (venv) $ pip install pytest, ... </code></pre> <ul> <li>then you can restart the server anytime, or even offline</li> </ul> <pre><code> $ devpi-server --offline </code></pre> <ul> <li>tutorial includes examples, proving how simple this is.</li> </ul> <p><strong>Will #6:</strong> <strong><a href="https://github.com/wasi-master/pypi-command-line">PyPi command line</strong> </a></p> <p><strong>Extras</strong></p> <p>Brian:</p> <ul> <li>I’ve started using pyenv on my Mac just for downloading Python versions. Verdict still out if I like it better than just downloading from pytest.org. </li> <li>Also started using <a href="https://starship.rs/">Starship</a> with no customizations so far. I’d like to hear from people if they have nice Starship customizations I should try.</li> <li><a href="https://vscode.dev/">vscode.dev</a> is a thing, <a href="https://code.visualstudio.com/blogs/2021/10/20/vscode-dev">announcement</a> just today </li> </ul> <p>Michael:</p> <ul> <li>PyCascades <a href="https://bit.ly/pycascades2022cfp"><strong>Call for Proposals</strong></a> is currently open </li> <li>Got your <a href="https://www.apple.com/macbook-pro-14-and-16/"><strong>M1 Max</strong></a>?</li> <li>Prediction: Tools like <a href="https://www.codeweavers.com/crossover"><strong>Crossover for Windows apps</strong></a> will become more of a thing.</li> </ul> <p>Will: </p> <ul> <li>GIL removal <ul> <li><a href="https://ift.tt/3C33nx2> <li><a href="https://lwn.net/SubscriberLink/872869/0e62bba2db51ec7a/">https://lwn.net/SubscriberLink/872869/0e62bba2db51ec7a/</a></li> </ul></li> <li><a href="https:///vscode.dev">vscode.dev</a></li> </ul> <p><strong>Joke:</strong> </p> <ul> <li><a href="https://devops.com/the-torture-never-stops/"><strong>The torture never stops</strong></a></li> <li><a href="http://www.zaphinath.com/wp-content/uploads/2015/11/ie-eats-glue.jpg"><strong>IE (“Safari”) Eating Glue</strong></a></li> </ul>

from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...