Skip to content
Open
2 changes: 1 addition & 1 deletion dronecan_gui_tool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# Start method must be configured globally, and only once. Using 'spawn' ensures full compatibility with Windoze.
# We need to check first if the start mode is already configured, because this code will be re-run for every child.
#
if multiprocessing.get_start_method(True) != 'spawn':
if multiprocessing.get_start_method(allow_none=True) is None:
multiprocessing.set_start_method('spawn')

#
Expand Down
7 changes: 4 additions & 3 deletions dronecan_gui_tool/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import os
import re
import pkg_resources
import importlib.resources
import queue
from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem, QAbstractItemView, QHeaderView, QApplication, QWidget, \
QComboBox, QCompleter, QPushButton, QHBoxLayout, QVBoxLayout, QMessageBox
Expand Down Expand Up @@ -640,8 +640,9 @@ def get_app_icon():
pass
# noinspection PyBroadException
try:
fn = pkg_resources.resource_filename('dronecan_gui_tool', os.path.join('icons', 'dronecan_gui_tool.png'))
_APP_ICON_OBJECT = QIcon(fn)
icon_resource = importlib.resources.files('dronecan_gui_tool').joinpath('icons', 'dronecan_gui_tool.png')
with importlib.resources.as_file(icon_resource) as icon_path:
_APP_ICON_OBJECT = QIcon(str(icon_path))
except Exception:
logger.error('Could not load icon', exc_info=True)
_APP_ICON_OBJECT = QIcon()
Expand Down
20 changes: 11 additions & 9 deletions pip_sizes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

import os
import pkg_resources
import importlib.metadata

def calc_container(path):
total_size = 0
Expand All @@ -13,24 +13,26 @@ def calc_container(path):



dists = [d for d in pkg_resources.working_set]
dists = list(importlib.metadata.distributions())

data = {}
data2 = []
data3 = {}

for dist in dists:
try:
path = os.path.join(dist.location, dist.project_name)
dist_name = dist.metadata.get('Name', 'unknown')
path = os.path.join(str(dist.locate_file('')), dist_name)
if not os.path.exists(path):
path = os.path.join(str(dist.locate_file('')), dist_name.replace('-', '_'))
size = calc_container(path)
if size/1000 > 1.0:
#print (f"{dist}: {size/1000} KB")
data[size] = f"{dist}: {size/1000} KB"
a = f"{dist}"
data2.append(a.split()[0])# first word
data3[a.split()[0]] = f"{dist}: {size/1000} KB"
dist_label = f"{dist_name} {dist.metadata.get('Version', '')}"
data[size] = f"{dist_label}: {size/1000} KB"
data2.append(dist_name)
data3[dist_name] = f"{dist_label}: {size/1000} KB"
except OSError:
'{} no longer exists'.format(dist.project_name)
pass

sorted_dict = dict(sorted(data.items()))
sorted_dict2 = sorted(data2)
Expand Down
16 changes: 10 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
import os
import sys
import shutil
import pkg_resources
import glob
from setuptools import setup, find_packages
from setuptools.archive_util import unpack_archive

PACKAGE_NAME = 'dronecan_gui_tool'
HUMAN_FRIENDLY_NAME = 'DroneCAN GUI Tool'
Expand Down Expand Up @@ -115,6 +113,8 @@

if ('bdist_msi' in sys.argv) or ('build_exe' in sys.argv):
import cx_Freeze
import importlib.metadata
from setuptools.archive_util import unpack_archive

# cx_Freeze can't handle 3rd-party packages packed in .egg files, so we have to extract them for it
dependency_eggs_to_unpack = [
Expand All @@ -130,9 +130,13 @@
except Exception:
pass
for dep in dependency_eggs_to_unpack:
for egg in pkg_resources.require(dep):
if not os.path.isdir(egg.location):
unpack_archive(egg.location, unpacked_eggs_dir)
try:
dist = importlib.metadata.distribution(dep)
except importlib.metadata.PackageNotFoundError:
continue
dist_location = str(dist.locate_file(''))
if not os.path.isdir(dist_location):
unpack_archive(dist_location, unpacked_eggs_dir)

import qtawesome
import qtconsole
Expand All @@ -153,7 +157,7 @@
args['options'] = {
'build_exe': {
'packages': [
'pkg_resources',
'importlib.metadata',
'zmq',
'pygments',
'jupyter_client',
Expand Down