Skip to content

Commit 68836b1

Browse files
authored
Merge pull request #606 from geeksville/pr-poetry
Change build to use poetry
2 parents b15e27c + 195f0c9 commit 68836b1

17 files changed

Lines changed: 1705 additions & 213 deletions

.github/workflows/ci.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,29 @@ jobs:
1818
- "3.10"
1919
- "3.11"
2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
2222
- name: Install Python 3
23-
uses: actions/setup-python@v1
23+
uses: actions/setup-python@v5
2424
- name: Uninstall meshtastic
2525
run: |
26-
pip3 uninstall meshtastic
26+
pip3 uninstall -y meshtastic
2727
- name: Install dependencies
2828
run: |
2929
python -m pip install --upgrade pip
30-
pip3 install -r requirements.txt
30+
pip3 install poetry
3131
- name: Install meshtastic from local
3232
run: |
33-
pip3 install .
34-
which meshtastic
35-
meshtastic --version
33+
poetry install
34+
poetry run meshtastic --version
3635
- name: Run pylint
37-
run: pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"
36+
run: poetry run pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"
3837
- name: Check types with mypy
39-
run: mypy meshtastic/
38+
run: poetry run mypy meshtastic/
4039
- name: Run tests with pytest
41-
run: pytest --cov=meshtastic
40+
run: poetry run pytest --cov=meshtastic
4241
- name: Generate coverage report
4342
run: |
44-
pytest --cov=meshtastic --cov-report=xml
43+
poetry run pytest --cov=meshtastic --cov-report=xml
4544
- name: Upload coverage to Codecov
4645
uses: codecov/codecov-action@v4
4746
with:
@@ -62,11 +61,12 @@ jobs:
6261
- "3.10"
6362
- "3.11"
6463
steps:
65-
- uses: actions/checkout@v2
64+
- uses: actions/checkout@v4
6665
- name: Install Python 3
67-
uses: actions/setup-python@v1
66+
uses: actions/setup-python@v5
6867
- name: Install meshtastic from local
6968
run: |
70-
pip3 install .
71-
which meshtastic
72-
meshtastic --version
69+
python -m pip install --upgrade pip
70+
pip3 install poetry
71+
poetry install
72+
poetry run meshtastic --version

.github/workflows/release.yml

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,36 @@ jobs:
1212

1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python 3.9
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.9"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip3 install poetry
1626
1727
- name: Bump version
1828
run: >-
19-
bin/bump_version.py
29+
poetry version patch
2030
21-
- name: Commit updated version.py
31+
- name: Commit updated version.
2232
id: commit_updated
2333
run: |
2434
git config --global user.name 'github-actions'
2535
git config --global user.email 'bot@noreply.github.com'
2636
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
27-
git add setup.py
37+
git add pyproject.toml
2838
git commit -m "bump version" && git push || echo "No changes to commit"
2939
git log -n 1 --pretty=format:"%H" | tail -n 1 | awk '{print "::set-output name=sha::"$0}'
3040
3141
- name: Get version
3242
id: get_version
3343
run: >-
34-
bin/show_version.py
44+
poetry version
3545
3646
- name: Create GitHub release
3747
uses: actions/create-release@v1
@@ -47,26 +57,9 @@ jobs:
4757
env:
4858
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4959

50-
- name: Set up Python 3.9
51-
uses: actions/setup-python@v2
52-
with:
53-
python-version: 3.9
54-
55-
- name: Install pypa/build
56-
run: >-
57-
python -m
58-
pip install
59-
build
60-
--user
61-
6260
- name: Build a binary wheel and a source tarball
6361
run: >-
64-
python -m
65-
build
66-
--sdist
67-
--wheel
68-
--outdir dist/
69-
.
62+
poetry build
7063
7164
- name: Publish to PyPI
7265
uses: pypa/gh-action-pypi-publish@master
@@ -79,14 +72,14 @@ jobs:
7972
# needs: release_create
8073
# steps:
8174
# - name: Checkout
82-
# uses: actions/checkout@v3
75+
# uses: actions/checkout@v4
8376
# with:
8477
# ref: ${{ needs.release_create.outputs.new_sha }}
8578

8679
# - name: Set up Python 3.9
87-
# uses: actions/setup-python@v2
80+
# uses: actions/setup-python@v5
8881
# with:
89-
# python-version: 3.9
82+
# python-version: "3.9"
9083

9184
# - name: Setup code signing
9285
# env:
@@ -125,21 +118,19 @@ jobs:
125118
needs: release_create
126119
steps:
127120
- name: Checkout
128-
uses: actions/checkout@v3
121+
uses: actions/checkout@v4
129122
with:
130123
ref: ${{ needs.release_create.outputs.new_sha }}
131124

132125
- name: Set up Python 3.9
133-
uses: actions/setup-python@v2
126+
uses: actions/setup-python@v5
134127
with:
135-
python-version: 3.9
128+
python-version: "3.9"
136129

137130
- name: Build
138131
run: |
139-
pip install pyinstaller
140-
pip install -r requirements.txt
141-
pip install .
142-
pyinstaller -F -n meshtastic --collect-all meshtastic meshtastic/__main__.py
132+
pip install poetry
133+
bin/build-bin.sh
143134
144135
- name: Add ubuntu to release
145136
uses: actions/upload-release-asset@v1
@@ -166,21 +157,19 @@ jobs:
166157
needs: release_create
167158
steps:
168159
- name: Checkout
169-
uses: actions/checkout@v3
160+
uses: actions/checkout@v4
170161
with:
171162
ref: ${{ needs.release_create.outputs.new_sha }}
172163

