From 6f136713a46e555946a22ffb3ed49c372eea58df Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 7 Nov 2023 16:19:13 -0600 Subject: [PATCH] Install scie-pants in `~/.local/bin` instead of `~/bin` (#144) Using `~/bin` does not follow the XDG based directory spec[1] which recommends `~/.local/bin` and does not offer an `XDG_` env var alternative similar to other paths. [1] https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html * Add ~/.local/bin to PATH in CI * Update test with new path --- .github/workflows/ci.yml | 3 +++ get-pants.sh | 4 ++-- tests/test_pantsup.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4598b70..13df1a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Ensure default install path is on PATH + # Do this here so that we can change the path before updating the init-pants action. + run: echo "${HOME}/.local/bin" >> $GITHUB_PATH - name: Setup Pants uses: pantsbuild/actions/init-pants@v4-scie-pants with: diff --git a/get-pants.sh b/get-pants.sh index 56ee4f2..cae178e 100755 --- a/get-pants.sh +++ b/get-pants.sh @@ -163,7 +163,7 @@ Once installed, if you want to update your "pants" launcher binary, use -h | --help: Print this help message. -d | --bin-dir: - The directory to install the scie-pants binary in, "~/bin" by default. + The directory to install the scie-pants binary in, "~/.local/bin" by default. -b | --base-name: The name to use for the scie-pants binary, "pants" by default. @@ -176,7 +176,7 @@ Once installed, if you want to update your "pants" launcher binary, use EOF } -bin_dir="${HOME}/bin" +bin_dir="${HOME}/.local/bin" base_name="pants" version="latest/download" while (($# > 0)); do diff --git a/tests/test_pantsup.py b/tests/test_pantsup.py index 770833f..7401683 100755 --- a/tests/test_pantsup.py +++ b/tests/test_pantsup.py @@ -20,6 +20,6 @@ def test_installs_pants(tmp_path: Path) -> None: assert b"Downloading and installing the pants launcher" in proc.stderr assert b"Installed the pants launcher from" in proc.stderr - bin_path = tmp_path / "bin" / "pants" + bin_path = tmp_path / ".local" / "bin" / "pants" assert os.path.isfile(bin_path) assert os.access(bin_path, os.X_OK)