Skip to content

Commit 7ec6e0c

Browse files
Use Workspaces to resolve both CPython and CircuitPython types where necessary (#309)
Co-authored-by: Michael Pham <[email protected]>
1 parent 2ca1aaf commit 7ec6e0c

File tree

146 files changed

+679
-741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+679
-741
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,3 @@ jobs:
4040
uses: SonarSource/[email protected]
4141
env:
4242
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43-
archive:
44-
runs-on: ubuntu-latest
45-
steps:
46-
- uses: actions/checkout@v4
47-
- name: Build
48-
run: |
49-
make build
50-
- name: Archive
51-
uses: actions/upload-artifact@v4
52-
with:
53-
name: proves
54-
path: artifacts/proves.zip

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ pysquared.egg-info/
1414
**/*.mpy
1515
site/
1616
typeshed/
17+
*.egg-info
18+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ repos:
2121
entry: '# type:? *ignore'
2222
language: pygrep
2323
types: [python]
24-
files: ^pysquared/
25-
exclude: ^pysquared/beacon\.py|^pysquared/logger\.py|^pysquared/rtc/manager/microcontroller\.py
24+
files: ^circuitpython-workspaces/flight-software
25+
exclude: ^circuitpython-workspaces/flight-software/src/pysquared/beacon\.py|^circuitpython-workspaces/flight-software/src/pysquared/logger\.py|^circuitpython-workspaces/flight-software/src/pysquared/rtc/manager/microcontroller\.py
2626

2727
- repo: local
2828
hooks:
@@ -32,7 +32,7 @@ repos:
3232
entry: '# pyright:? *.*false'
3333
language: pygrep
3434
types: [python]
35-
files: ^pysquared/
35+
files: ^circuitpython-workspaces/flight-software
3636

3737
- repo: https://github.com/codespell-project/codespell
3838
rev: v2.4.1

.vscode/settings.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
{
22
"files.eol": "\n",
33
"python.testing.pytestArgs": [
4-
"tests/unit"
4+
"cpython-workspaces/flight-software-unit-tests/src"
55
],
66
"python.testing.unittestEnabled": false,
7-
"python.testing.pytestEnabled": true,
8-
"sonarlint.connectedMode.project": {
9-
"connectionId": "proves-kit",
10-
"projectKey": "proveskit_circuitpy_flight_software"
11-
},
12-
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
7+
"python.testing.pytestEnabled": true
138
}

Makefile

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.PHONY: all
2-
all: .venv typeshed pre-commit-install
2+
all: .venv circuitpython-workspaces/typeshed pre-commit-install
33

44
.PHONY: help
55
help: ## Display this help.
@@ -13,10 +13,10 @@ help: ## Display this help.
1313
@$(UV) venv
1414
@$(UV) pip install --requirement pyproject.toml
1515

16-
typeshed: ## Install CircuitPython typeshed stubs
16+
circuitpython-workspaces/typeshed: ## Install CircuitPython typeshed stubs
1717
@echo "Installing CircuitPython typeshed stubs..."
1818
@$(MAKE) uv
19-
@$(UV) pip install circuitpython-typeshed==0.1.0 --target typeshed
19+
@$(UV) pip install circuitpython-typeshed==0.1.0 --target circuitpython-workspaces/typeshed
2020

2121
.PHONY: pre-commit-install
2222
pre-commit-install: uv
@@ -28,54 +28,27 @@ fmt: pre-commit-install ## Lint and format files
2828
$(UVX) pre-commit run --all-files
2929

3030
.PHONY: typecheck
31-
typecheck: .venv typeshed ## Run type check
32-
@$(UV) run -m pyright .
31+
typecheck: .venv circuitpython-workspaces/typeshed ## Run type check
32+
@$(UV) run -m pyright --project=circuitpython-workspaces circuitpython-workspaces/
33+
@$(UV) run -m pyright --project=cpython-workspaces cpython-workspaces/
3334

3435
.PHONY: test
3536
test: .venv ## Run tests
36-
$(UV) run coverage run --rcfile=pyproject.toml -m pytest tests/unit
37+
$(UV) run coverage run --rcfile=pyproject.toml -m pytest cpython-workspaces/flight-software-unit-tests/src
3738
@$(UV) run coverage html --rcfile=pyproject.toml > /dev/null
3839
@$(UV) run coverage xml --rcfile=pyproject.toml > /dev/null
3940

4041
.PHONY: clean
4142
clean: ## Remove all gitignored files
4243
git clean -dfX
4344

44-
##@ Build
45-
46-
.PHONY: build
47-
build: uv mpy-cross ## Build the project, store the result in the artifacts directory
48-
@echo "Creating artifacts/pysquared"
49-
@mkdir -p artifacts/pysquared
50-
$(call compile_mpy)
51-
$(call rsync_to_dest,.,artifacts/pysquared/)
52-
@$(UV) run python -c "import os; [os.remove(os.path.join(root, file)) for root, _, files in os.walk('artifacts/pysquared') for file in files if file.endswith('.py')]"
53-
@$(UV) run python -c "import os; [os.remove(os.path.join(root, file)) for root, _, files in os.walk('pysquared') for file in files if file.endswith('.mpy')]"
54-
@echo "Creating artifacts/pysquared.zip"
55-
@zip -r artifacts/pysquared.zip artifacts/pysquared > /dev/null
56-
57-
define rsync_to_dest
58-
@if [ -z "$(1)" ]; then \
59-
echo "Issue with Make target, rsync source is not specified. Stopping."; \
60-
exit 1; \
61-
fi
62-
63-
@if [ -z "$(2)" ]; then \
64-
echo "Issue with Make target, rsync destination is not specified. Stopping."; \
65-
exit 1; \
66-
fi
67-
68-
@rsync -avh $(1)/pysquared/* --exclude='requirements.txt' --exclude='__pycache__' $(2) --delete --times --checksum
69-
endef
70-
7145
##@ Build Tools
7246
TOOLS_DIR ?= tools
7347
$(TOOLS_DIR):
7448
mkdir -p $(TOOLS_DIR)
7549

7650
### Tool Versions
7751
UV_VERSION ?= 0.8.14
78-
MPY_CROSS_VERSION ?= 9.0.5
7952

8053
UV_DIR ?= $(TOOLS_DIR)/uv-$(UV_VERSION)
8154
UV ?= $(UV_DIR)/uv
@@ -85,36 +58,6 @@ uv: $(UV) ## Download uv
8558
$(UV): $(TOOLS_DIR)
8659
@test -s $(UV) || { mkdir -p $(UV_DIR); curl -LsSf https://astral.sh/uv/$(UV_VERSION)/install.sh | UV_INSTALL_DIR=$(UV_DIR) sh > /dev/null; }
8760

88-
UNAME_S := $(shell uname -s)
89-
UNAME_M := $(shell uname -m)
90-
91-
MPY_S3_PREFIX ?= https://adafruit-circuit-python.s3.amazonaws.com/bin/mpy-cross
92-
MPY_CROSS ?= $(TOOLS_DIR)/mpy-cross-$(MPY_CROSS_VERSION)
93-
.PHONY: mpy-cross
94-
mpy-cross: $(MPY_CROSS) ## Download mpy-cross
95-
$(MPY_CROSS): $(TOOLS_DIR)
96-
@echo "Downloading mpy-cross $(MPY_CROSS_VERSION)..."
97-
@mkdir -p $(dir $@)
98-
ifeq ($(OS),Windows_NT)
99-
@curl -LsSf $(MPY_S3_PREFIX)/windows/mpy-cross-windows-$(MPY_CROSS_VERSION).static.exe -o $@
100-
else
101-
ifeq ($(UNAME_S),Linux)
102-
ifeq ($(or $(filter x86_64,$(UNAME_M)),$(filter amd64,$(UNAME_M))),$(UNAME_M))
103-
@curl -LsSf $(MPY_S3_PREFIX)/linux-amd64/mpy-cross-linux-amd64-$(MPY_CROSS_VERSION).static -o $@
104-
@chmod +x $@
105-
endif
106-
else ifeq ($(UNAME_S),Darwin)
107-
@curl -LsSf $(MPY_S3_PREFIX)/macos-11/mpy-cross-macos-11-$(MPY_CROSS_VERSION)-universal -o $@
108-
@chmod +x $@
109-
else
110-
@echo "Pre-built mpy-cross not available for system: $(UNAME_S)"
111-
endif
112-
endif
113-
114-
define compile_mpy
115-
@$(UV) run python -c "import os, subprocess; [subprocess.run(['$(MPY_CROSS)', os.path.join(root, file)]) for root, _, files in os.walk('pysquared') for file in files if file.endswith('.py')]" || exit 1
116-
endef
117-
11861
.PHONY: docs
11962
docs: uv
12063
@$(UV) run --group docs mkdocs serve

README.md

Lines changed: 11 additions & 2 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[project]
2+
name = "pysquared-flight-software"
3+
version = "2.0.0"
4+
description = "Flight Software for the PROVES Kit"
5+
requires-python = ">=3.13"
6+
dependencies = [
7+
"adafruit-circuitpython-ina219==3.4.26",
8+
"adafruit-circuitpython-asyncio @ git+https://github.com/adafruit/[email protected]",
9+
"adafruit-circuitpython-drv2605==1.3.4",
10+
"adafruit-circuitpython-lis2mdl==2.1.23",
11+
"adafruit-circuitpython-lsm6ds==4.5.13",
12+
"adafruit-circuitpython-mcp9808==3.3.24",
13+
"adafruit-circuitpython-neopixel==6.3.12",
14+
"adafruit-circuitpython-register==1.10.4",
15+
"adafruit-circuitpython-rfm==1.0.6",
16+
"adafruit-circuitpython-tca9548a @ git+https://github.com/proveskit/[email protected]",
17+
"adafruit-circuitpython-ticks==1.1.1",
18+
"adafruit-circuitpython-veml7700==2.1.4",
19+
"proves-circuitpython-rv3028 @ git+https://github.com/proveskit/[email protected]",
20+
"proves-circuitpython-sx126 @ git+https://github.com/proveskit/[email protected]",
21+
"proves-circuitpython-sx1280 @ git+https://github.com/proveskit/[email protected]",
22+
]
23+
24+
[tool.setuptools]
25+
package-dir = {"" = "src"}
26+
27+
[tool.setuptools.packages.find]
28+
where = ["src"]
29+
include = ["pysquared*"]

pysquared/__init__.py renamed to circuitpython-workspaces/flight-software/src/pysquared/__init__.py

File renamed without changes.

pysquared/beacon.py renamed to circuitpython-workspaces/flight-software/src/pysquared/beacon.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
import time
1919
from collections import OrderedDict
2020

21-
try:
22-
from mocks.circuitpython.microcontroller import Processor
23-
except ImportError:
24-
from microcontroller import Processor
21+
from microcontroller import Processor
2522

2623
from .hardware.radio.packetizer.packet_manager import PacketManager
2724
from .logger import Logger

pysquared/cdh.py renamed to circuitpython-workspaces/flight-software/src/pysquared/cdh.py

File renamed without changes.

0 commit comments

Comments
 (0)