-
Notifications
You must be signed in to change notification settings - Fork 4
/
settings.py
167 lines (133 loc) · 7.67 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import bpy
import sys
from bpy.types import AddonPreferences
if bpy.app.version >= (2, 91, 0):
PYPATH = sys.executable
else:
PYPATH = bpy.app.binary_path_python
import megapolis
from sverchok.dependencies import draw_message
from megapolis.dependencies import ex_dependencies, pip, ensurepip
from sverchok.utils.context_managers import addon_preferences
from sverchok.ui.utils import message_on_layout
COMMITS_LINK = 'https://api.github.com/repos/victorcalixto/mega-polis/commits'
ADDON_NAME = megapolis.__name__
ADDON_PRETTY_NAME = 'MEGA-POLIS'
ARCHIVE_LINK = 'https://github.com/victorcalixto/mega-polis/archive/'
MASTER_BRANCH_NAME = 'main'
def draw_in_sv_prefs(layout):
draw_message(layout, "geopandas", dependencies=ex_dependencies)
draw_message(layout, "leafmap", dependencies=ex_dependencies)
draw_message(layout, "osmnx", dependencies=ex_dependencies)
draw_message(layout, "pandas", dependencies=ex_dependencies)
draw_message(layout, "laspy", dependencies=ex_dependencies)
draw_message(layout, "rasterio", dependencies=ex_dependencies)
draw_message(layout, "pillow", dependencies=ex_dependencies)
draw_message(layout, "mapillary", dependencies=ex_dependencies)
draw_message(layout, "wget", dependencies=ex_dependencies)
draw_message(layout, "networkx", dependencies=ex_dependencies)
draw_message(layout, "scikit-learn", dependencies=ex_dependencies)
draw_message(layout, "streamlit", dependencies=ex_dependencies)
draw_message(layout, "pyvista", dependencies=ex_dependencies)
draw_message(layout, "seaborn", dependencies=ex_dependencies)
draw_message(layout, "visilibity", dependencies=ex_dependencies)
draw_message(layout, "opencv-python", dependencies=ex_dependencies)
draw_message(layout, "keplergl", dependencies=ex_dependencies)
draw_message(layout, "plotly", dependencies=ex_dependencies)
draw_message(layout, "requests", dependencies=ex_dependencies)
draw_message(layout, "bokeh", dependencies=ex_dependencies)
draw_message(layout, "pythreejs", dependencies=ex_dependencies)
draw_message(layout, "shapely", dependencies=ex_dependencies)
draw_message(layout, "pyproj", dependencies=ex_dependencies)
draw_message(layout, "detectron2", dependencies=ex_dependencies)
draw_message(layout, "torch", dependencies=ex_dependencies)
draw_message(layout, "tabulate", dependencies=ex_dependencies)
draw_message(layout, "psutil", dependencies=ex_dependencies)
draw_message(layout, "matplotlib", dependencies=ex_dependencies)
draw_message(layout, "richdem", dependencies=ex_dependencies)
def update_addon_ui(layout):
layout.operator('node.sv_show_latest_commits', text='Show Last Commits').commits_link = COMMITS_LINK
with addon_preferences(ADDON_NAME) as prefs:
if not prefs.available_new_version:
check = layout.operator('node.sverchok_check_for_upgrades_wsha', text='Check for Upgrades')
check.commits_link = COMMITS_LINK
check.addon_name = ADDON_NAME
else:
update_op = layout.operator('node.sverchok_update_addon', text=f'Upgrade {ADDON_PRETTY_NAME}')
update_op.addon_name = ADDON_NAME
update_op.master_branch_name = MASTER_BRANCH_NAME
update_op.archive_link = ARCHIVE_LINK
def sv_draw_update_menu_in_panel(self, context):
layout = self.layout
box = layout.box()
box.label(text=ADDON_PRETTY_NAME)
update_addon_ui(box)
class SvMegapolisPreferences(AddonPreferences):
bl_idname = __package__
available_new_version: bpy.props.BoolProperty(default=False)
dload_archive_name: bpy.props.StringProperty(name="archive name", default=MASTER_BRANCH_NAME) # default = "master"
dload_archive_path: bpy.props.StringProperty(name="archive path", default=ARCHIVE_LINK)
def draw(self, context):
layout = self.layout
def get_icon(package):
if package is None:
return 'CANCEL'
else:
return 'CHECKMARK'
box = layout.box()
box.label(text="Dependencies:")
draw_message(box, "sverchok", dependencies=ex_dependencies)
draw_message(box, "geopandas", dependencies=ex_dependencies)
draw_message(box, "leafmap", dependencies=ex_dependencies)
draw_message(box, "osmnx", dependencies=ex_dependencies)
draw_message(box, "pandas", dependencies=ex_dependencies)
draw_message(box, "laspy", dependencies=ex_dependencies)
draw_message(box, "rasterio", dependencies=ex_dependencies)
draw_message(box, "pillow", dependencies=ex_dependencies)
draw_message(box, "mapillary", dependencies=ex_dependencies)
draw_message(box, "wget", dependencies=ex_dependencies)
draw_message(box, "networkx", dependencies=ex_dependencies)
draw_message(box, "scikit-learn", dependencies=ex_dependencies)
draw_message(box, "streamlit", dependencies=ex_dependencies)
draw_message(box, "pyvista", dependencies=ex_dependencies)
draw_message(box, "seaborn", dependencies=ex_dependencies)
draw_message(box, "visilibity", dependencies=ex_dependencies)
box.operator('wm.url_open', text="Read installation instructions for Swig (Visilibity dependency)").url="https://swig.org/download.html"
draw_message(box, "opencv-python", dependencies=ex_dependencies)
draw_message(box, "keplergl", dependencies=ex_dependencies)
draw_message(box, "plotly", dependencies=ex_dependencies)
draw_message(box, "requests", dependencies=ex_dependencies)
draw_message(box, "pythreejs", dependencies=ex_dependencies)
draw_message(box, "bokeh", dependencies=ex_dependencies)
draw_message(box, "shapely", dependencies=ex_dependencies)
draw_message(box, "pyproj", dependencies=ex_dependencies)
draw_message(box, "detectron2", dependencies=ex_dependencies)
draw_message(box, "torch", dependencies=ex_dependencies)
draw_message(box, "tabulate", dependencies=ex_dependencies)
draw_message(box, "psutil", dependencies=ex_dependencies)
draw_message(box, "matplotlib", dependencies=ex_dependencies)
draw_message(box, "richdem", dependencies=ex_dependencies)
box_extra = layout.box()
box_extra.label(text="Extra Dependencies:")
box_extra.operator('wm.url_open', text="Read installation instructions for Detectron 2").url="https://detectron2.readthedocs.io/en/latest/tutorials/install.html"
box_extra.operator('wm.url_open', text="Read installation instructions in Pytorch website to install pytorch torchvision torchaudio cudatoolkit").url="https://pytorch.org/"
box_extra.operator('wm.url_open', text="Read installation instructions for Rustup (Whitebox Tool dependency)").url="https://rustup.rs/"
row = layout.row()
row.operator('node.sv_show_latest_commits').commits_link = COMMITS_LINK
if not self.available_new_version:
check = row.operator('node.sverchok_check_for_upgrades_wsha', text='Check for Upgrades')
check.commits_link = COMMITS_LINK
check.addon_name = ADDON_NAME
else:
update_op = row.operator('node.sverchok_update_addon', text=f'Upgrade {ADDON_PRETTY_NAME}')
update_op.addon_name = ADDON_NAME
update_op.master_branch_name = MASTER_BRANCH_NAME
update_op.archive_link = ARCHIVE_LINK
def register():
bpy.utils.register_class(SvMegapolisPreferences)
bpy.types.SV_PT_SverchokUtilsPanel.append(sv_draw_update_menu_in_panel)
def unregister():
bpy.utils.unregister_class(SvMegapolisPreferences)
bpy.types.SV_PT_SverchokUtilsPanel.remove(sv_draw_update_menu_in_panel)
if __name__ == '__main__':
register()