From d2ca9cccb7907c683517e79490295c20a7c98512 Mon Sep 17 00:00:00 2001 From: ineskhou Date: Mon, 3 Nov 2025 10:31:48 -0800 Subject: [PATCH 1/6] Added Ground station updates, also fixed linux hanging problem --- Makefile | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 71f7b8c..45357f1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ PYSQUARED_VERSION ?= copilot/fix-7bfb9c49-466e-42db-a6be-dece956d6d8c PYSQUARED ?= git+https://github.com/proveskit/pysquared@$(PYSQUARED_VERSION)\#subdirectory=circuitpython-workspaces/flight-software +PYSQUARED_GS ?= git+https://github.com/proveskit/pysquared@$(PYSQUARED_VERSION)\#subdirectory=circuitpython-workspaces/ground-station BOARD_MOUNT_POINT ?= "" BOARD_TTY_PORT ?= "" VERSION ?= $(shell git tag --points-at HEAD --sort=-creatordate < /dev/null | head -n 1) @@ -30,11 +31,40 @@ download-libraries: download-libraries-flight-software download-libraries-ground .PHONY: download-libraries-% download-libraries-%: uv .venv ## Download the required libraries @echo "Downloading libraries for $*..." - @$(UV) pip install --requirement src/$*/lib/requirements.txt --target src/$*/lib --no-deps --upgrade --quiet - @$(UV) pip --no-cache install $(PYSQUARED) --target src/$*/lib --no-deps --upgrade --quiet + @echo " Cleaning old packages (keeping requirements.txt and local dirs)..." + @find src/$*/lib -mindepth 1 -maxdepth 1 ! -name 'requirements.txt' ! -name 'proveskit_*' -exec rm -rf {} + 2>/dev/null || true + @rm -rf src/$*/lib/*.dist-info src/$*/lib/.lock + @mkdir -p src/$*/lib + @TMP_INSTALL_DIR=$$(mktemp -d); \ + trap "rm -rf $$TMP_INSTALL_DIR" EXIT INT TERM; \ + echo " Installing requirements from src/$*/lib/requirements.txt..."; \ + echo " Note: Git dependencies may take 10-30 seconds each to clone and build..."; \ + set -e; \ + while IFS= read -r line || [ -n "$$line" ]; do \ + if [ -n "$$line" ] && [ "$${line#\#}" = "$$line" ]; then \ + echo " Installing: $$line"; \ + echo " (Please wait, this may take time for Git repos...)"; \ + rm -rf "$$TMP_INSTALL_DIR"/*; \ + $(UV) pip install "$$line" --target "$$TMP_INSTALL_DIR" --no-deps --no-cache-dir --upgrade || exit 1; \ + cp -r "$$TMP_INSTALL_DIR"/* src/$*/lib/ 2>/dev/null || true; \ + echo " ✓ Installed"; \ + fi; \ + done < src/$*/lib/requirements.txt; \ + echo " Installing pysquared..."; \ + echo " (Please wait, this may take time for Git repos...)"; \ + rm -rf "$$TMP_INSTALL_DIR"/*; \ + $(UV) pip --no-cache-dir install $(PYSQUARED) --target "$$TMP_INSTALL_DIR" --no-deps --upgrade || exit 1; \ + cp -r "$$TMP_INSTALL_DIR"/* src/$*/lib/ 2>/dev/null || true; \ + echo " ✓ Installed" + + @if [ "$*" = "ground-station" ]; then \ + echo "Also downloading GS..."; \ + $(UV) pip --no-cache install $(PYSQUARED_GS) --target src/$*/lib --no-deps --upgrade --quiet; \ + fi @rm -rf src/$*/lib/*.dist-info @rm -rf src/$*/lib/.lock + @echo " Finished downloading libraries for $*" .PHONY: pre-commit-install pre-commit-install: uv @@ -87,14 +117,18 @@ build: build-flight-software build-ground-station ## Build all projects .PHONY: build-* build-%: download-libraries-% mpy-cross ## Build the project, store the result in the artifacts directory - @echo "Creating artifacts/proves/$*" + @echo "Building $*..." + @echo " Creating artifacts/proves/$*" @mkdir -p artifacts/proves/$* @echo "__version__ = '$(VERSION)'" > artifacts/proves/$*/version.py $(call compile_mpy,$*) + @echo " Copying files to artifacts..." $(call rsync_to_dest,src/$*,artifacts/proves/$*/) + @echo " Removing source .py files from artifacts..." @$(UV) run python -c "import os; [os.remove(os.path.join(root, file)) for root, _, files in os.walk('artifacts/proves/$*/lib') for file in files if file.endswith('.py')]" - @echo "Creating artifacts/proves/$*.zip" + @echo " Creating artifacts/proves/$*.zip" @zip -r artifacts/proves/$*.zip artifacts/proves/$* > /dev/null + @echo " Finished building $*" define rsync_to_dest @if [ -z "$(1)" ]; then \ @@ -171,5 +205,6 @@ endif endif define compile_mpy - @$(UV) run python -c "import os, subprocess; [subprocess.run(['$(MPY_CROSS)', os.path.join(root, file)]) for root, _, files in os.walk('src/$(1)/lib') for file in files if file.endswith('.py')]" || exit 1 + @echo "Compiling Python files to .mpy for $*..." + @$(UV) run python -c "import os, subprocess; files = [(r, f) for r, _, fs in os.walk('src/$(1)/lib') for f in fs if f.endswith('.py')]; print(f'Found {len(files)} Python files to compile'); [print(f' Compiling {os.path.join(r, f)}...') or subprocess.run(['$(MPY_CROSS)', os.path.join(r, f)], check=True) for r, f in files]; print(' Finished compiling')" || exit 1 endef From 52cf571a72522b4fe56fd3f5614ffa200d2f7a8a Mon Sep 17 00:00:00 2001 From: ineskhou <127782958+ineskhou@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:36:56 -0800 Subject: [PATCH 2/6] Update Makefile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 45357f1..29377e4 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,11 @@ download-libraries-%: uv .venv ## Download the required libraries @if [ "$*" = "ground-station" ]; then \ echo "Also downloading GS..."; \ - $(UV) pip --no-cache install $(PYSQUARED_GS) --target src/$*/lib --no-deps --upgrade --quiet; \ + TMP_GS_INSTALL_DIR=$$(mktemp -d); \ + trap "rm -rf $$TMP_GS_INSTALL_DIR" EXIT INT TERM; \ + $(UV) pip --no-cache install $(PYSQUARED_GS) --target "$$TMP_GS_INSTALL_DIR" --no-deps --upgrade --quiet || exit 1; \ + cp -r "$$TMP_GS_INSTALL_DIR"/* src/$*/lib/ 2>/dev/null || true; \ + rm -rf "$$TMP_GS_INSTALL_DIR"; \ fi @rm -rf src/$*/lib/*.dist-info From 8f477a18ea75813752657b840adfb1eb94c16b1c Mon Sep 17 00:00:00 2001 From: ineskhou <127782958+ineskhou@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:37:11 -0800 Subject: [PATCH 3/6] Update Makefile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 29377e4..358d6f2 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,6 @@ download-libraries-%: uv .venv ## Download the required libraries rm -rf "$$TMP_GS_INSTALL_DIR"; \ fi - @rm -rf src/$*/lib/*.dist-info - @rm -rf src/$*/lib/.lock @echo " Finished downloading libraries for $*" .PHONY: pre-commit-install From 18474ac7903b7e56098a4f4324b22638b6a2fbb2 Mon Sep 17 00:00:00 2001 From: ineskhou Date: Wed, 5 Nov 2025 14:37:47 -0800 Subject: [PATCH 4/6] cahceh fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 45357f1..00f4a1a 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ download-libraries-%: uv .venv ## Download the required libraries @if [ "$*" = "ground-station" ]; then \ echo "Also downloading GS..."; \ - $(UV) pip --no-cache install $(PYSQUARED_GS) --target src/$*/lib --no-deps --upgrade --quiet; \ + $(UV) pip --no-cache-dir install $(PYSQUARED_GS) --target src/$*/lib --no-deps --upgrade --quiet; \ fi @rm -rf src/$*/lib/*.dist-info From cb695d7c4cf082e628bdfdcc7edb037d31b60263 Mon Sep 17 00:00:00 2001 From: ineskhou Date: Wed, 5 Nov 2025 15:07:57 -0800 Subject: [PATCH 5/6] makefile has seperate linux builds --- Makefile | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 358d6f2..6b207f4 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,14 @@ typeshed: ## Install CircuitPython typeshed stubs download-libraries: download-libraries-flight-software download-libraries-ground-station .PHONY: download-libraries-% +download-libraries-%: uv .venv ## Download the required libraries + @echo "Downloading libraries for $*..." + @$(UV) pip install --requirement src/$*/lib/requirements.txt --target src/$*/lib --no-deps --upgrade --quiet + @$(UV) pip --no-cache install $(PYSQUARED) --target src/$*/lib --no-deps --upgrade --quiet + @rm -rf src/$*/lib/*.dist-info + @rm -rf src/$*/lib/.lock + +.PHONY: linux-download-libraries-% download-libraries-%: uv .venv ## Download the required libraries @echo "Downloading libraries for $*..." @echo " Cleaning old packages (keeping requirements.txt and local dirs)..." @@ -117,13 +125,27 @@ clean: ## Remove all gitignored files such as downloaded libraries and artifacts .PHONY: build build: build-flight-software build-ground-station ## Build all projects +.PHONY linux-build +linux-build: linux-build-flight-software linux-build-ground-station + .PHONY: build-* +build-%: download-libraries-% mpy-cross ## Build the project, store the result in the artifacts directory + @echo "Creating artifacts/proves/$*" + @mkdir -p artifacts/proves/$* + @echo "__version__ = '$(VERSION)'" > artifacts/proves/$*/version.py + $(call compile_mpy,$*) + $(call rsync_to_dest,src/$*,artifacts/proves/$*/) + @$(UV) run python -c "import os; [os.remove(os.path.join(root, file)) for root, _, files in os.walk('artifacts/proves/$*/lib') for file in files if file.endswith('.py')]" + @echo "Creating artifacts/proves/$*.zip" + @zip -r artifacts/proves/$*.zip artifacts/proves/$* > /dev/null + +.PHONY: linux-build-* build-%: download-libraries-% mpy-cross ## Build the project, store the result in the artifacts directory @echo "Building $*..." @echo " Creating artifacts/proves/$*" @mkdir -p artifacts/proves/$* @echo "__version__ = '$(VERSION)'" > artifacts/proves/$*/version.py - $(call compile_mpy,$*) + $(call linux_compile_mpy,$*) @echo " Copying files to artifacts..." $(call rsync_to_dest,src/$*,artifacts/proves/$*/) @echo " Removing source .py files from artifacts..." @@ -206,7 +228,11 @@ else endif endif -define compile_mpy +define linux_compile_mpy @echo "Compiling Python files to .mpy for $*..." @$(UV) run python -c "import os, subprocess; files = [(r, f) for r, _, fs in os.walk('src/$(1)/lib') for f in fs if f.endswith('.py')]; print(f'Found {len(files)} Python files to compile'); [print(f' Compiling {os.path.join(r, f)}...') or subprocess.run(['$(MPY_CROSS)', os.path.join(r, f)], check=True) for r, f in files]; print(' Finished compiling')" || exit 1 endef + +define compile_mpy + @$(UV) run python -c "import os, subprocess; [subprocess.run(['$(MPY_CROSS)', os.path.join(root, file)]) for root, _, files in os.walk('src/$(1)/lib') for file in files if file.endswith('.py')]" || exit 1 +endef From 3024492bfad37f33ee9b288161cd6425b23dff60 Mon Sep 17 00:00:00 2001 From: ineskhou Date: Wed, 5 Nov 2025 15:20:04 -0800 Subject: [PATCH 6/6] fixed syntax issues --- Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6b207f4..15a7246 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ download-libraries-%: uv .venv ## Download the required libraries @rm -rf src/$*/lib/.lock .PHONY: linux-download-libraries-% -download-libraries-%: uv .venv ## Download the required libraries +linux-download-libraries-%: uv .venv ## Download the required libraries @echo "Downloading libraries for $*..." @echo " Cleaning old packages (keeping requirements.txt and local dirs)..." @find src/$*/lib -mindepth 1 -maxdepth 1 ! -name 'requirements.txt' ! -name 'proveskit_*' -exec rm -rf {} + 2>/dev/null || true @@ -121,11 +121,10 @@ clean: ## Remove all gitignored files such as downloaded libraries and artifacts git clean -dfX ##@ Build - .PHONY: build build: build-flight-software build-ground-station ## Build all projects -.PHONY linux-build +.PHONY: linux-build linux-build: linux-build-flight-software linux-build-ground-station .PHONY: build-* @@ -140,7 +139,7 @@ build-%: download-libraries-% mpy-cross ## Build the project, store the result i @zip -r artifacts/proves/$*.zip artifacts/proves/$* > /dev/null .PHONY: linux-build-* -build-%: download-libraries-% mpy-cross ## Build the project, store the result in the artifacts directory +linux-build-%: linux-download-libraries-% mpy-cross ## Build the project, store the result in the artifacts directory @echo "Building $*..." @echo " Creating artifacts/proves/$*" @mkdir -p artifacts/proves/$*