From 3dc283fcb608c880e2f174486d2bad5091427dd9 Mon Sep 17 00:00:00 2001 From: Brendon Smith Date: Mon, 18 Oct 2021 21:22:47 -0400 Subject: [PATCH] Install Poetry with `pipx` and unset `POETRY_HOME` br3ndonland/dotfiles@1d8eee0 br3ndonland/dotfiles@884d475 Poetry has a new install script, install-poetry.py, which alters the requirements for adding Poetry to `$PATH`. `$HOME/.local/bin` was already on `$PATH` for pipx, so it seemed like a good option. Commits 1d8eee0 and 884d475 updated `.zshrc` and `script/strap-after-setup` for install-poetry.py and `POETRY_HOME=$HOME/.local`. This made sense initially, because Poetry installs its binaries into `$POETRY_HOME/bin`, and because Poetry doesn't have a `$POETRY_BIN_DIR` configuration variable like pipx does (`$PIPX_BIN_DIR`). Unfortunately, `POETRY_HOME=$HOME/.local` ended up being problematic, because Poetry takes over `$POETRY_HOME`, and doesn't consider other applications installed there. For example, if the get-poetry.py or install-poetry.py scripts were used to install Poetry, they can also be used to uninstall Poetry. Uninstalling with `python install-poetry.py --uninstall` or `python get-poetry.py --uninstall` deletes the entire `$POETRY_HOME` directory, which means it deletes `$HOME/.local`, causing problems for other applications that use `$HOME/.local` (python-poetry/poetry#4625). There have been many other issues with the Poetry custom install scripts get-poetry.py and install-poetry.py (br3ndonland/inboard#36), so other installation methods are be welcome. Poetry is now available through Homebrew, but Homebrew installation is not supported by the Poetry maintainers. Homebrew installation also requires its own custom install script, which creates its own issues. python-poetry/poetry#941 python-poetry/poetry#1765 Homebrew/homebrew-core#48883 Homebrew/homebrew-core#86776 pipx (https://pypa.github.io/pipx/) can also be used to install Poetry. The pipx installation method is suggested in the Poetry docs and GitHub, and pipx is already in use in this repo. python-poetry/poetry#677 python-poetry/poetry#3360 This commit will remove `export POETRY_HOME=$HOME/.local` from `.zshrc`, and will install Poetry with pipx. --- .zshrc | 1 - script/strap-after-setup | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.zshrc b/.zshrc index 6d2ed432..fe510448 100644 --- a/.zshrc +++ b/.zshrc @@ -53,7 +53,6 @@ fi TTY=$(tty) export GPG_TTY=$TTY export PATH=$HOME/.local/bin:$PATH -export POETRY_HOME=$HOME/.local ### aliases alias python='python3' diff --git a/script/strap-after-setup b/script/strap-after-setup index f52ea8eb..56199867 100755 --- a/script/strap-after-setup +++ b/script/strap-after-setup @@ -3,7 +3,6 @@ # Run by run_dotfile_scripts in bootstrap.sh # Scripts must be executable (chmod +x) echo "-> Running strap-after-setup. Some steps may require password entry." -RAW="https://raw.githubusercontent.com" ### Configure macOS if [ "${MACOS:-0}" -gt 0 ] || [ "$(uname)" = "Darwin" ]; then @@ -12,12 +11,9 @@ else echo "Not macOS. Skipping macos.sh." fi -### Install user Python packages -if command -v python3 &>/dev/null && ! command -v poetry &>/dev/null; then - export POETRY_HOME="$HOME/.local" - curl -fsS -o "$HOME/install-poetry.py" \ - $RAW/python-poetry/poetry/HEAD/install-poetry.py - python3 "$HOME/install-poetry.py" +### Install Poetry +if command -v pipx &>/dev/null && ! command -v poetry &>/dev/null; then + pipx install poetry else echo "Skipping Poetry install." fi