File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import sys
1010import time
1111
12- import pkg_resources
1312import pyqrcode
1413import yaml
1514from google .protobuf .json_format import MessageToDict
1817import meshtastic .test
1918import meshtastic .util
2019from meshtastic import channel_pb2 , config_pb2 , portnums_pb2 , remote_hardware
20+ from meshtastic .version import get_active_version
2121from meshtastic .__init__ import BROADCAST_ADDR
2222from meshtastic .ble_interface import BLEInterface
2323from meshtastic .globals import Globals
@@ -1399,7 +1399,7 @@ def initParser():
13991399
14001400 parser .set_defaults (deprecated = None )
14011401
1402- the_version = pkg_resources . get_distribution ( "meshtastic" ). version
1402+ the_version = get_active_version ()
14031403 parser .add_argument ("--version" , action = "version" , version = f"{ the_version } " )
14041404
14051405 parser .add_argument (
Original file line number Diff line number Diff line change 1212import traceback
1313from queue import Queue
1414
15- import pkg_resources
15+ import packaging . version as pkg_version
1616import requests
1717import serial
1818import serial .tools .list_ports
1919
2020from meshtastic .supported_device import supported_devices
21+ from meshtastic .version import get_active_version
2122
2223"""Some devices such as a seger jlink we never want to accidentally open"""
2324blacklistVids = dict .fromkeys ([0x1366 ])
@@ -269,7 +270,7 @@ def support_info():
269270 print (f" Machine: { platform .uname ().machine } " )
270271 print (f" Encoding (stdin): { sys .stdin .encoding } " )
271272 print (f" Encoding (stdout): { sys .stdout .encoding } " )
272- the_version = pkg_resources . get_distribution ( "meshtastic" ). version
273+ the_version = get_active_version ()
273274 pypi_version = check_if_newer_version ()
274275 if pypi_version :
275276 print (
@@ -599,9 +600,15 @@ def check_if_newer_version():
599600 pypi_version = data ["info" ]["version" ]
600601 except Exception :
601602 pass
602- act_version = pkg_resources .get_distribution ("meshtastic" ).version
603- if pypi_version and pkg_resources .parse_version (
604- pypi_version
605- ) <= pkg_resources .parse_version (act_version ):
603+ act_version = get_active_version ()
604+
605+ try :
606+ parsed_act_version = pkg_version .parse (act_version )
607+ parsed_pypi_version = pkg_version .parse (pypi_version )
608+ except pkg_version .InvalidVersion :
609+ return pypi_version
610+
611+ if parsed_pypi_version <= parsed_act_version :
606612 return None
613+
607614 return pypi_version
Original file line number Diff line number Diff line change 1+ import sys
2+ try :
3+ from importlib .metadata import version
4+ except :
5+ import pkg_resources
6+
7+ def get_active_version ():
8+ if "importlib.metadata" in sys .modules :
9+ return version ("meshtastic" )
10+ else :
11+ return pkg_resources .get_distribution ("meshtastic" ).version
You can’t perform that action at this time.
0 commit comments