install: refuse runner worktrees and bind the CLI Python.
Keep editable installs on the canonical checkout so PATH mytoolkit cannot silently pick up a stale GHA _work tree.
This commit is contained in:
@@ -144,10 +144,20 @@ mytoolkit init journal springer mydir
|
|||||||
|
|
||||||
项目使用 `uv` 管理依赖。修改 `pyproject.toml` 后运行 `uv sync` 同步。
|
项目使用 `uv` 管理依赖。修改 `pyproject.toml` 后运行 `uv sync` 同步。
|
||||||
|
|
||||||
|
### 本机安装(防串源)
|
||||||
|
|
||||||
|
真源检出:`~/Documents/myBin/mytoolkit`(远程 `apaam/mytoolkit`)。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
uv sync
|
cd ~/Documents/myBin/mytoolkit && make install
|
||||||
|
python3 -m pip show mytoolkit | grep Editable
|
||||||
|
# 必须是 .../Documents/myBin/mytoolkit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- **禁止**在 `~/.xiaohe/actions-runner/_work/...` 或任意 GHA worktree 里 `pip install -e`
|
||||||
|
- **禁止**把 `xiaohe-agent/packages/mytoolkit` submodule 当开发树安装(那只是 pin)
|
||||||
|
- `make install` 会拒绝上述路径,并装进 PATH 上 `mytoolkit` 所用的 Python
|
||||||
|
|
||||||
### 测试
|
### 测试
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -1,21 +1,44 @@
|
|||||||
ROOT_DIR := $(shell pwd)
|
ROOT_DIR := $(shell pwd)
|
||||||
PYTHON ?= python3
|
# Prefer an explicit PYTHON=; else the interpreter behind `mytoolkit` on PATH;
|
||||||
|
# else python3. Never silently install into a different Python than the CLI.
|
||||||
|
CLI_BIN := $(shell command -v mytoolkit 2>/dev/null)
|
||||||
|
CLI_PY := $(if $(CLI_BIN),$(shell head -1 "$(CLI_BIN)" 2>/dev/null | sed 's|^#!||'),)
|
||||||
|
PYTHON ?= $(if $(CLI_PY),$(CLI_PY),python3)
|
||||||
|
|
||||||
.PHONY: help install uninstall sync-skill test
|
.PHONY: help install uninstall sync-skill test
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Usage: make [target]"
|
@echo "Usage: make [target]"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo " install Install mytoolkit in editable mode (current Python) and sync skill"
|
@echo " install Editable install into CLI Python + sync skill"
|
||||||
|
@echo " (refuse runner/_work trees; PYTHON=$(PYTHON))"
|
||||||
@echo " sync-skill Copy the bundled agent skill to ~/.agents/skills/mytoolkit/"
|
@echo " sync-skill Copy the bundled agent skill to ~/.agents/skills/mytoolkit/"
|
||||||
@echo " test Run the pytest suite"
|
@echo " test Run the pytest suite"
|
||||||
@echo " uninstall Uninstall mytoolkit and remove shell completions"
|
@echo " uninstall Uninstall mytoolkit and remove shell completions"
|
||||||
|
|
||||||
|
# Canonical checkout: ~/Documents/myBin/mytoolkit (apaam/mytoolkit).
|
||||||
|
# Do NOT `pip install -e` from GHA _work or xiaohe packages/ submodule.
|
||||||
install:
|
install:
|
||||||
|
@case "$(ROOT_DIR)" in \
|
||||||
|
*/_work/*|*/actions-runner/*|*/.xiaohe/actions-runner/*) \
|
||||||
|
echo "ERROR: refuse install from runner/worktree: $(ROOT_DIR)" >&2; \
|
||||||
|
echo "Use: cd ~/Documents/myBin/mytoolkit && make install" >&2; \
|
||||||
|
exit 1 ;; \
|
||||||
|
esac
|
||||||
|
@echo "Installing editable mytoolkit"
|
||||||
|
@echo " ROOT=$(ROOT_DIR)"
|
||||||
|
@echo " PYTHON=$(PYTHON)"
|
||||||
$(PYTHON) -m pip install -e "$(ROOT_DIR)" --upgrade
|
$(PYTHON) -m pip install -e "$(ROOT_DIR)" --upgrade
|
||||||
@echo "Installing shell completions…"
|
@echo "Installing shell completions…"
|
||||||
@mytoolkit completion install || echo "Warning: completion install failed"
|
@mytoolkit completion install || echo "Warning: completion install failed"
|
||||||
@$(MAKE) -s sync-skill
|
@$(MAKE) -s sync-skill
|
||||||
|
@echo "Editable install:"
|
||||||
|
@$(PYTHON) -m pip show mytoolkit | awk '/^(Name|Version|Location|Editable project location):/'
|
||||||
|
@ed="$$($(PYTHON) -m pip show mytoolkit | awk -F': ' '/Editable project location:/ {print $$2}')"; \
|
||||||
|
case "$$ed" in \
|
||||||
|
*/_work/*|*/actions-runner/*) \
|
||||||
|
echo "ERROR: Editable still points at runner tree: $$ed" >&2; exit 1 ;; \
|
||||||
|
esac
|
||||||
|
|
||||||
sync-skill:
|
sync-skill:
|
||||||
@echo "Syncing agent skill to ~/.agents/skills/mytoolkit/ ..."
|
@echo "Syncing agent skill to ~/.agents/skills/mytoolkit/ ..."
|
||||||
|
|||||||
Reference in New Issue
Block a user