173164
- name: Set up Python 3.9
174-
uses: actions/setup-python@v2
165+
uses: actions/setup-python@v5
175166
with:
176-
python-version: 3.9
167+
python-version: "3.9"
177168

178169
- name: Build
179170
run: |
180-
pip install pyinstaller
181-
pip install -r requirements.txt
182-
pip install .
183-
pyinstaller -F -n meshtastic --collect-all meshtastic meshtastic/__main__.py
171+
pip install poetry
172+
bin/build-bin.sh
184173
185174
- name: Add windows to release
186175
uses: actions/upload-release-asset@v1

.github/workflows/update_protobufs.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77

88
steps:
99
- name: Checkout code
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@v4
1111
with:
1212
submodules: true
1313

@@ -18,9 +18,14 @@ jobs:
1818
1919
- name: Download nanopb
2020
run: |
21-
wget https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.6-linux-x86.tar.gz
22-
tar xvzf nanopb-0.4.6-linux-x86.tar.gz
23-
mv nanopb-0.4.6-linux-x86 nanopb-0.4.6
21+
wget https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.8-linux-x86.tar.gz
22+
tar xvzf nanopb-0.4.8-linux-x86.tar.gz
23+
mv nanopb-0.4.8-linux-x86 nanopb-0.4.8
24+
25+
- name: Install poetry (needed by regen-protobufs.sh)
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip3 install poetry
2429
2530
- name: Re-generate protocol buffers
2631
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ __pycache__
1616
examples/__pycache__
1717
meshtastic.spec
1818
.hypothesis/
19+
coverage.xml

bin/build-bin.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo Building ubuntu binary
6+
poetry install
7+
source $(poetry env info --path)/bin/activate
8+
pyinstaller -F -n meshtastic --collect-all meshtastic meshtastic/__main__.py
9+

bin/bump_version.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

bin/prerelease-tests.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ set -e
33
# You may consider running: "pytest -m smoke1" instead of this test.
44

55
echo "Running (crude) prerelease tests to verify sanity"
6+
7+
# Use the python environment created by poetry
8+
source $(poetry env info --path)/bin/activate
9+
610
echo running hello
711
python3 tests/hello_world.py
8-
# bin/run.sh --help
12+
# meshtastic --help
913
echo toggling router
10-
bin/run.sh --set is_router true
11-
bin/run.sh --set is_router false
14+
meshtastic --set is_router true
15+
meshtastic --set is_router false
1216
# TODO: This does not seem to work.
1317
echo setting channel
14-
bin/run.sh --seturl "https://www.meshtastic.org/c/#GAMiENTxuzogKQdZ8Lz_q89Oab8qB0RlZmF1bHQ="
18+
meshtastic --seturl "https://www.meshtastic.org/c/#GAMiENTxuzogKQdZ8Lz_q89Oab8qB0RlZmF1bHQ="
1519
echo setting owner
16-
bin/run.sh --set-owner "Test Build"
20+
meshtastic --set-owner "Test Build"
1721
echo setting position
18-
bin/run.sh --setlat 32.7767 --setlon -96.7970 --setalt 1337
22+
meshtastic --setlat 32.7767 --setlon -96.7970 --setalt 1337
1923
echo dumping info
20-
bin/run.sh --info
24+
meshtastic run meshtastic --info
2125
echo sending closing message
22-
bin/run.sh --sendtext "Sanity complete"
26+
meshtastic --sendtext "Sanity complete"

bin/regen-protobufs.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
#gsed -i 's/import "\//import ".\//g' ./protobufs/meshtastic/*
55
#gsed -i 's/package meshtastic;//g' ./protobufs/meshtastic/*
66

7-
./nanopb-0.4.7/generator-bin/protoc -I=protobufs --python_out ./ --mypy_out ./ ./protobufs/meshtastic/*.proto
8-
./nanopb-0.4.7/generator-bin/protoc -I=protobufs --python_out ./meshtastic/ --mypy_out ./meshtastic/ ./protobufs/nanopb.proto
7+
# protoc looks for mypy plugin in the python path
8+
source $(poetry env info --path)/bin/activate
9+
10+
./nanopb-0.4.8/generator-bin/protoc -I=protobufs --python_out ./ --mypy_out ./ ./protobufs/meshtastic/*.proto
11+
./nanopb-0.4.8/generator-bin/protoc -I=protobufs --python_out ./meshtastic/ --mypy_out ./meshtastic/ ./protobufs/nanopb.proto
912

1013
# workaround for import bug in protoc https://github.com/protocolbuffers/protobuf/issues/1491#issuecomment-690618628
1114

bin/run-ci-local.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# This script lets you run github ci actions locally
4+
# You need to have act installed. You can get it at https://nektosact.com/
5+
6+
# by default it simulates a push event
7+
# other useful options
8+
# -j build-and-publish-ubuntu
9+
10+
# also: we only run one of the 4 matrix tests, because otherwise it absolutely hammers the CPU (so many containers and threads)
11+
act -P ubuntu-latest=-self-hosted --matrix "python-version:3.8" "$@"

bin/run.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)