Skip to content

Commit df6675e

Browse files
Major refactor, cleanup, documentation, and Python packaging.
1 parent ed42d8f commit df6675e

File tree

61 files changed

+989
-536
lines changed

Some content is hidden

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

61 files changed

+989
-536
lines changed

.github/workflows/build-and-release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@ jobs:
2323

2424
call-linux-build:
2525
uses: ./.github/workflows/build-linux.yml
26+
27+
# call-linux-arm-build:
28+
# uses: ./.github/workflows/build-linux-arm.yml
2629

2730
call-windows-build:
2831
uses: ./.github/workflows/build-windows.yml
29-
32+
3033
call-python-build:
34+
needs: [call-macos-build, call-linux-build, call-windows-build]
3135
uses: ./.github/workflows/build-python.yml
32-
36+
with:
37+
teensy-loader-linux-artifact: ${{ needs.call-linux-build.outputs.teensy-loader }}
38+
teensy-loader-macos-artifact: ${{ needs.call-macos-build.outputs.teensy-loader }}
39+
teensy-loader-windows-artifact: ${{ needs.call-windows-build.outputs.teensy-loader }}
40+
3341
# Using the outputs of the build
3442
deploy-builds:
3543

@@ -45,6 +53,9 @@ jobs:
4553
- uses: actions/download-artifact@v4
4654
with:
4755
name: ${{ needs.call-linux-build.outputs.build-file }}
56+
# - uses: actions/download-artifact@v4
57+
# with:
58+
# name: ${{ needs.call-linux-arm-build.outputs.build-file }}
4859
- uses: actions/download-artifact@v4
4960
with:
5061
name: ${{ needs.call-windows-build.outputs.build-file }}

