|
2 | 2 | Orange Canvas Configuration |
3 | 3 |
|
4 | 4 | """ |
| 5 | +import pkgutil |
| 6 | + |
5 | 7 | import random |
6 | 8 | import uuid |
7 | 9 | import warnings |
|
11 | 13 | from typing import Dict, Any, Optional, Iterable, List |
12 | 14 |
|
13 | 15 | import packaging.version |
14 | | -import pkg_resources |
15 | 16 | import requests |
16 | 17 |
|
17 | 18 | from AnyQt.QtGui import ( |
18 | | - QPainter, QFont, QFontMetrics, QColor, QPixmap, QIcon, QGuiApplication |
| 19 | + QPainter, QFont, QFontMetrics, QColor, QImage, QPixmap, QIcon, |
| 20 | + QGuiApplication |
19 | 21 | ) |
20 | 22 | from AnyQt.QtCore import Qt, QPoint, QRect, QSettings |
21 | 23 |
|
22 | 24 | from orangecanvas import config as occonfig |
| 25 | +from orangecanvas.config import entry_points, EntryPoint |
23 | 26 | from orangecanvas.utils.settings import config_slot |
24 | 27 | from orangewidget.workflow import config |
25 | 28 | from orangewidget.settings import set_widget_settings_dir_components |
|
61 | 64 | spec = [config_slot(*t) for t in spec] |
62 | 65 |
|
63 | 66 |
|
| 67 | +def _pixmap_from_pkg_data(package, path, format): |
| 68 | + contents = pkgutil.get_data(package, path) |
| 69 | + return QPixmap.fromImage(QImage.fromData(contents, format)) |
| 70 | + |
| 71 | + |
64 | 72 | class Config(config.Config): |
65 | 73 | """ |
66 | 74 | Orange application configuration |
@@ -96,17 +104,16 @@ def application_icon(): |
96 | 104 | """ |
97 | 105 | Return the main application icon. |
98 | 106 | """ |
99 | | - path = pkg_resources.resource_filename( |
100 | | - __name__, "icons/orange-256.png" |
| 107 | + return QIcon( |
| 108 | + _pixmap_from_pkg_data(__package__, "icons/orange-256.png", "png") |
101 | 109 | ) |
102 | | - return QIcon(path) |
103 | 110 |
|
104 | 111 | @staticmethod |
105 | 112 | def splash_screen(): |
106 | 113 | splash_n = random.randint(1, 3) |
107 | | - path = pkg_resources.resource_filename( |
108 | | - __name__, f"icons/orange-splash-screen-{splash_n:02}.png") |
109 | | - pm = QPixmap(path) |
| 114 | + pm = _pixmap_from_pkg_data( |
| 115 | + __name__, f"icons/orange-splash-screen-{splash_n:02}.png", "png" |
| 116 | + ) |
110 | 117 |
|
111 | 118 | version = Config.ApplicationVersion |
112 | 119 | if version: |
@@ -138,9 +145,9 @@ def widgets_entry_points(): |
138 | 145 | # Ensure the 'this' distribution's ep is the first. iter_entry_points |
139 | 146 | # yields them in unspecified order. |
140 | 147 | all_eps = sorted( |
141 | | - pkg_resources.iter_entry_points(WIDGETS_ENTRY), |
| 148 | + entry_points(group=WIDGETS_ENTRY), |
142 | 149 | key=lambda ep: |
143 | | - 0 if ep.dist.project_name.lower() == "orange3" else 1 |
| 150 | + 0 if ep.dist.name.lower() == "orange3" else 1 |
144 | 151 | ) |
145 | 152 | return iter(all_eps) |
146 | 153 |
|
@@ -173,18 +180,18 @@ def core_packages(): |
173 | 180 |
|
174 | 181 | @staticmethod |
175 | 182 | def examples_entry_points(): |
176 | | - # type: () -> Iterable[pkg_resources.EntryPoint] |
| 183 | + # type: () -> Iterable[EntryPoint] |
177 | 184 | """ |
178 | 185 | Return an iterator over the entry points yielding 'Example Workflows' |
179 | 186 | """ |
180 | 187 | # `iter_entry_points` yields them in unspecified order, so we order |
181 | 188 | # them by name. The default is at the beginning, unless another |
182 | 189 | # entrypoint precedes it alphabetically (e.g. starting with '!'). |
183 | | - default_ep = pkg_resources.EntryPoint( |
184 | | - "000-Orange3", "Orange.canvas.workflows", |
185 | | - dist=pkg_resources.get_distribution("Orange3")) |
| 190 | + default_ep = EntryPoint( |
| 191 | + "000-Orange3", "Orange.canvas.workflows", "orange.widgets.tutorials", |
| 192 | + ) |
186 | 193 |
|
187 | | - all_ep = list(pkg_resources.iter_entry_points("orange.widgets.tutorials")) |
| 194 | + all_ep = list(entry_points(group="orange.widgets.tutorials")) |
188 | 195 | all_ep.append(default_ep) |
189 | 196 | all_ep.sort(key=lambda x: x.name) |
190 | 197 | return iter(all_ep) |
|
0 commit comments