Skip to content

Commit 7cf54f4

Browse files
Add initial python firmware uploader content. Relatively stable on Windows and Mac. Needs refactoring.
0 parents  commit 7cf54f4

File tree

78 files changed

+3071
-0
lines changed

Some content is hidden

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

78 files changed

+3071
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: build-and-release
4+
5+
# Controls when the workflow will run
6+
on:
7+
8+
# Trigger on a push
9+
#push:
10+
11+
# Trigger on a published release
12+
release:
13+
types: [published]
14+
15+
# Allows you to run this workflow manually from the Actions tab
16+
workflow_dispatch:
17+
18+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
19+
jobs:
20+
# Build the installer on mac
21+
call-macos-build:
22+
uses: ./.github/workflows/build-macos.yml
23+
24+
call-linux-build:
25+
uses: ./.github/workflows/build-linux.yml
26+
27+
call-windows-build:
28+
uses: ./.github/workflows/build-windows.yml
29+
30+
call-python-build:
31+
uses: ./.github/workflows/build-python.yml
32+
33+
# Using the outputs of the build
34+
deploy-builds:
35+
36+
# Only do this on a release - note - filtering release types in the above "on:" statement
37+
if: github.event_name == 'release'
38+
runs-on: ubuntu-latest
39+
needs: [call-macos-build, call-linux-build, call-windows-build, call-python-build]
40+
steps:
41+
# Download the generated app files that are part of the release
42+
- uses: actions/download-artifact@v4
43+
with:
44+
name: ${{ needs.call-macos-build.outputs.build-file }}
45+
- uses: actions/download-artifact@v4
46+
with:
47+
name: ${{ needs.call-linux-build.outputs.build-file }}
48+
- uses: actions/download-artifact@v4
49+
with:
50+
name: ${{ needs.call-windows-build.outputs.build-file }}
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: ${{ needs.call-python-build.outputs.build-file }}
54+
- name: Output Listing
55+
run: ls -la
56+
57+
- name: Publish Release
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
files: |
61+
${{ needs.call-macos-build.outputs.build-file }}
62+
${{ needs.call-linux-build.outputs.build-file }}
63+
${{ needs.call-windows-build.outputs.build-file }}
64+
${{ needs.call-python-build.outputs.build-package }}
65+

