Skip to content

Commit

Permalink
chore: add Hermit Python
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Jun 26, 2024
1 parent 05c5e79 commit 85f14d8
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/.python3-3.12.3.pkg
7 changes: 7 additions & 0 deletions bin/README.hermit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hermit environment

This is a [Hermit](https://github.com/cashapp/hermit) bin directory.

The symlinks in this directory are managed by Hermit and will automatically
download and install Hermit itself as well as packages. These packages are
local to this environment.
21 changes: 21 additions & 0 deletions bin/activate-hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This file must be used with "source bin/activate-hermit" from bash or zsh.
# You cannot run it directly
#
# THIS FILE IS GENERATED; DO NOT MODIFY

if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")"
if "${BIN_DIR}/hermit" noop > /dev/null; then
eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")"

if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then
hash -r 2>/dev/null
fi

echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated"
fi
43 changes: 43 additions & 0 deletions bin/hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
# THIS FILE IS GENERATED; DO NOT MODIFY

set -eo pipefail

export HERMIT_USER_HOME=~

if [ -z "${HERMIT_STATE_DIR}" ]; then
case "$(uname -s)" in
Darwin)
export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit"
;;
Linux)
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit"
;;
esac

This comment has been minimized.

Copy link
@ds-cbo

ds-cbo Jul 2, 2024

Contributor

Wouldn't you want to exit on other systems? Now it'll try writing to /pkg/hermit@stable/hermit on for example FreeBSD, which is a pretty bad idea imho. In general I'm a bit sceptical of these "oh we'll just curl a script from github and execute that" tools because I'm yet to find one that works well cross-platform. Distro maintainers often seem to know better than specific project maintainers when it comes down to installing something.

Sour complaining aside to make room for genuine curiosity: What led you to include hermit for voluptuous? I thought it was a pure python library without dependencies, so that pip install -e . was all you needed. To me hermit seems more like a maintenance burden than a relief, but I might be overlooking something.

@alecthomas (I'm not sure if you receive notifications without tag)

This comment has been minimized.

Copy link
@alecthomas

alecthomas Jul 2, 2024

Author Owner

Hermit only supports Linux and Darwin, though the script should exit for other platforms. Hermit is self-bootstrapping, so distro packages aren't relevant.

Hermit manages the Python toolchain itself, similar to Nix or asdf, and there's no "burden", it's entirely optional. I use Hermit basically everywhere and it's a massive benefit to me.

fi

export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}"
HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")"
export HERMIT_CHANNEL
export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit}

if [ ! -x "${HERMIT_EXE}" ]; then
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
INSTALL_SCRIPT="$(mktemp)"
# This value must match that of the install script
INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38"
if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then
curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}"
else
# Install script is versioned by its sha256sum value
curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}"
# Verify install script's sha256sum
openssl dgst -sha256 "${INSTALL_SCRIPT}" | \
awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \
'$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}'
fi
/bin/bash "${INSTALL_SCRIPT}" 1>&2
fi

exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
Empty file added bin/hermit.hcl
Empty file.
1 change: 1 addition & 0 deletions bin/pip
1 change: 1 addition & 0 deletions bin/pip3
1 change: 1 addition & 0 deletions bin/pip3.12
1 change: 1 addition & 0 deletions bin/pydoc3
1 change: 1 addition & 0 deletions bin/pydoc3.12
1 change: 1 addition & 0 deletions bin/python
1 change: 1 addition & 0 deletions bin/python3
1 change: 1 addition & 0 deletions bin/python3-config
1 change: 1 addition & 0 deletions bin/python3.12
1 change: 1 addition & 0 deletions bin/python3.12-config

0 comments on commit 85f14d8

Please sign in to comment.