Skip to content

Instantly share code, notes, and snippets.

@skyzyx
Created November 7, 2024 23:45
Show Gist options
  • Save skyzyx/e3923ecd8400de93b7d320888644f6b1 to your computer and use it in GitHub Desktop.
Save skyzyx/e3923ecd8400de93b7d320888644f6b1 to your computer and use it in GitHub Desktop.
Installing Tinfoil "nut" on macOS

Installing Tinfoil "nut" on macOS

Prerequisites

Installation (first-time only)

  1. Install some core dependencies.

    brew install curl libusb openssl@3 [email protected]
    brew link curl --force
    export PATH="$(brew --prefix curl)/bin:${PATH}"
  2. Create a Python virtual environment and activate it. This will ensure everything is self-contained.

    python3.9 -m venv .venv
    source .venv/bin/activate
    pip install --upgrade pip wheel

    When you're inside of this activated virtual environment, python refers to the correct version of Python (3.9) and pip is connected to this one Python installation.

  3. Edit requirements.txt to remove the version constraints on pycurl.

    - pycurl~=7.44.1; sys_platform != 'win32'
    + pycurl; sys_platform != 'win32'
  4. We will install dependencies from requirements.txt, but this will involve compiling a custom build of pycurl with OpenSSL. Just copy-paste and run the whole block below.

    PYCURL_SSL_LIBRARY=openssl \
    LDFLAGS="-L$(brew --prefix openssl@3)/lib" \
    CPPFLAGS="-I$(brew --prefix openssl@3)/include" \
    pip install --no-cache-dir --compile --ignore-installed -r requirements.txt
  5. Run the application.

    python gui_nut.py

Cleaning up your session

When you're done, you may choose to clean-up some things.

  1. Running deactivate (or simply closing/quitting your terminal) will exit the Python virtual environment.

  2. Closing/quitting your terminal will revert the update to $PATH we did up at the top.

  3. Switch back to the built-in macOS curl by default.

    brew unlink curl

Re-entering the Python virtual environment

Once you've exited and cleaned-up (below) your Python virtual environment, but you choose to re-enter your Python virtual environment, then do:

  1. Configure dependencies.

    brew link curl --force
    export PATH="$(brew --prefix curl)/bin:${PATH}"
  2. Re-activate the Python virtual environment.

    source .venv/bin/activate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment