Update setup command

This commit is contained in:
2026-04-17 00:54:42 -04:00
parent fc277760af
commit 2478ce5bae
4 changed files with 44 additions and 9 deletions
+4
View File
@@ -0,0 +1,4 @@
.env
.env.*
.venv/
.vscode/
-3
View File
@@ -1,7 +1,4 @@
{
"extraPaths": [
"/Applications/SageMath-10-8.app/Contents/Frameworks/Sage.framework/Versions/10.8/local/lib/python3.13/site-packages"
],
"reportUnknownMemberType": "warning",
"reportUnknownArgumentType": "warning",
"reportUnknownParameterType": "warning",
+2
View File
@@ -0,0 +1,2 @@
pylint
pyright
+38 -6
View File
@@ -2,10 +2,13 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PYTHON_PATH="/Applications/SageMath-10-8.app/Contents/Frameworks/Sage.framework/Versions/10.8/local/bin/python3"
SAGE_SITE_PACKAGES="/Applications/SageMath-10-8.app/Contents/Frameworks/Sage.framework/Versions/10.8/local/lib/python3.13/site-packages"
VENV_PYTHON="$SCRIPT_DIR/.venv/bin/python3"
if [ -f "$SCRIPT_DIR/.env" ]; then
# shellcheck source=/dev/null
source "$SCRIPT_DIR/.env"
fi
init_paper() {
local raw="${1:-.}"
local name
@@ -20,12 +23,40 @@ init_paper() {
}
setup() {
"$PYTHON_PATH" -m venv "$SCRIPT_DIR/.venv"
"$VENV_PYTHON" -m pip install pylint
local python_path="${1:?Usage: setup <python_path> <sage_site_packages> <system_name>}"
local sage_site_packages="${2:?Usage: setup <python_path> <sage_site_packages> <system_name>}"
local system_name="${3:?Usage: setup <python_path> <sage_site_packages> <system_name>}"
printf 'SAGE_PYTHON_PATH=%s\nSAGE_SITE_PACKAGES=%s\n' "$python_path" "$sage_site_packages" \
> "$SCRIPT_DIR/.env.$system_name"
ln -sf ".env.$system_name" "$SCRIPT_DIR/.env"
source "$SCRIPT_DIR/.env"
mkdir -p "$SCRIPT_DIR/.vscode"
"$python_path" - <<EOF
import json
settings = {
"python.defaultInterpreterPath": "$python_path",
"python.analysis.extraPaths": ["$sage_site_packages"],
"python.analysis.diagnosticSeverityOverrides": {
"reportUnknownMemberType": "warning",
"reportUnknownArgumentType": "warning",
"reportUnknownParameterType": "warning",
"reportMissingParameterType": "warning",
"reportUnknownVariableType": "warning"
}
}
with open("$SCRIPT_DIR/.vscode/settings.json", "w") as f:
json.dump(settings, f, indent=4)
f.write("\n")
EOF
"$python_path" -m venv "$SCRIPT_DIR/.venv"
"$VENV_PYTHON" -m pip install -r "$SCRIPT_DIR/requirements.txt"
}
lint() {
npx pyright lib/ --pythonpath "$PYTHON_PATH"
"$VENV_PYTHON" -m pyright lib/ --pythonpath "$SAGE_PYTHON_PATH"
"$VENV_PYTHON" -m pylint lib/ \
--init-hook="import sys; sys.path.insert(0, '${SAGE_SITE_PACKAGES}'); sys.path.insert(0, '${SCRIPT_DIR}')" \
--disable=fixme
@@ -37,7 +68,8 @@ init_paper)
init_paper "$@"
;;
setup)
setup
shift
setup "$@"
;;
lint)
lint