-
Notifications
You must be signed in to change notification settings - Fork 82
fix(deps-dev): Ensure user-scoped pipx
installs and reliable version checks for pipx
packages.
#1320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(deps-dev): Ensure user-scoped pipx
installs and reliable version checks for pipx
packages.
#1320
Changes from all commits
e6817d8
1701f05
896a9c4
12fc072
24adfec
84c01bf
22ec79e
59de3b0
611596a
ac5ec93
d547a7c
6bea8cf
7523533
4640164
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
if ! command -v pipx >/dev/null 2>&1; then | ||
echo "Error: pipx not found." | ||
exit 1 | ||
fi | ||
|
||
if ! command -v jq >/dev/null 2>&1; then | ||
echo "Error: jq not found." | ||
exit 1 | ||
fi | ||
|
||
if [ "$#" -ne 2 ] || [ -z "${1:-}" ] || [ -z "${2:-}" ]; then | ||
echo "Usage: $0 <package_name> <binary_name>" >&2 | ||
exit 2 | ||
fi | ||
|
||
pkg="$1" | ||
app="$2" | ||
|
||
pipx list --json | jq --raw-output --arg pkg "$pkg" --arg app "$app" ' | ||
.venvs[$pkg].metadata.main_package.app_paths[]?.__Path__ | ||
| select((split("/") | last) == $app) | ||
' | head -n1 |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,18 +15,24 @@ readonly required_version_min="${required_version_major_min}.${required_version_ | |||||||||||||||||||||||||||
readonly required_version_major_max=3 | ||||||||||||||||||||||||||||
readonly required_version_major_max_plus_1=$((required_version_major_max + 1)) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
package_preinstalled=0 | ||||||||||||||||||||||||||||
if ! command -v cmake >/dev/null 2>&1; then | ||||||||||||||||||||||||||||
cmake_bin="$(command -v cmake 2>/dev/null || true)" | ||||||||||||||||||||||||||||
if [ -n "${cmake_bin}" ]; then | ||||||||||||||||||||||||||||
package_preinstalled=0 | ||||||||||||||||||||||||||||
echo "Preinstalled CMake found at: ${cmake_bin}" | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
package_preinstalled=1 | ||||||||||||||||||||||||||||
# ystdlib requires CMake v3.23; ANTLR and yaml-cpp do not yet support CMake v4+ | ||||||||||||||||||||||||||||
# (see https://github.com/y-scope/clp/issues/795). | ||||||||||||||||||||||||||||
pipx install --force "cmake>=${required_version_min},<${required_version_major_max_plus_1}" | ||||||||||||||||||||||||||||
pipx ensurepath | ||||||||||||||||||||||||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||||||||||||||||||||||||||||
cmake_bin=$("${script_dir}/find-pipx-bin.sh" cmake cmake) | ||||||||||||||||||||||||||||
echo "Pipx CMake installed at: ${cmake_bin}" | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
Comment on lines
+28
to
31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate resolved cmake_bin after pipx install. If the helper fails to locate the binary, subsequent invocations will crash obscurely. - script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
- cmake_bin=$("${script_dir}/find-pipx-bin.sh" cmake cmake)
- echo "Pipx CMake installed at: ${cmake_bin}"
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
+ cmake_bin=$("${script_dir}/find-pipx-bin.sh" cmake cmake)
+ if [ -z "${cmake_bin}" ] || [ ! -x "${cmake_bin}" ]; then
+ echo "Error: could not resolve CMake binary after pipx install." >&2
+ echo " Try: pipx uninstall cmake && pipx install 'cmake>=${required_version_min},<${required_version_major_max_plus_1}'" >&2
+ exit 1
+ fi
+ echo "Pipx CMake installed at: ${cmake_bin}" 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
installed_version=$(cmake -E capabilities | jq --raw-output ".version.string") | ||||||||||||||||||||||||||||
installed_version_major=$(cmake -E capabilities | jq --raw-output ".version.major") | ||||||||||||||||||||||||||||
installed_version_minor=$(cmake -E capabilities | jq --raw-output ".version.minor") | ||||||||||||||||||||||||||||
installed_version=$("${cmake_bin}" -E capabilities | jq --raw-output ".version.string") | ||||||||||||||||||||||||||||
installed_version_major=$("${cmake_bin}" -E capabilities | jq --raw-output ".version.major") | ||||||||||||||||||||||||||||
installed_version_minor=$("${cmake_bin}" -E capabilities | jq --raw-output ".version.minor") | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ystdlib requires CMake v3.23; ANTLR and yaml-cpp do not yet support CMake v4+ | ||||||||||||||||||||||||||||
# (see https://github.com/y-scope/clp/issues/795). | ||||||||||||||||||||||||||||
|
@@ -47,3 +53,5 @@ if (("${installed_version_major}" < "${required_version_major_min}")) \ | |||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
echo "CMake version ${installed_version} installed at ${cmake_bin} satisfies version requirements." |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,17 +12,23 @@ fi | |||||||||||||
# We lock to version 3.44.0 to avoid https://github.com/y-scope/clp/issues/1352 | ||||||||||||||
readonly required_version="3.44.0" | ||||||||||||||
|
||||||||||||||
package_preinstalled=0 | ||||||||||||||
if ! command -v task >/dev/null 2>&1; then | ||||||||||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||||||||||||||
|
||||||||||||||
go_task_bin="$(command -v task 2>/dev/null || true)" | ||||||||||||||
if [ -n "${go_task_bin}" ]; then | ||||||||||||||
package_preinstalled=0 | ||||||||||||||
echo "Preinstalled Task found at: ${go_task_bin}" | ||||||||||||||
else | ||||||||||||||
package_preinstalled=1 | ||||||||||||||
pipx install --force "go-task-bin==${required_version}" | ||||||||||||||
pipx ensurepath | ||||||||||||||
go_task_bin=$("${script_dir}/find-pipx-bin.sh" go-task-bin task) | ||||||||||||||
echo "Pipx Task installed at: ${go_task_bin}" | ||||||||||||||
fi | ||||||||||||||
Comment on lines
+25
to
27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate resolved Task binary after pipx install. Harden against a missing/incorrectly resolved path before using it. - go_task_bin=$("${script_dir}/find-pipx-bin.sh" go-task-bin task)
- echo "Pipx Task installed at: ${go_task_bin}"
+ go_task_bin=$("${script_dir}/find-pipx-bin.sh" go-task-bin task)
+ if [ -z "${go_task_bin}" ] || [ ! -x "${go_task_bin}" ]; then
+ echo "Error: could not resolve Task binary after pipx install." >&2
+ echo " Try: pipx uninstall go-task-bin && pipx install 'go-task-bin==${required_version}'" >&2
+ exit 1
+ fi
+ echo "Pipx Task installed at: ${go_task_bin}" 🤖 Prompt for AI Agents
|
||||||||||||||
|
||||||||||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||||||||||||||
task_version=$(task --silent --taskfile "${script_dir}/print-go-task-version.yaml") | ||||||||||||||
if [[ "${task_version}" != "${required_version}" ]]; then | ||||||||||||||
echo "Error: Task version ${task_version} is currently unsupported (must be" \ | ||||||||||||||
installed_version=$(${go_task_bin} --silent --taskfile "${script_dir}/print-go-task-version.yaml") | ||||||||||||||
if [[ "${installed_version}" != "${required_version}" ]]; then | ||||||||||||||
echo "Error: Task version ${installed_version} is currently unsupported (must be" \ | ||||||||||||||
Comment on lines
+29
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quote the resolved binary when invoking. Prevents breakage if the path contains spaces. -installed_version=$(${go_task_bin} --silent --taskfile "${script_dir}/print-go-task-version.yaml")
+installed_version=$("${go_task_bin}" --silent --taskfile "${script_dir}/print-go-task-version.yaml") 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
"${required_version})." | ||||||||||||||
|
||||||||||||||
if ((0 == "${package_preinstalled}")); then | ||||||||||||||
|
@@ -35,3 +41,5 @@ if [[ "${task_version}" != "${required_version}" ]]; then | |||||||||||||
|
||||||||||||||
exit 1 | ||||||||||||||
fi | ||||||||||||||
|
||||||||||||||
echo "Task version ${installed_version} installed at ${go_task_bin} satisfies version requirements." |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,14 +13,20 @@ readonly required_version_major_min=0 | |||||||||||||||||||||||||||
readonly required_version_minor_min=8 | ||||||||||||||||||||||||||||
readonly required_version_min="${required_version_major_min}.${required_version_minor_min}" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
package_preinstalled=0 | ||||||||||||||||||||||||||||
if ! command -v uv >/dev/null 2>&1; then | ||||||||||||||||||||||||||||
uv_bin="$(command -v uv 2>/dev/null || true)" | ||||||||||||||||||||||||||||
if [ -n "${uv_bin}" ]; then | ||||||||||||||||||||||||||||
package_preinstalled=0 | ||||||||||||||||||||||||||||
echo "Preinstalled uv found at: ${uv_bin}" | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
package_preinstalled=1 | ||||||||||||||||||||||||||||
pipx install --force "uv>=${required_version_min}" | ||||||||||||||||||||||||||||
pipx ensurepath | ||||||||||||||||||||||||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||||||||||||||||||||||||||||
uv_bin=$("${script_dir}/find-pipx-bin.sh" uv uv) | ||||||||||||||||||||||||||||
echo "Pipx uv installed at: ${uv_bin}" | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
Comment on lines
+24
to
27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate resolved uv binary after pipx install. Avoids opaque failures when uv_bin isn’t found. - script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
- uv_bin=$("${script_dir}/find-pipx-bin.sh" uv uv)
- echo "Pipx uv installed at: ${uv_bin}"
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
+ uv_bin=$("${script_dir}/find-pipx-bin.sh" uv uv)
+ if [ -z "${uv_bin}" ] || [ ! -x "${uv_bin}" ]; then
+ echo "Error: could not resolve uv binary after pipx install." >&2
+ echo " Try: pipx uninstall uv && pipx install 'uv>=${required_version_min}'" >&2
+ exit 1
+ fi
+ echo "Pipx uv installed at: ${uv_bin}" 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
installed_version=$(uv self version --output-format json | jq --raw-output ".version") | ||||||||||||||||||||||||||||
installed_version=$(${uv_bin} self version --output-format json | jq --raw-output ".version") | ||||||||||||||||||||||||||||
IFS=. read -r installd_version_major installed_version_minor _ <<<"${installed_version}" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (("${installd_version_major}" == "${required_version_major_min}" && \ | ||||||||||||||||||||||||||||
|
@@ -38,3 +44,5 @@ if (("${installd_version_major}" == "${required_version_major_min}" && \ | |||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
echo "uv version ${installed_version} installed at ${uv_bin} satisfies version requirements." |
Uh oh!
There was an error while loading. Please reload this page.