Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

#244: vendorizing your Python podcast

Published Fri, Jul 30, 2021, recorded Fri, Jul 30, 2021

Watch the live stream:

Watch this episode on YouTube
Play on YouTube
Watch the live stream replay

About the show

Sponsored by us:

Special guest: Brandon Braner

Brian #1: pip Environmental Variables

  • The problem with snakes on a plane → no internet
  • Situation:
    • want to work on some code on a plane
    • project set up to use tox, which creates venvs, and pip installs dependencies from pypi.org.
    • but… no internet
  • Preflight work:
    • run tox with an internet connection
    • copy everything from all of the “site-packages” directories under “.tox” into a “wheels” directory or whatever you want to call it.
    • set environmental variables:
    • PIP_FIND_LINKS=file:/Users/okken/wheels
    • PIP_NO_INDEX=1
    • Try this out first BEFORE getting on the plane, to make sure you didn’t miss anything.
  • In flight:
    • tox works fine now, using local dir as index
  • Thanks Paul Ganssle for helping with this.
  • All command line flags for pip are available as env variables:
    • “pip’s command line options can be set with environment variables using the format PIP_[HTML_REMOVED] . Dashes (-) have to be replaced with underscores (_).”

Michael #2: Extra, Extra, 6x Extra, hear all about it

Brandon #3: Kaggle 30 Days of Machine Learning

  • What is Kaggle
    1. Find and publish data sets
    2. Explore and build models in a web-based data-science environment(Jupyter Notebooks)
    3. Work with other data scientists and machine learning engineers
    4. Enter competitions to solve data science challenges.
  • Starts August 2nd, 2021
  • Has an introduction to Python and covers basic and intermediate machine learning concepts
  • Get some completion certificates
  • Kaggle competition at the end with teams of 3

Brian #4: Building and testing Python with GitHub Actions

  • GitHub Docs
  • This is an incredible resource
  • I suggest starting with Running tests with tox, as it’s a super simple setup.
  • And, you can test all of the tox environments locally.
        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: ${{ matrix.python }}
              - name: Install Tox and any other packages
                run: pip install tox
              - name: Run Tox
                run: tox -e py
    

Michael #5: python-vendorize

  • via Patrick Park
  • Vendoring a dependency means basically copying it into your package or your app rather than installing and importing it externally.
  • Here’s a simple way to do that.
  • python-vendorize allows pure-Python dependencies to be vendorized
  • vendorize.toml might look something like:

        target = "your_app/_vendor"
        packages = [
            "six",
        ]
    
  • run python-vendorize in the same directory as vendorize.toml

  • In your_app.py, six can be imported from _vendor:
        from ._vendor import six
    

Brandon #6: Supabase and the new Python library

Extras

Joke

The (tech) circle of life


Want to go deeper? Check our projects