Skip to content

Commit d87eddf

Browse files
committed
Make pyqrcode optional
1 parent 31f322f commit d87eddf

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

meshtastic/__main__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
import time
1414
from typing import List, Optional
1515

16-
import pyqrcode # type: ignore[import-untyped]
16+
try:
17+
import pyqrcode # type: ignore[import-untyped]
18+
except ImportError as e:
19+
pyqrcode = None
20+
1721
import yaml
1822
from google.protobuf.json_format import MessageToDict
1923
from pubsub import pub # type: ignore[import-untyped]
@@ -896,8 +900,11 @@ def setSimpleConfig(modem_preset):
896900
else:
897901
urldesc = "Primary channel URL"
898902
print(f"{urldesc}: {url}")
899-
qr = pyqrcode.create(url)
900-
print(qr.terminal())
903+
if pyqrcode is not None:
904+
qr = pyqrcode.create(url)
905+
print(qr.terminal())
906+
else:
907+
print("Install pyqrcode to view a QR code printed to terminal.")
901908

902909
log_set: Optional = None # type: ignore[annotation-unchecked]
903910
# we need to keep a reference to the logset so it doesn't get GCed early

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ readme = "README.md"
1010
python = "^3.9,<3.14" # 3.9 is needed for pandas, bleak requires <3.14
1111
pyserial = "^3.5"
1212
protobuf = ">=4.21.12"
13-
pyqrcode = "^1.2.1"
1413
tabulate = "^0.9.0"
1514
requests = "^2.31.0"
1615
pyyaml = "^6.0.1"
1716
pypubsub = "^4.0.3"
1817
bleak = "^0.22.3"
1918
packaging = "^24.0"
19+
pyqrcode = { version = "^1.2.1", optional = true }
2020
dotmap = { version = "^1.3.30", optional = true }
2121
print-color = { version = "^0.4.6", optional = true }
2222
dash = { version = "^2.17.1", optional = true }

0 commit comments

Comments
 (0)