pythonmacoshomebrewpython-poetry

Why is not recommended to install poetry with homebrew?


Poetry official documentation strictly recommends sticking with the official installer. However, homebrew has poetry formulae.

brew install poetry

Usually, I like to keep everything I can in homebrew to manage installations easily.

What is the drawback and risks of installing poetry using homebrew instead of the recommended installation script?


Solution

  • The drawback is that poetry will be unable to upgrade itself (I've no idea what'd actually happen), and you'll not be able to install specific poetry versions. Homebrew installed poetry will probably also use the Homebrew-installed Python environment, etc, instead of having its own isolated venv to execute from.

    If you use homebrew to install poetry, don't try to manage that installation any way outside of homebrew. Otherwise, it's probably fine.

    Other misc drawbacks include:

    • Can't control specific Python version used to run Poetry (want to get the latest core Python speedups!)
    • Uncertain support and management of poetry plugins (part of "managing the installation")
    • Can't run multiple poetry versions side-by-side

    edit

    My personal recommendation is to install pipx using homebrew, and then install poetry via pipx:

    brew install pipx
    pipx ensurepath
    pipx install poetry  # latest version
    pipx install poetry==1.2.2 [email protected]
    pipx install poetry==1.3.2 [email protected]
    pipx install poetry==1.6.1 [email protected]
    

    so you'll get something like:

    ❯ pipx list
    venvs are in /Users/redacted/.local/pipx/venvs
    apps are exposed on your $PATH at /Users/redacted/Code/dotfiles/bin
       package hatch 1.7.0, installed using Python 3.11.5
        - hatch
       package poetry 1.2.2, installed using Python 3.11.5
        - poetry
       package poetry 1.3.2 ([email protected]), installed using Python 3.11.5
        - [email protected]
       package poetry 1.6.1 ([email protected]), installed using Python 3.11.5
        - [email protected]
    ❯ poetry --version
    Poetry (version 1.2.2)
    ❯ [email protected] --version
    Poetry (version 1.3.2)
    

    e.g. via:

    brew install pipx
    pipx ensurepath
    pipx install poetry  # latest version
    pipx install poetry==1.2.2 [email protected]
    pipx install poetry==1.3.2 [email protected]
    pipx install poetry==1.6.1 [email protected]
    

    Poetry is still under very active development, and its API is not very stable. This gives me full control of what version to use/when, e.g. across different projects.