.github/workflows/build-linux.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: build-linux
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-latest
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+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.12'
32+
33+
# Setup python
34+
- name: System Setup
35+
run: |
36+
pip install pyinstaller pyqt5 darkdetect argparse intelhex esptool mpremote requests psutil
37+
38+
# Build the installer.
39+
- name: Build Linux Installer
40+
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
43+
ESPTOOL_LOCATION=$(pip show esptool | grep "Location: " | cut -c 11- | tr -d '\n')
44+
ESPTOOL_TARGETS_1=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/1/*.json:./esptool/targets/stub_flasher/1/")
45+
ESPTOOL_TARGETS_2=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/2/*.json:./esptool/targets/stub_flasher/2/")
46+
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
47+
gzip MicroPythonUploader
48+
mv MicroPythonUploader.gz MicroPythonUploader.linux.gz
49+
50+
- uses: actions/upload-artifact@v4
51+
with:
52+
name: MicroPythonUploader.linux.gz
53+
path: MicroPythonUploader.linux.gz
54+
55+
- id: output-installer
56+
run: echo "filename=MicroPythonUploader.linux.gz" >> $GITHUB_OUTPUT

.github/workflows/build-macos.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: build-macos
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.macos-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+
macos-build-job:
18+
# The type of runner that the job will run on
19+
runs-on: macos-13
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+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.12'
32+
33+
# Setup python
34+
- name: System Setup
35+
run: |
36+
pip install pyinstaller Pillow pyqt5 darkdetect argparse intelhex esptool mpremote requests psutil
37+
brew install create-dmg
38+
39+
# Build the installer.
40+
- name: Build Mac Installer
41+
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
44+
ESPTOOL_LOCATION=$(pip show esptool | grep "Location: " | cut -c 11- | tr -d '\n')
45+
ESPTOOL_TARGETS_1=$(echo "${ESPTOOL_LOCATION}/esptool/targets/stub_flasher/1/*.json:./esptool/targets/stub_flasher/1/")
46+
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
48+
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/"
51+
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: MicroPythonUploader.dmg
55+
path: MicroPythonUploader.dmg
56+
57+
- id: output-installer
58+
run: echo "filename=MicroPythonUploader.dmg" >> $GITHUB_OUTPUT
59+
60+

.github/workflows/build-python.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: build-python
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.python-build-job.outputs.install-file }}
13+
build-package:
14+
description: "The output of this build procsss"
15+
value: ${{ jobs.python-build-job.outputs.install-package }}
16+
17+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
18+
jobs:
19+
# Build the installer on mac
20+
python-build-job:
21+
# The type of runner that the job will run on
22+
runs-on: ubuntu-latest
23+
24+
# Output
25+
outputs:
26+
install-file: ${{ steps.output-installer.outputs.filename }}
27+
install-package: ${{ steps.output-installer.outputs.packagename }}
28+
29+
# Steps represent a sequence of tasks that will be executed as part of the job
30+
steps:
31+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.12'
36+
37+
# Setup python
38+
- name: System Setup
39+
run: |
40+
pip3 install setuptools
41+
42+
# Build the installer
43+
- name: Build Python Installer
44+
run: |
45+
python setup.py sdist
46+
47+
- uses: actions/upload-artifact@v4
48+
with:
49+
name: python-install-package
50+
path: dist
51+
52+
- name: Extract package name
53+
run: |
54+
cd dist
55+
echo "PACKAGE_NAME=$(ls *.tar.gz)" >> $GITHUB_ENV
56+
57+
- id: output-installer
58+
run: |
59+
echo "filename=python-install-package" >> $GITHUB_OUTPUT
60+
echo "packagename=${{ env.PACKAGE_NAME }}" >> $GITHUB_OUTPUT

.github/workflows/build-windows.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: build-windows
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.windows-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+
windows-build-job:
18+
# The type of runner that the job will run on
19+
runs-on: windows-latest
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+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.12'
32+
33+
# Setup python
34+
- name: System Setup
35+
run: |
36+
pip install pyinstaller pyqt5 darkdetect argparse intelhex esptool mpremote requests psutil
37+
38+
# Build the installer.
39+
- name: Build Windows Installer
40+
shell: powershell
41+
run: |
42+
ren MicroPython_Firmware_Uploader\resource\teensy_loader_cli_windows.exe teensy_loader_cli.exe
43+
$ESPTOOL_TARGETS = echo "$(pip show esptool | findstr "Location: ")"
44+
$ESPTOOL_TARGETS = $ESPTOOL_TARGETS.Substring(10)
45+
$ESPTOOL_TARGETS_1 = echo "${ESPTOOL_TARGETS}\esptool\targets\stub_flasher\1\*.json;.\esptool\targets\stub_flasher\1\"
46+
$ESPTOOL_TARGETS_2 = echo "${ESPTOOL_TARGETS}\esptool\targets\stub_flasher\2\*.json;.\esptool\targets\stub_flasher\2\"
47+
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
48+
49+
- name: Compress Installer
50+
shell: powershell
51+
run: |
52+
$compress = @{
53+
Path = ".\MicroPythonUploader.exe"
54+
CompressionLevel = "Fastest"
55+
DestinationPath = ".\MicroPythonUploader.win.zip"
56+
}
57+
Compress-Archive @compress
58+
59+
- uses: actions/upload-artifact@v4
60+
with:
61+
name: MicroPythonUploader.win.zip
62+
path: MicroPythonUploader.win.zip
63+
64+
# Use Windows powershell notation: $env:GITHUB_OUTPUT
65+
- id: output-installer
66+
run: echo "filename=MicroPythonUploader.win.zip" >> $env:GITHUB_OUTPUT
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Workflow that builds the application, but doens't add to a release.
2+
#
3+
# This will run on a push that doesn't have a vesion (release) tag
4+
5+
name: non-release-build
6+
7+
# Controls when the workflow will run
8+
on:
9+
# Trigger on push - when a version tag isn't set
10+
# push:
11+
# branches:
12+
# - master
13+
# tags-ignore:
14+
# - "v*.*.*"
15+
16+
# Allows you to run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
19+
# Run each plaform build workflows as seperate jobs
20+
jobs:
21+
# Build the installer on mac
22+
call-macos-build:
23+
uses: ./.github/workflows/build-macos.yml
24+
25+
call-linux-build:
26+
uses: ./.github/workflows/build-linux.yml
27+
28+
call-windows-build:
29+
uses: ./.github/workflows/build-windows.yml
30+
31+
call-python-build:
32+
uses: ./.github/workflows/build-python.yml

.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#Python
2+
__pycache__/
3+
*.py[co]
4+
5+
#VSCode
6+
7+
/.vscode/*
8+
9+
# Windows image file caches
10+
Thumbs.db
11+
ehthumbs.db
12+
13+
#Eagle Backup files
14+
*.s#?
15+
*.b#?
16+
*.l#?
17+
*.lck
18+
19+
# Folder config file
20+
Desktop.ini
21+
22+
# Recycle Bin used on file shares
23+
$RECYCLE.BIN/
24+
25+
# Windows Installer files
26+
*.cab
27+
*.msi
28+
*.msm
29+
*.msp
30+
31+
# =========================
32+
# Operating System Files
33+
# =========================
34+
35+
# OSX
36+
# =========================
37+
38+
.DS_Store
39+
.AppleDouble
40+
.LSOverride
41+
42+
# Icon must ends with two \r.
43+
Icon
44+
45+
46+
# Thumbnails
47+
._*
48+
49+
# Files that might appear on external disk
50+
.Spotlight-V100
51+
.Trashes

0 commit comments

Comments
 (0)