Skip to content

Commit 3f77dbd

Browse files
committed
feat: add debounce and system site packages to Python setup
- Implements debounce mechanism to prevent rapid script execution - Ensures system site packages are included in virtual environments - Simplifies mise configuration by removing conditional tool declarations
1 parent e6c6e24 commit 3f77dbd

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

template/.config/copier/mise/scripts/setup-python.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
# This file is @generated by <https://github.com/liblaf/copier-python>.
33
# DO NOT EDIT!
44

5+
if [[ -n ${__USAGE-} ]]; then
6+
# skip when in shell completions
7+
return
8+
fi
9+
10+
DEBOUNCE_FILE="${DEBOUNCE_FILE:-"/tmp/debounce"}"
11+
DEBOUNCE_INTERVAL="${DEBOUNCE_INTERVAL:-"1"}"
12+
if [[ -f ${DEBOUNCE_FILE} ]]; then
13+
last_exec_time="$(< "${DEBOUNCE_FILE}")"
14+
current_time="$(date +%s)"
15+
if ((current_time - last_exec_time < DEBOUNCE_INTERVAL)); then
16+
return
17+
fi
18+
fi
19+
date "+%s" > "${DEBOUNCE_FILE}"
20+
521
if [[ -f "pixi.lock" ]]; then
622
args=()
723
if [[ -t 2 ]]; then args+=(--color=always); fi
@@ -10,6 +26,8 @@ fi
1026

1127
if [[ -f "uv.lock" ]]; then
1228
uv sync --all-extras --all-groups
29+
# shellcheck disable=SC2016
30+
sd '^(\s*)?(?P<key>include-system-site-packages)(\s*)?=(\s*)?(?<val>.*)$' '$key = true' ".venv/pyvenv.cfg"
1331
# shellcheck disable=SC1091
1432
source ".venv/bin/activate"
1533
fi

template/.config/mise/conf.d/00-python.toml.jinja

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
# This file is @generated by <https://github.com/liblaf/copier-python>.
44
# DO NOT EDIT!
55

6-
[[env]]
6+
[env]
77
_.source = { path = ".config/copier/mise/scripts/setup-python.sh", tools = true }
88

99
[settings]
1010
jobs = 1
1111

1212
[tools]
13-
ruff = "latest"
14-
# {%- if package_manager == "pixi" %}
1513
pixi = "latest"
16-
# {%- elif package_manager == "uv" %}
14+
ruff = "latest"
1715
uv = "latest"
18-
# {%- endif %}

0 commit comments

Comments
 (0)