inkstitch: 3.1.0 -> 3.2.2

Inkstitch requires a unreleased version of inkex, which is overwritten
in-place. Injecting it requires messing with the pythonpath within the
plugin (as Inkscape meddles with it itself), which is done through a
wrapper.

authored by tropf and committed by Sandro Jäckel 6784df30 bfb2d2f3

+566 -13
+4 -4
pkgs/applications/graphics/inkscape/extensions/inkstitch/0001-force-frozen-true.patch
··· 1 - From af541a4f8ddda287f74687327e4ed89b79557777 Mon Sep 17 00:00:00 2001 2 From: tropf <tropf@noreply.codeberg.org> 3 Date: Mon, 5 Aug 2024 21:25:33 +0200 4 - Subject: [PATCH 1/3] force frozen=true 5 6 Enforce installation in frozen mode, i.e. as a packaged version where 7 source can not be modified. ··· 10 1 file changed, 1 insertion(+), 1 deletion(-) 11 12 diff --git a/inkstitch.py b/inkstitch.py 13 - index 50f33d19..398465ca 100644 14 --- a/inkstitch.py 15 +++ b/inkstitch.py 16 @@ -40,7 +40,7 @@ else: ··· 23 if not running_as_frozen: # override running_as_frozen from DEBUG.toml - for testing 24 if safe_get(ini, "DEBUG", "force_frozen", default=False): 25 -- 26 - 2.36.0 27
··· 1 + From 64f735a58d3e5cc2344f823e73602eab638d7076 Mon Sep 17 00:00:00 2001 2 From: tropf <tropf@noreply.codeberg.org> 3 Date: Mon, 5 Aug 2024 21:25:33 +0200 4 + Subject: [PATCH 1/4] force frozen=true 5 6 Enforce installation in frozen mode, i.e. as a packaged version where 7 source can not be modified. ··· 10 1 file changed, 1 insertion(+), 1 deletion(-) 11 12 diff --git a/inkstitch.py b/inkstitch.py 13 + index efe6f6dec..be8ddf665 100644 14 --- a/inkstitch.py 15 +++ b/inkstitch.py 16 @@ -40,7 +40,7 @@ else: ··· 23 if not running_as_frozen: # override running_as_frozen from DEBUG.toml - for testing 24 if safe_get(ini, "DEBUG", "force_frozen", default=False): 25 -- 26 + 2.49.0 27
+4 -4
pkgs/applications/graphics/inkscape/extensions/inkstitch/0002-plugin-invocation-use-python-script-as-entrypoint.patch
··· 1 - From a86412c57833c24743214c9d3abb76093365769f Mon Sep 17 00:00:00 2001 2 From: tropf <tropf@noreply.codeberg.org> 3 Date: Mon, 5 Aug 2024 21:26:13 +0200 4 - Subject: [PATCH 2/3] plugin invocation: use python script as entrypoint 5 6 Ink/Stitch is invoked by calling a script with command line parameters. 7 Depending on the distribution format, this is bundled into a standalone ··· 17 1 file changed, 1 insertion(+), 1 deletion(-) 18 19 diff --git a/lib/inx/utils.py b/lib/inx/utils.py 20 - index 9168f2a2..00313639 100755 21 --- a/lib/inx/utils.py 22 +++ b/lib/inx/utils.py 23 @@ -21,7 +21,7 @@ def build_environment(): ··· 30 # Command tag and icons path 31 if sys.platform == "win32": 32 -- 33 - 2.36.0 34
··· 1 + From c15715af2cfca6603241f4d414b68d43bd4acb98 Mon Sep 17 00:00:00 2001 2 From: tropf <tropf@noreply.codeberg.org> 3 Date: Mon, 5 Aug 2024 21:26:13 +0200 4 + Subject: [PATCH 2/4] plugin invocation: use python script as entrypoint 5 6 Ink/Stitch is invoked by calling a script with command line parameters. 7 Depending on the distribution format, this is bundled into a standalone ··· 17 1 file changed, 1 insertion(+), 1 deletion(-) 18 19 diff --git a/lib/inx/utils.py b/lib/inx/utils.py 20 + index c4cbf6f0d..6d4774ec0 100755 21 --- a/lib/inx/utils.py 22 +++ b/lib/inx/utils.py 23 @@ -21,7 +21,7 @@ def build_environment(): ··· 30 # Command tag and icons path 31 if sys.platform == "win32": 32 -- 33 + 2.49.0 34
+490
pkgs/applications/graphics/inkscape/extensions/inkstitch/0003-lazy-load-module-to-access-global_settings.patch
···
··· 1 + From 87d64cbc61175a2adebd4563ac833562a4729295 Mon Sep 17 00:00:00 2001 2 + From: tropf <tropf@noreply.codeberg.org> 3 + Date: Fri, 16 May 2025 23:28:21 +0200 4 + Subject: [PATCH 3/4] lazy-load module to access global_settings 5 + 6 + The access to global_settings triggers a read to the home directory on 7 + module inclusion. During the nix build process, this home does not 8 + exist, and hence fails, crashing the entire build. 9 + 10 + The inclusion is moved into the function calls, such that it is only 11 + loaded at runtime (where a home should be available), but not at build 12 + time. 13 + 14 + The performance impact is considered negligible, as the loads are called 15 + every invocation, but will mostly hit the cache. 16 + 17 + Note to self: If this patch is missing, the cache module import will be 18 + the first to trigger the read. This import can be left untouched, as the 19 + underlying cause is defused by this patch. 20 + --- 21 + lib/gui/apply_palette.py | 3 ++- 22 + lib/gui/edit_json/main_panel.py | 3 ++- 23 + lib/gui/lettering/main_panel.py | 6 +++++- 24 + lib/gui/lettering_font_sample.py | 4 +++- 25 + lib/gui/preferences.py | 3 ++- 26 + lib/gui/simulator/control_panel.py | 4 +++- 27 + lib/gui/simulator/drawing_panel.py | 6 +++++- 28 + lib/gui/simulator/simulator_preferences.py | 5 ++++- 29 + lib/gui/simulator/split_simulator_window.py | 4 +++- 30 + lib/gui/simulator/view_panel.py | 6 +++++- 31 + lib/metadata.py | 3 +-- 32 + lib/sew_stack/stitch_layers/stitch_layer_editor.py | 3 ++- 33 + lib/utils/cache.py | 6 +++--- 34 + 13 files changed, 40 insertions(+), 16 deletions(-) 35 + 36 + diff --git a/lib/gui/apply_palette.py b/lib/gui/apply_palette.py 37 + index 6bc771914..df647d082 100644 38 + --- a/lib/gui/apply_palette.py 39 + +++ b/lib/gui/apply_palette.py 40 + @@ -8,12 +8,12 @@ import wx.adv 41 + 42 + from ..i18n import _ 43 + from ..threads import ThreadCatalog 44 + -from ..utils.settings import global_settings 45 + 46 + 47 + class ApplyPaletteFrame(wx.Frame): 48 + 49 + def __init__(self, title, **kwargs): 50 + + from ..utils.settings import global_settings 51 + super().__init__(None, title=title) 52 + 53 + self.SetWindowStyle(wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE) 54 + @@ -99,6 +99,7 @@ class ApplyPaletteApp(wx.App): 55 + app.MainLoop() 56 + 57 + def set_palette(self): 58 + + from ..utils.settings import global_settings 59 + if self.frame.palette_list.GetSelection() == -1: 60 + return 61 + self.palette = self.frame.palette_list.GetString(self.frame.palette_list.GetSelection()) 62 + diff --git a/lib/gui/edit_json/main_panel.py b/lib/gui/edit_json/main_panel.py 63 + index bd43f523b..5eb9d4cc9 100644 64 + --- a/lib/gui/edit_json/main_panel.py 65 + +++ b/lib/gui/edit_json/main_panel.py 66 + @@ -22,7 +22,6 @@ from ...lettering.categories import FONT_CATEGORIES 67 + from ...lettering.font_variant import FontVariant 68 + from ...stitch_plan import stitch_groups_to_stitch_plan 69 + from ...svg.tags import SVG_PATH_TAG 70 + -from ...utils.settings import global_settings 71 + from ...utils.threading import ExitThread, check_stop_flag 72 + from .. import PreviewRenderer, WarningPanel 73 + from . import HelpPanel, SettingsPanel 74 + @@ -33,6 +32,7 @@ LETTER_CASE = {0: '', 1: 'upper', 2: 'lower'} 75 + class LetteringEditJsonPanel(wx.Panel): 76 + 77 + def __init__(self, parent, simulator, layer, metadata=None, background_color='white'): 78 + + from ...utils.settings import global_settings 79 + self.parent = parent 80 + self.simulator = simulator 81 + self.layer = layer 82 + @@ -251,6 +251,7 @@ class LetteringEditJsonPanel(wx.Panel): 83 + return glyph 84 + 85 + def on_font_changed(self, event=None): 86 + + from ...utils.settings import global_settings 87 + selected_font = self.settings_panel.font_chooser.GetValue() 88 + if selected_font: 89 + self.font = self.fonts[selected_font] 90 + diff --git a/lib/gui/lettering/main_panel.py b/lib/gui/lettering/main_panel.py 91 + index 64312b5a1..5ed11b247 100644 92 + --- a/lib/gui/lettering/main_panel.py 93 + +++ b/lib/gui/lettering/main_panel.py 94 + @@ -17,7 +17,6 @@ from ...lettering.categories import FONT_CATEGORIES 95 + from ...stitch_plan import stitch_groups_to_stitch_plan 96 + from ...svg.tags import INKSTITCH_LETTERING 97 + from ...utils import DotDict, cache 98 + -from ...utils.settings import global_settings 99 + from ...utils.threading import ExitThread, check_stop_flag 100 + from .. import PresetsPanel, PreviewRenderer, info_dialog 101 + from . import LetteringHelpPanel, LetteringOptionsPanel 102 + @@ -73,6 +72,7 @@ class LetteringPanel(wx.Panel): 103 + 104 + def load_settings(self): 105 + """Load the settings saved into the SVG group element""" 106 + + from ...utils.settings import global_settings 107 + 108 + self.settings = DotDict({ 109 + "text": "", 110 + @@ -184,12 +184,14 @@ class LetteringPanel(wx.Panel): 111 + 112 + @property 113 + def default_font(self): 114 + + from ...utils.settings import global_settings 115 + try: 116 + return self.fonts[global_settings['last_font']] 117 + except KeyError: 118 + return list(self.fonts.values())[0] 119 + 120 + def on_change(self, attribute, event): 121 + + from ...utils.settings import global_settings 122 + value = event.GetEventObject().GetValue() 123 + self.settings[attribute] = value 124 + if attribute == "text" and self.options_panel.font_glyph_filter.GetValue() is True: 125 + @@ -206,6 +208,7 @@ class LetteringPanel(wx.Panel): 126 + self.update_preview() 127 + 128 + def on_choice_change(self, attribute, event=None): 129 + + from ...utils.settings import global_settings 130 + value = event.GetEventObject().GetCurrentSelection() 131 + self.settings[attribute] = value 132 + if attribute == 'trim_option': 133 + @@ -215,6 +218,7 @@ class LetteringPanel(wx.Panel): 134 + self.update_preview() 135 + 136 + def on_font_changed(self, event=None): 137 + + from ...utils.settings import global_settings 138 + font = self.fonts.get(self.options_panel.font_chooser.GetValue(), self.default_font) 139 + self.settings.font = font.marked_custom_font_id 140 + global_settings['last_font'] = font.marked_custom_font_name 141 + diff --git a/lib/gui/lettering_font_sample.py b/lib/gui/lettering_font_sample.py 142 + index e19544dce..c2f7fcaaa 100644 143 + --- a/lib/gui/lettering_font_sample.py 144 + +++ b/lib/gui/lettering_font_sample.py 145 + @@ -13,12 +13,12 @@ from ..commands import ensure_command_symbols 146 + from ..i18n import _ 147 + from ..lettering import get_font_list 148 + from ..marker import ensure_marker_symbols 149 + -from ..utils.settings import global_settings 150 + 151 + 152 + class FontSampleFrame(wx.Frame): 153 + 154 + def __init__(self, *args, **kwargs): 155 + + from ..utils.settings import global_settings 156 + self.layer = kwargs.pop("layer") 157 + wx.Frame.__init__(self, None, wx.ID_ANY, _("Font Sampling"), *args, **kwargs) 158 + 159 + @@ -135,6 +135,7 @@ class FontSampleFrame(wx.Frame): 160 + self.font_chooser.Append(font.marked_custom_font_name) 161 + 162 + def on_font_changed(self, event=None): 163 + + from ..utils.settings import global_settings 164 + selected_font = self.font_chooser.GetValue() 165 + if selected_font: 166 + self.font = self.fonts[selected_font] 167 + @@ -157,6 +158,7 @@ class FontSampleFrame(wx.Frame): 168 + self.color_sort_checkbox.Disable() 169 + 170 + def apply(self, event): 171 + + from ..utils.settings import global_settings 172 + # apply scale to layer and extract for later use 173 + self.layer.transform.add_scale(self.scale_spinner.GetValue() / 100) 174 + scale = self.layer.transform.a 175 + diff --git a/lib/gui/preferences.py b/lib/gui/preferences.py 176 + index 23dbbf0c6..13684acb9 100644 177 + --- a/lib/gui/preferences.py 178 + +++ b/lib/gui/preferences.py 179 + @@ -7,11 +7,11 @@ import wx 180 + 181 + from ..i18n import _ 182 + from ..utils.cache import get_stitch_plan_cache 183 + -from ..utils.settings import global_settings 184 + 185 + 186 + class PreferencesFrame(wx.Frame): 187 + def __init__(self, *args, **kwargs): 188 + + from ..utils.settings import global_settings 189 + self.extension = kwargs.pop("extension") 190 + wx.Frame.__init__(self, None, wx.ID_ANY, _("Preferences"), *args, **kwargs) 191 + self.SetTitle(_("Preferences")) 192 + @@ -180,6 +180,7 @@ class PreferencesFrame(wx.Frame): 193 + stitch_plan_cache.clear(retry=True) 194 + 195 + def apply(self): 196 + + from ..utils.settings import global_settings 197 + metadata = self.extension.get_inkstitch_metadata() 198 + metadata['min_stitch_len_mm'] = self.minimum_stitch_length.GetValue() 199 + metadata['collapse_len_mm'] = self.minimum_jump_stitch_length.GetValue() 200 + diff --git a/lib/gui/simulator/control_panel.py b/lib/gui/simulator/control_panel.py 201 + index 99d1f92ba..1bd9e1872 100644 202 + --- a/lib/gui/simulator/control_panel.py 203 + +++ b/lib/gui/simulator/control_panel.py 204 + @@ -11,7 +11,6 @@ from wx.lib.intctrl import IntCtrl 205 + from ...debug.debug import debug 206 + from ...i18n import _ 207 + from ...utils import get_resource_dir 208 + -from ...utils.settings import global_settings 209 + from . import SimulatorSlider 210 + 211 + 212 + @@ -21,6 +20,7 @@ class ControlPanel(wx.Panel): 213 + @debug.time 214 + def __init__(self, parent, *args, **kwargs): 215 + """""" 216 + + from ...utils.settings import global_settings 217 + self.parent = parent 218 + self.stitch_plan = kwargs.pop('stitch_plan', None) 219 + self.detach_callback = kwargs.pop('detach_callback', None) 220 + @@ -204,6 +204,7 @@ class ControlPanel(wx.Panel): 221 + return icon.ConvertToBitmap() 222 + 223 + def choose_speed(self): 224 + + from ...utils.settings import global_settings 225 + if not global_settings['simulator_adaptive_speed']: 226 + self.set_speed(global_settings['simulator_speed']) 227 + return 228 + @@ -233,6 +234,7 @@ class ControlPanel(wx.Panel): 229 + self.animation_reverse() 230 + 231 + def set_speed(self, speed): 232 + + from ...utils.settings import global_settings 233 + global_settings['simulator_speed'] = speed 234 + self.speed = int(max(speed, 1)) 235 + self.update_speed_text() 236 + diff --git a/lib/gui/simulator/drawing_panel.py b/lib/gui/simulator/drawing_panel.py 237 + index abe6fa0fb..036a7b2a6 100644 238 + --- a/lib/gui/simulator/drawing_panel.py 239 + +++ b/lib/gui/simulator/drawing_panel.py 240 + @@ -11,7 +11,6 @@ from numpy import split 241 + from ...debug.debug import debug 242 + from ...i18n import _ 243 + from ...svg import PIXELS_PER_MM 244 + -from ...utils.settings import global_settings 245 + 246 + # L10N command label at bottom of simulator window 247 + COMMAND_NAMES = [_("STITCH"), _("JUMP"), _("TRIM"), _("STOP"), _("COLOR CHANGE")] 248 + @@ -37,6 +36,7 @@ class DrawingPanel(wx.Panel): 249 + 250 + def __init__(self, parent, *args, **kwargs): 251 + """""" 252 + + from ...utils.settings import global_settings 253 + self.parent = parent 254 + self.stitch_plan = kwargs.pop('stitch_plan', None) 255 + kwargs['style'] = wx.BORDER_SUNKEN 256 + @@ -269,6 +269,7 @@ class DrawingPanel(wx.Panel): 257 + canvas.StrokeLines(block) 258 + 259 + def draw_needle_penetration_points(self, canvas, pen, stitches): 260 + + from ...utils.settings import global_settings 261 + if self.view_panel.btnNpp.GetValue(): 262 + npp_size = global_settings['simulator_npp_size'] * PIXELS_PER_MM * self.PIXEL_DENSITY 263 + npp_pen = wx.Pen(pen.GetColour(), width=int(npp_size)) 264 + @@ -364,11 +365,13 @@ class DrawingPanel(wx.Panel): 265 + pass 266 + 267 + def color_to_pen(self, color): 268 + + from ...utils.settings import global_settings 269 + line_width = global_settings['simulator_line_width'] * PIXELS_PER_MM * self.PIXEL_DENSITY 270 + background_color = self.GetBackgroundColour().GetAsString() 271 + return wx.Pen(list(map(int, color.visible_on_background(background_color).rgb)), int(line_width)) 272 + 273 + def update_pen_size(self): 274 + + from ...utils.settings import global_settings 275 + line_width = global_settings['simulator_line_width'] * PIXELS_PER_MM * self.PIXEL_DENSITY 276 + for pen in self.pens: 277 + pen.SetWidth(int(line_width)) 278 + @@ -421,6 +424,7 @@ class DrawingPanel(wx.Panel): 279 + self.jumps.append(jumps) 280 + 281 + def set_speed(self, speed): 282 + + from ...utils.settings import global_settings 283 + self.speed = speed 284 + global_settings['simulator_speed'] = speed 285 + 286 + diff --git a/lib/gui/simulator/simulator_preferences.py b/lib/gui/simulator/simulator_preferences.py 287 + index 7b72b87de..bfebc7cbe 100644 288 + --- a/lib/gui/simulator/simulator_preferences.py 289 + +++ b/lib/gui/simulator/simulator_preferences.py 290 + @@ -6,7 +6,6 @@ 291 + import wx 292 + 293 + from ...i18n import _ 294 + -from ...utils.settings import global_settings 295 + 296 + 297 + class SimulatorPreferenceDialog(wx.Dialog): 298 + @@ -14,6 +13,7 @@ class SimulatorPreferenceDialog(wx.Dialog): 299 + """ 300 + 301 + def __init__(self, *args, **kwargs): 302 + + from ...utils.settings import global_settings 303 + super(SimulatorPreferenceDialog, self).__init__(*args, **kwargs) 304 + self.SetWindowStyle(wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE) 305 + 306 + @@ -62,18 +62,21 @@ class SimulatorPreferenceDialog(wx.Dialog): 307 + self.SetSizerAndFit(sizer) 308 + 309 + def on_change(self, attribute, event): 310 + + from ...utils.settings import global_settings 311 + global_settings[attribute] = event.EventObject.GetValue() 312 + if self.drawing_panel.loaded and attribute == 'simulator_line_width': 313 + self.drawing_panel.update_pen_size() 314 + self.drawing_panel.Refresh() 315 + 316 + def on_adaptive_speed_changed(self, event=None): 317 + + from ...utils.settings import global_settings 318 + adaptive_speed = self.adaptive_speed.GetValue() 319 + global_settings['simulator_adaptive_speed'] = adaptive_speed 320 + self.control_panel.choose_speed() 321 + self.control_panel.Refresh() 322 + 323 + def save_settings(self): 324 + + from ...utils.settings import global_settings 325 + global_settings['simulator_line_width'] = self.line_width.GetValue() 326 + global_settings['simulator_npp_size'] = self.npp_size.GetValue() 327 + 328 + diff --git a/lib/gui/simulator/split_simulator_window.py b/lib/gui/simulator/split_simulator_window.py 329 + index e4b2803e2..6513b6d3d 100644 330 + --- a/lib/gui/simulator/split_simulator_window.py 331 + +++ b/lib/gui/simulator/split_simulator_window.py 332 + @@ -8,12 +8,12 @@ import wx 333 + 334 + from ...debug.debug import debug 335 + from ...utils import get_resource_dir 336 + -from ...utils.settings import global_settings 337 + from . import SimulatorPanel, SimulatorWindow 338 + 339 + 340 + class SplitSimulatorWindow(wx.Frame): 341 + def __init__(self, panel_class, title, target_duration=None, **kwargs): 342 + + from ...utils.settings import global_settings 343 + super().__init__(None, title=title) 344 + 345 + self.SetWindowStyle(wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE) 346 + @@ -89,6 +89,7 @@ class SplitSimulatorWindow(wx.Frame): 347 + self.detach_simulator() 348 + 349 + def attach_simulator(self): 350 + + from ...utils.settings import global_settings 351 + self.detached_simulator_frame.detach_simulator_panel() 352 + self.simulator_panel.Reparent(self.splitter) 353 + self.splitter.SplitVertically(self.settings_panel, self.simulator_panel) 354 + @@ -105,6 +106,7 @@ class SplitSimulatorWindow(wx.Frame): 355 + global_settings['pop_out_simulator'] = False 356 + 357 + def detach_simulator(self): 358 + + from ...utils.settings import global_settings 359 + self.splitter.Unsplit() 360 + self.detached_simulator_frame = SimulatorWindow(panel=self.simulator_panel, parent=self) 361 + self.splitter.SetMinimumPaneSize(100) 362 + diff --git a/lib/gui/simulator/view_panel.py b/lib/gui/simulator/view_panel.py 363 + index e2f2618d8..abbbc49d4 100644 364 + --- a/lib/gui/simulator/view_panel.py 365 + +++ b/lib/gui/simulator/view_panel.py 366 + @@ -9,7 +9,6 @@ from ...debug.debug import debug 367 + from ...i18n import _ 368 + from . import SimulatorPreferenceDialog 369 + from . import DesignInfoDialog 370 + -from ...utils.settings import global_settings 371 + 372 + 373 + class ViewPanel(ScrolledPanel): 374 + @@ -18,6 +17,7 @@ class ViewPanel(ScrolledPanel): 375 + @debug.time 376 + def __init__(self, parent, detach_callback): 377 + """""" 378 + + from ...utils.settings import global_settings 379 + self.parent = parent 380 + self.detach_callback = detach_callback 381 + ScrolledPanel.__init__(self, parent) 382 + @@ -159,14 +159,17 @@ class ViewPanel(ScrolledPanel): 383 + self.toggle_npp(event) 384 + 385 + def toggle_npp(self, event): 386 + + from ...utils.settings import global_settings 387 + self.drawing_panel.Refresh() 388 + global_settings['npp_button_status'] = self.btnNpp.GetValue() 389 + 390 + def on_cursor_button(self, event): 391 + + from ...utils.settings import global_settings 392 + self.drawing_panel.Refresh() 393 + global_settings['display_crosshair'] = self.btnCursor.GetValue() 394 + 395 + def toggle_page(self, event): 396 + + from ...utils.settings import global_settings 397 + debug.log("toggle page") 398 + value = self.btnPage.GetValue() 399 + self.drawing_panel.set_show_page(value) 400 + @@ -174,6 +177,7 @@ class ViewPanel(ScrolledPanel): 401 + global_settings['toggle_page_button_status'] = value 402 + 403 + def on_marker_button(self, marker_type, event): 404 + + from ...utils.settings import global_settings 405 + value = event.GetEventObject().GetValue() 406 + self.control_panel.slider.enable_marker_list(marker_type, value) 407 + if marker_type == 'jump': 408 + diff --git a/lib/metadata.py b/lib/metadata.py 409 + index 837fbf008..0beaeeb7a 100644 410 + --- a/lib/metadata.py 411 + +++ b/lib/metadata.py 412 + @@ -5,8 +5,6 @@ from collections.abc import MutableMapping 413 + import inkex 414 + from lxml import etree 415 + 416 + -from .utils.settings import DEFAULT_METADATA, global_settings 417 + - 418 + 419 + def strip_namespace(tag): 420 + """Remove xml namespace from a tag name. 421 + @@ -33,6 +31,7 @@ class InkStitchMetadata(MutableMapping): 422 + """ 423 + 424 + def __init__(self, document): 425 + + from .utils.settings import DEFAULT_METADATA, global_settings 426 + super().__init__() 427 + self.document = document 428 + self.metadata = document.metadata 429 + diff --git a/lib/sew_stack/stitch_layers/stitch_layer_editor.py b/lib/sew_stack/stitch_layers/stitch_layer_editor.py 430 + index eddf78675..4a5dfcf40 100644 431 + --- a/lib/sew_stack/stitch_layers/stitch_layer_editor.py 432 + +++ b/lib/sew_stack/stitch_layers/stitch_layer_editor.py 433 + @@ -7,7 +7,6 @@ import wx.propgrid 434 + from ...debug.debug import debug 435 + from ...gui.windows import SimpleBox 436 + from ...i18n import _ 437 + -from ...utils.settings import global_settings 438 + 439 + 440 + class CheckBoxProperty(wx.propgrid.BoolProperty): 441 + @@ -311,6 +310,7 @@ class StitchLayerEditor: 442 + return any(property.HasFlag(wx.propgrid.PG_PROP_MODIFIED) for property in self.property_grid.Items) 443 + 444 + def get_panel(self, parent): 445 + + from ...utils.settings import global_settings 446 + if self.property_grid_panel is None: 447 + self.layer_editor_panel = wx.Panel(parent, wx.ID_ANY) 448 + 449 + @@ -426,6 +426,7 @@ class StitchLayerEditor: 450 + self.property_grid.RefreshEditor() 451 + 452 + def on_sash_position_changed(self, event): 453 + + from ...utils.settings import global_settings 454 + global_settings['stitch_layer_editor_sash_position'] = event.GetSashPosition() 455 + 456 + def show_help(self, property): 457 + diff --git a/lib/utils/cache.py b/lib/utils/cache.py 458 + index cca6296a9..6ecdf6403 100644 459 + --- a/lib/utils/cache.py 460 + +++ b/lib/utils/cache.py 461 + @@ -10,9 +10,6 @@ import sqlite3 462 + 463 + import diskcache # type: ignore[import-untyped] 464 + 465 + -from lib.utils.settings import global_settings 466 + - 467 + -from .paths import get_user_dir 468 + from functools import lru_cache 469 + 470 + 471 + @@ -25,6 +22,8 @@ __stitch_plan_cache = None 472 + 473 + 474 + def get_stitch_plan_cache(): 475 + + from .paths import get_user_dir 476 + + from lib.utils.settings import global_settings 477 + global __stitch_plan_cache 478 + 479 + if __stitch_plan_cache is None: 480 + @@ -51,6 +50,7 @@ def get_stitch_plan_cache(): 481 + 482 + 483 + def is_cache_disabled(): 484 + + from lib.utils.settings import global_settings 485 + return not global_settings['cache_size'] 486 + 487 + 488 + -- 489 + 2.49.0 490 +
+31
pkgs/applications/graphics/inkscape/extensions/inkstitch/0004-enable-force-insertion-of-python-path.patch
···
··· 1 + From 99c895045df01e291c6c9dc89b7a1c758e010bda Mon Sep 17 00:00:00 2001 2 + From: tropf <tropf@noreply.codeberg.org> 3 + Date: Sat, 26 Oct 2024 14:07:17 +0200 4 + Subject: [PATCH 4/4] enable force-insertion of python path 5 + 6 + As of now, the inkex library loaded by inkstitch must be fixed. The 7 + version supplied by inkscape is not sufficient. This should be fixed 8 + with inkscape 1.4, where this patch can be removed. 9 + 10 + The fixed path is injected through an environment variable at runtime. 11 + --- 12 + inkstitch.py | 3 +++ 13 + 1 file changed, 3 insertions(+) 14 + 15 + diff --git a/inkstitch.py b/inkstitch.py 16 + index be8ddf665..d7a8fca2f 100644 17 + --- a/inkstitch.py 18 + +++ b/inkstitch.py 19 + @@ -105,6 +105,9 @@ if not running_as_frozen: # debugging/profiling only in development mode 20 + if prefer_pip_inkex and 'PYTHONPATH' in os.environ: 21 + debug_utils.reorder_sys_path() 22 + 23 + +if "PYTHON_INKEX_PATH" in os.environ: 24 + + sys.path = [os.environ["PYTHON_INKEX_PATH"]] + sys.path 25 + + 26 + # enabling of debug depends on value of debug_type in DEBUG.toml file 27 + if debug_type != 'none': 28 + from lib.debug.debugger import init_debugger 29 + -- 30 + 2.49.0 31 +
+37 -5
pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix
··· 2 lib, 3 python3, 4 fetchFromGitHub, 5 gettext, 6 }: 7 let 8 - version = "3.1.0"; 9 dependencies = 10 with python3.pkgs; 11 [ 12 pyembroidery 13 - inkex 14 wxpython 15 networkx 16 shapely 17 lxml 18 appdirs 19 numpy 20 jinja2 21 requests 22 - # Upstream wants colormath2 yet still refers to it as colormath. Curious. 23 - colormath 24 flask 25 fonttools 26 trimesh ··· 41 owner = "inkstitch"; 42 repo = "inkstitch"; 43 tag = "v${version}"; 44 - hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY="; 45 }; 46 47 nativeBuildInputs = [ ··· 70 patches = [ 71 ./0001-force-frozen-true.patch 72 ./0002-plugin-invocation-use-python-script-as-entrypoint.patch 73 ]; 74 75 postPatch = '' 76 # Add shebang with python dependencies 77 substituteInPlace lib/inx/utils.py --replace-fail ' interpreter="python"' "" 78 sed -i -e '1i#!${pyEnv.interpreter}' inkstitch.py 79 chmod a+x inkstitch.py 80 ''; 81 82 nativeCheckInputs = with python3.pkgs; [
··· 2 lib, 3 python3, 4 fetchFromGitHub, 5 + fetchFromGitLab, 6 gettext, 7 }: 8 let 9 + # on update check compatibility to nixpkgs inkex 10 + version = "3.2.2"; 11 + 12 + # remove and use nixpkgs version is recent enough 13 + inkex' = python3.pkgs.inkex.overrideAttrs (old: rec { 14 + # this is no special commit, just the most recent as of writing 15 + version = "3150a5b3b06f7e4c2104d9e8eb6dc448982bb2b0"; 16 + src = fetchFromGitLab { 17 + owner = "inkscape"; 18 + repo = "extensions"; 19 + rev = "${version}"; 20 + hash = "sha256-FYBZ66ERC3nVYCaAmFPqKnBxDOKAoQwT14C0fKLn10c="; 21 + }; 22 + 23 + postPatch = '' 24 + substituteInPlace pyproject.toml \ 25 + --replace-fail 'scour = "^0.37"' 'scour = ">=0.37"' 26 + ''; 27 + }); 28 + 29 dependencies = 30 with python3.pkgs; 31 [ 32 pyembroidery 33 + # inkex upstream release & nixpkgs is too old 34 + # use nixpkgs inkex once up to date 35 + inkex' 36 wxpython 37 networkx 38 + platformdirs 39 shapely 40 lxml 41 appdirs 42 numpy 43 jinja2 44 requests 45 + colormath2 46 flask 47 fonttools 48 trimesh ··· 63 owner = "inkstitch"; 64 repo = "inkstitch"; 65 tag = "v${version}"; 66 + hash = "sha256-6EVfjmTXEYgZta01amK8E6t5h2JBPfGGNnqfBG8LQfo="; 67 }; 68 69 nativeBuildInputs = [ ··· 92 patches = [ 93 ./0001-force-frozen-true.patch 94 ./0002-plugin-invocation-use-python-script-as-entrypoint.patch 95 + ./0003-lazy-load-module-to-access-global_settings.patch 96 + ./0004-enable-force-insertion-of-python-path.patch 97 ]; 98 + 99 + doCheck = false; 100 101 postPatch = '' 102 # Add shebang with python dependencies 103 substituteInPlace lib/inx/utils.py --replace-fail ' interpreter="python"' "" 104 sed -i -e '1i#!${pyEnv.interpreter}' inkstitch.py 105 chmod a+x inkstitch.py 106 + ''; 107 + 108 + postInstall = '' 109 + export SITE_PACKAGES=$(find "${pyEnv}" -type d -name 'site-packages') 110 + wrapProgram $out/share/inkscape/extensions/inkstitch/inkstitch.py \ 111 + --set PYTHON_INKEX_PATH "$SITE_PACKAGES" 112 ''; 113 114 nativeCheckInputs = with python3.pkgs; [