.github/workflows/build-linux-arm.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: build-linux-arm
4+
5+
# Controls when the workflow will run
6+
on:
7+
# this is a called workflow
8+
workflow_call:
9+
outputs:
10+
build-file:
11+
description: "The output of this build procsss"
12+
value: ${{ jobs.linux-build-job.outputs.install-file }}
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# Build the installer on mac
17+
linux-build-job:
18+
# The type of runner that the job will run on
19+
runs-on: ubuntu-24.04-arm
20+
21+
# Output
22+
outputs:
23+
install-file: ${{ steps.output-installer.outputs.filename }}
24+
25+
# Steps represent a sequence of tasks that will be executed as part of the job
26+
steps:
27+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
28+
- uses: actions/checkout@v4
29+
with:
30+
path: uploader
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.12'
34+
35+
# Setup python
36+
- name: System Setup
37+
run: |
38+
pip install pyinstaller pyqt5 darkdetect argparse intelhex esptool mpremote requests psutil
39+
40+
# Fetch and build the teensy_loader_cli executable for Linux
41+
- name: Fetch Teensy Loader CLI
42+
uses: actions/checkout@v4
43+
with:
44+
repository: PaulStoffregen/teensy_loader_cli
45+
path: teensy_loader_cli
46+
47+
- name: Build Teensy Loader CLI
48+
run: |
49+
cd teensy_loader_cli
50+
sudo apt-get update
51+
sudo apt-get install -y libusb-dev
52+
make OS=LINUX CC=gcc CFLAGS="-static -O2 -Wall"
53+
sudo mv teensy_loader_cli $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
54+
sudo chmod +x $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
55+
56+
# Build the installer.
57+
- name: Build Linux Installer
58+
run: |
59+
cd $GITHUB_WORKSPACE/uploader/
60+
ESPTOOL_LOCATION=$(pip show esptool | grep "Location: " | cut -c 11- | tr -d '\n')
61+
ESPTOOL_TARGETS_1=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/1/*.json:./esptool/targets/stub_flasher/1/")
62+
ESPTOOL_TARGETS_2=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/2/*.json:./esptool/targets/stub_flasher/2/")
63+
pyinstaller --onefile --clean --name MicroPythonUploader --noconsole --distpath=. --icon=MicroPython_Firmware_Uploader/resource/sfe_flame.ico --add-data="MicroPython_Firmware_Uploader/resource/*:resource/" --add-data="${ESPTOOL_TARGETS_1}" --add-data="${ESPTOOL_TARGETS_2}" MicroPython_Firmware_Upload.py
64+
gzip MicroPythonUploader
65+
mv MicroPythonUploader.gz $GITHUB_WORKSPACE/MicroPythonUploader.linux-arm.gz
66+
67+
- uses: actions/upload-artifact@v4
68+
with:
69+
name: MicroPythonUploader.linux-arm.gz
70+
path: MicroPythonUploader.linux-arm.gz
71+
72+
- id: output-installer
73+
run: |
74+
echo "filename=MicroPythonUploader.linux-arm.gz" >> $GITHUB_OUTPUT

.github/workflows/build-linux.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
build-file:
1111
description: "The output of this build procsss"
1212
value: ${{ jobs.linux-build-job.outputs.install-file }}
13+
teensy-loader:
14+
description: "The teensy loader cli executable"
15+
value: ${{ jobs.linux-build-job.outputs.teensy-loader }}
1316

1417
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1518
jobs:
@@ -21,11 +24,14 @@ jobs:
2124
# Output
2225
outputs:
2326
install-file: ${{ steps.output-installer.outputs.filename }}
27+
teensy-loader: ${{ steps.output-installer.outputs.teensy-loader }}
2428

2529
# Steps represent a sequence of tasks that will be executed as part of the job
2630
steps:
2731
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2832
- uses: actions/checkout@v4
33+
with:
34+
path: uploader
2935
- uses: actions/setup-python@v5
3036
with:
3137
python-version: '3.12'
@@ -35,22 +41,50 @@ jobs:
3541
run: |
3642
pip install pyinstaller pyqt5 darkdetect argparse intelhex esptool mpremote requests psutil
3743
44+
# Fetch and build the teensy_loader_cli executable for Linux
45+
- name: Fetch Teensy Loader CLI
46+
uses: actions/checkout@v4
47+
with:
48+
repository: PaulStoffregen/teensy_loader_cli
49+
path: teensy_loader_cli
50+
51+
# Build the teensy_loader_cli executable for Linux
52+
# Move it to the correct location
53+
# also copy it for use in a different job
54+
- name: Build Teensy Loader CLI
55+
run: |
56+
cd teensy_loader_cli
57+
sudo apt-get update
58+
sudo apt-get install -y libusb-dev
59+
make OS=LINUX CC=gcc CFLAGS="-static -O2 -Wall"
60+
sudo mv teensy_loader_cli $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
61+
sudo chmod +x $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
62+
sudo cp $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe $GITHUB_WORKSPACE/teensy_loader_cli_linux
63+
sudo chmod +x $GITHUB_WORKSPACE/teensy_loader_cli_linux
64+
3865
# Build the installer.
3966
- name: Build Linux Installer
4067
run: |
41-
sudo mv MicroPython_Firmware_Uploader/resource/teensy_loader_cli_linux MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
42-
sudo chmod +x MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
68+
cd $GITHUB_WORKSPACE/uploader/
4369
ESPTOOL_LOCATION=$(pip show esptool | grep "Location: " | cut -c 11- | tr -d '\n')
4470
ESPTOOL_TARGETS_1=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/1/*.json:./esptool/targets/stub_flasher/1/")
4571
ESPTOOL_TARGETS_2=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/2/*.json:./esptool/targets/stub_flasher/2/")
4672
pyinstaller --onefile --clean --name MicroPythonUploader --noconsole --distpath=. --icon=MicroPython_Firmware_Uploader/resource/sfe_flame.ico --add-data="MicroPython_Firmware_Uploader/resource/*:resource/" --add-data="${ESPTOOL_TARGETS_1}" --add-data="${ESPTOOL_TARGETS_2}" MicroPython_Firmware_Upload.py
4773
gzip MicroPythonUploader
48-
mv MicroPythonUploader.gz MicroPythonUploader.linux.gz
74+
mv MicroPythonUploader.gz $GITHUB_WORKSPACE/MicroPythonUploader.linux.gz
4975
5076
- uses: actions/upload-artifact@v4
5177
with:
5278
name: MicroPythonUploader.linux.gz
5379
path: MicroPythonUploader.linux.gz
5480

81+
- uses: actions/upload-artifact@v4
82+
with:
83+
name: teensy_loader_cli_linux
84+
path: teensy_loader_cli_linux
85+
86+
# We output our linux executable for publishing as well as the teensy_loader executable for use by the python package
5587
- id: output-installer
56-
run: echo "filename=MicroPythonUploader.linux.gz" >> $GITHUB_OUTPUT
88+
run: |
89+
echo "filename=MicroPythonUploader.linux.gz" >> $GITHUB_OUTPUT
90+
echo "teensy-loader=teensy_loader_cli_linux" >> $GITHUB_OUTPUT

.github/workflows/build-macos.yml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
build-file:
1111
description: "The output of this build procsss"
1212
value: ${{ jobs.macos-build-job.outputs.install-file }}
13+
teensy-loader:
14+
description: "The teensy loader cli executable"
15+
value: ${{ jobs.macos-build-job.outputs.teensy-loader }}
1316

1417
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1518
jobs:
@@ -21,11 +24,14 @@ jobs:
2124
# Output
2225
outputs:
2326
install-file: ${{ steps.output-installer.outputs.filename }}
27+
teensy-loader: ${{ steps.output-installer.outputs.teensy-loader }}
2428

2529
# Steps represent a sequence of tasks that will be executed as part of the job
2630
steps:
2731
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2832
- uses: actions/checkout@v4
33+
with:
34+
path: uploader
2935
- uses: actions/setup-python@v5
3036
with:
3137
python-version: '3.12'
@@ -35,26 +41,55 @@ jobs:
3541
run: |
3642
pip install pyinstaller Pillow pyqt5 darkdetect argparse intelhex esptool mpremote requests psutil
3743
brew install create-dmg
44+
45+
# Fetch and build the teensy_loader_cli executable for Mac
46+
- name: Fetch Teensy Loader CLI
47+
uses: actions/checkout@v4
48+
with:
49+
repository: PaulStoffregen/teensy_loader_cli
50+
path: teensy_loader_cli
51+
52+
# Build the teensy_loader_cli executable for Linux
53+
# Move it to the correct location
54+
# also copy it for use in a different job
55+
- name: Build Teensy Loader CLI
56+
run: |
57+
pwd
58+
cd teensy_loader_cli
59+
make OS=MACOSX CC=gcc
60+
sudo mv teensy_loader_cli $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
61+
sudo chmod +x $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
62+
sudo cp $GITHUB_WORKSPACE/uploader/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe $GITHUB_WORKSPACE/teensy_loader_cli_macos
63+
sudo chmod +x $GITHUB_WORKSPACE/teensy_loader_cli_macos
3864
3965
# Build the installer.
4066
- name: Build Mac Installer
4167
run: |
42-
sudo mv MicroPython_Firmware_Uploader/resource/teensy_loader_cli_mac MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
43-
sudo chmod +x MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
68+
echo "PWD BEFORE: $(pwd)"
69+
echo "DIRECTORY STRUCTURE BEFORE: $ls -r ${GITHUB_WORKSPACE}"
4470
ESPTOOL_LOCATION=$(pip show esptool | grep "Location: " | cut -c 11- | tr -d '\n')
4571
ESPTOOL_TARGETS_1=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/1/*.json:./esptool/targets/stub_flasher/1/")
4672
ESPTOOL_TARGETS_2=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/2/*.json:./esptool/targets/stub_flasher/2/")
47-
pyinstaller --windowed -n MicroPythonUploader --noconsole --distpath=. --icon=MicroPython_Firmware_Uploader/resource/sfe_flame.ico --add-data="MicroPython_Firmware_Uploader/resource/*:resource/" --add-data="${ESPTOOL_TARGETS_1}" --add-data="${ESPTOOL_TARGETS_2}" MicroPython_Firmware_Upload.py
73+
pyinstaller --windowed -n SparkFunMicroPython --noconsole --distpath=. --icon=uploader/MicroPython_Firmware_Uploader/resource/sfe_flame.ico --add-data="uploader/MicroPython_Firmware_Uploader/resource/*:resource/" --add-data="${ESPTOOL_TARGETS_1}" --add-data="${ESPTOOL_TARGETS_2}" uploader/MicroPython_Firmware_Upload.py
4874
mkdir tmp
49-
mv "MicroPythonUploader.app" "tmp/"
50-
create-dmg --volicon "MicroPython_Firmware_Uploader/resource/sparkdisk.icns" --background "MicroPython_Firmware_Uploader/resource/sfe_logo_med.png" --hide-extension "MicroPythonUploader.app" --icon "MicroPythonUploader.app" 100 100 --window-size 600 440 --app-drop-link 400 100 "MicroPythonUploader.dmg" "tmp/"
75+
mv "SparkFunMicroPython.app" "tmp/"
76+
create-dmg --volicon "uploader/MicroPython_Firmware_Uploader/resource/sparkdisk.icns" --background "uploader/MicroPython_Firmware_Uploader/resource/sfe_logo_med.png" --hide-extension "SparkFunMicroPython.app" --icon "SparkFunMicroPython.app" 100 100 --window-size 600 440 --app-drop-link 400 100 "SparkFunMicroPython.dmg" "tmp/"
77+
echo "PWD AFTER: $(pwd)"
78+
echo "DIRECTORY STRUCTURE AFTER: $ls -r ${GITHUB_WORKSPACE}"
5179
5280
- uses: actions/upload-artifact@v4
5381
with:
54-
name: MicroPythonUploader.dmg
55-
path: MicroPythonUploader.dmg
82+
name: SparkFunMicroPython.dmg
83+
path: SparkFunMicroPython.dmg
84+
85+
- uses: actions/upload-artifact@v4
86+
with:
87+
name: teensy_loader_cli_macos
88+
path: teensy_loader_cli_macos
5689

5790
- id: output-installer
58-
run: echo "filename=MicroPythonUploader.dmg" >> $GITHUB_OUTPUT
91+
run: |
92+
echo "filename=SparkFunMicroPython.dmg" >> $GITHUB_OUTPUT
93+
echo "teensy-loader=teensy_loader_cli_macos" >> $GITHUB_OUTPUT
5994
6095

.github/workflows/build-python.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ name: build-python
66
on:
77
# this is a called workflow
88
workflow_call:
9+
inputs:
10+
teensy-loader-linux-artifact:
11+
description: "The teensy loader cli executable for linux artifact name"
12+
required: true
13+
type: string
14+
teensy-loader-macos-artifact:
15+
description: "The teensy loader cli executable for mac artifact name"
16+
required: true
17+
type: string
18+
teensy-loader-windows-artifact:
19+
description: "The teensy loader cli executable for windows artifact name"
20+
required: true
21+
type: string
922
outputs:
1023
build-file:
1124
description: "The output of this build procsss"
@@ -27,6 +40,9 @@ jobs:
2740
install-package: ${{ steps.output-installer.outputs.packagename }}
2841

2942
# Steps represent a sequence of tasks that will be executed as part of the job
43+
# TODO: Need to make this dependent on the mac, linux, and windows build
44+
# then need to copy all of the executables here. The python packaging will then have to intelligently select the
45+
# correct executable to use based on the OS
3046
steps:
3147
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3248
- uses: actions/checkout@v4
@@ -39,6 +55,36 @@ jobs:
3955
run: |
4056
pip3 install setuptools
4157
58+
# Download the teensy loader cli executable for linux
59+
- name: Download Teensy Loader Linux
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: ${{ inputs.teensy-loader-linux-artifact }}
63+
64+
# Download the teensy loader cli executable for mac
65+
- name: Download Teensy Loader Mac
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: ${{ inputs.teensy-loader-macos-artifact }}
69+
70+
# Download the teensy loader cli executable for windows
71+
- name: Download Teensy Loader Windows
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: ${{ inputs.teensy-loader-windows-artifact }}
75+
76+
# Copy the teensy loader cli executable from the other builds
77+
# Note: A hack here, since setup.py is run now and also when the user installs the package,
78+
# we make linux the default (because this workflow is run on linux). The setup.py script will
79+
# rename the executable to teensy_loader_cli.exe for the other OSes at install time.
80+
- name: Copy Teensy Loader CLI
81+
run: |
82+
echo "Copying Teensy Loader CLIs Within Python Build"
83+
ls $GITHUB_WORKSPACE
84+
cp $GITHUB_WORKSPACE/teensy_loader_cli_linux $GITHUB_WORKSPACE/MicroPython_Firmware_Uploader/resource/teensy_loader_cli.exe
85+
cp $GITHUB_WORKSPACE/teensy_loader_cli_macos $GITHUB_WORKSPACE/MicroPython_Firmware_Uploader/resource/teensy_loader_cli_macos.exe
86+
cp $GITHUB_WORKSPACE/teensy_loader_cli_windows $GITHUB_WORKSPACE/MicroPython_Firmware_Uploader/resource/teensy_loader_cli_windows.exe
87+
4288
# Build the installer
4389
- name: Build Python Installer
4490
run: |

0 commit comments

Comments
 (0)