Friday, July 30, 2021

Python Bytes: #244 vendorizing your Python podcast

<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=5Tm5tr3prPs' 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><a href="https://twitter.com/blbraner">Brandon Braner</a></strong></p> <p><strong>Brain #1:</strong> <a href="https://pip.pypa.io/en/stable/topics/configuration/#environment-variables"><strong>pip Environmental Variables</strong></a></p> <ul> <li>The problem with snakes on a plane → no internet</li> <li>Situation: <ul> <li>want to work on some code on a plane</li> <li>project set up to use tox, which creates venvs, and pip installs dependencies <strong>from pypi.org.</strong></li> <li>but… no internet</li> </ul></li> <li>Preflight work: <ul> <li>run tox with an internet connection</li> <li>copy everything from all of the “site-packages” directories under “.tox” into a “wheels” directory or whatever you want to call it.</li> <li>set environmental variables:</li> <li>PIP_FIND_LINKS=file:/Users/okken/wheels</li> <li>PIP_NO_INDEX=1</li> <li>Try this out first BEFORE getting on the plane, to make sure you didn’t miss anything.</li> </ul></li> <li>In flight: <ul> <li>tox works fine now, using local dir as index</li> </ul></li> <li>Thanks <a href="https://twitter.com/pganssle/status/1420807532076060677?s=20">Paul Ganssle</a> for helping with this.</li> <li>All command line flags for pip are available as env variables: <ul> <li>“pip’s command line options can be set with environment variables using the format <code>PIP_[HTML_REMOVED]</code> . Dashes (<code>-</code>) have to be replaced with underscores (<code>_</code>).”</li> </ul></li> </ul> <p><strong>Michael #2: Extra, Extra, 6x Extra, hear all about it</strong></p> <ul> <li><a href="https://www.youtube.com/watch?v=lon-dEXfY2I"><strong>Michael’s Pydantic talk</strong></a></li> <li><strong><a href="https://talkpython.fm/episodes/show/327/little-automation-tools-in-python">Little Automation Tools in Python episode</a></strong></li> <li><a href="https://amzn.to/3BJ05z0"><strong>A Day in Code- Python: Learn to Code in Python through an Illustrated Story Released</strong></a> by Shari Eskenas</li> <li><a href="https://www.tabnine.com/"><strong>TabNine AI complete</strong></a></li> <li><a href="https://twitter.com/RhetTurnbull/status/1420037464366882818"><strong>macOS photos follow up</strong></a></li> <li><a href="https://github.com/mikeckennedy/jinja_partials"><strong>jinja-partials</strong></a></li> <li><a href="https://github.com/mikeckennedy/chameleon_partials"><strong>chameleon-partials</strong></a></li> <li><a href="https://github.com/mikeckennedy/fastapi-chameleon"><strong>fastapi-chameleon</strong></a></li> </ul> <p><strong>Brandon</strong> <strong>#3:</strong> <a href="https://www.kaggle.com/thirty-days-of-ml"><strong>Kaggle 30 Days of Machine Learning</strong></a> </p> <ul> <li>What is <a href="https://www.kaggle.com/">Kaggle</a> <ol> <li>Find and publish data sets</li> <li>Explore and build models in a web-based data-science environment(Jupyter Notebooks)</li> <li>Work with other data scientists and machine learning engineers</li> <li><strong>Enter competitions</strong> to solve data science challenges.</li> </ol></li> <li>Starts August 2nd, 2021</li> <li>Has an introduction to Python and covers basic and intermediate machine learning concepts</li> <li>Get some completion certificates</li> <li>Kaggle competition at the end with teams of 3</li> </ul> <p><strong>Brian #4:</strong> <a href="https://docs.github.com/en/actions/guides/building-and-testing-python"><strong>Building and testing Python with GitHub Actions</strong></a></p> <ul> <li>GitHub Docs</li> <li>This is an incredible resource</li> <li>I suggest starting with <a href="https://docs.github.com/en/actions/guides/building-and-testing-python#running-tests-with-tox"><strong>Running tests with tox</strong></a>, as it’s a super simple setup.</li> <li>And, you can test all of the tox environments locally.</li> </ul> <pre><code> name: Python package on: [push, pull_request] jobs: build: runs-on: ubuntu-latest strategy: matrix: python: [3.7, 3.8, 3.9, 3.10-dev] steps: - uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: python-version: $ - name: Install Tox and any other packages run: pip install tox - name: Run Tox run: tox -e py </code></pre> <p><strong>Michael #5:</strong> <a href="https://github.com/mwilliamson/python-vendorize"><strong>python-vendorize</strong></a></p> <ul> <li>via Patrick Park</li> <li>Vendoring a dependency means basically copying it into your package or your app rather than installing and importing it externally.</li> <li>Here’s a simple way to do that.</li> <li><code>python-vendorize</code> allows pure-Python dependencies to be vendorized</li> <li><code>vendorize.toml</code> might look something like:</li> </ul> <pre><code> target = "your_app/_vendor" packages = [ "six", ] </code></pre> <ul> <li>run <code>python-vendorize</code> in the same directory as <code>vendorize.toml</code></li> <li>In <code>your_app.py</code>, <code>six</code> can be imported from <code>_vendor</code>:</li> </ul> <pre><code> from ._vendor import six </code></pre> <p><strong>Brandon</strong> <strong>#6:</strong> <a href="https://supabase.io"><strong>Supabase</strong></a> <strong>and the new</strong> <a href="https://github.com/supabase/supabase-py"><strong>Python library</strong></a></p> <ul> <li>Supabase is an open source Firebase Alternative</li> <li>Postgres Database, Authentication, instant APIs, realtime subscriptions and Storage</li> <li>uses: <ul> <li><a href="https://postgrest.org/en/stable/">https://postgrest.org/en/stable/</a> for rest api access to your database</li> <li>GoTrue from Netlify for handling user authentication <a href="https://github.com/netlify/gotrue">https://github.com/netlify/gotrue</a></li> <li>Realtime client built in Elixir to listen to Postgres changes. <a href="https://github.com/supabase/realtime">https://github.com/supabase/realtime</a></li> <li>Supabase local so you don’t need internet to develop your project <a href="https://supabase.io/docs/guides/local-development">https://supabase.io/docs/guides/local-development</a></li> </ul></li> </ul> <p><strong>Extras</strong></p> <ul> <li><a href="https://simonwillison.net/2021/Jul/28/baked-data/"><strong>The Baked Data architectural pattern</strong></a> <ul> <li>Simon Willison</li> <li>“Baked Data: bundling a read-only copy of your data alongside the code for your application, as part of the same deployment”</li> </ul></li> <li><strong><a href="https://www.released.sh/">Released service - released.sh</a></strong></li> </ul> <p><strong>Joke</strong> </p> <p><a href="https://devhumor.com/media/monkeyuser-circle-of-life"><strong>The (tech) circle of life</strong></a></p>

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...