based on this commit, modified for easier application to this release

From 731ac2868e30dbccf5771abf79564d8bab1156c2 Mon Sep 17 00:00:00 2001
From: Kaalleen <36401965+kaalleen@users.noreply.github.com>
Date: Sun, 27 Jul 2025 07:28:20 +0200
Subject: [PATCH] rename pyembroidery to pystitch (#3889)

... and remove it as a submodule (use pip to install)

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 5edeeae786..0000000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "pyembroidery"]
-	path = pyembroidery
-	url = https://github.com/inkstitch/pyembroidery
diff --git a/Makefile b/Makefile
index b5d4dfbed0..4cf939c8ad 100644
--- a/Makefile
+++ b/Makefile
@@ -23,14 +23,14 @@ messages.po: inx
 	xgettext inx/*.inx --its=its/inx.its -o messages-inx.po
 	# There seems to be no proper way to set the charset to utf-8
 	sed -i 's/charset=CHARSET/charset=UTF-8/g' messages-inx.po
-	bin/pyembroidery-gettext > pyembroidery-format-descriptions.py
+	bin/pystitch-gettext > pystitch-format-descriptions.py
 	bin/inkstitch-fonts-gettext > inkstitch-fonts-metadata.py
 	bin/inkstitch-tiles-gettext > inkstitch-tiles-metadata.py
 	# After the inx files are finished building, we don't need the src/ folder anymore.
 	# We don't want babel to grab possible translation strings from that folder, so let's remove it
 	rm -rf src/
 	pybabel extract -o messages-babel.po -F babel.conf --add-location=full --add-comments=l10n,L10n,L10N --sort-by-file --strip-comments -k N_ -k '$$gettext' .
-	rm pyembroidery-format-descriptions.py inkstitch-fonts-metadata.py inkstitch-tiles-metadata.py
+	rm pystitch-format-descriptions.py inkstitch-fonts-metadata.py inkstitch-tiles-metadata.py
 	msgcat -o messages.po messages-babel.po messages-inx.po
 
 %.po: %.mo
@@ -38,7 +38,7 @@ messages.po: inx
 
 .PHONY: clean
 clean:
-	rm -f messages.po pyembroidery-format-descriptions.py
+	rm -f messages.po pystitch-format-descriptions.py
 
 .PHONY: locales
 locales:
diff --git a/bin/pyembroidery-convert b/bin/pyembroidery-convert
deleted file mode 100755
index ac58e3e573..0000000000
--- a/bin/pyembroidery-convert
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import pyembroidery
-
-pyembroidery.convert(sys.argv[1], sys.argv[2])
diff --git a/bin/pyembroidery-gettext b/bin/pyembroidery-gettext
deleted file mode 100755
index f4e844b951..0000000000
--- a/bin/pyembroidery-gettext
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env python
-
-import pyembroidery
-
-
-# generate fake python code containing the descriptions of pyembroidery formats
-# as gettext calls so that pybabel will extract them into messages.po
-for format in pyembroidery.supported_formats():
-    print("# L10N description for pyembroidery file format: %s" % format['extension'])
-    print("_(%s)" % repr(format['description']))
diff --git a/bin/pystitch-convert b/bin/pystitch-convert
new file mode 100755
index 0000000000..92e814a268
--- /dev/null
+++ b/bin/pystitch-convert
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import sys
+import pystitch
+
+pystitch.convert(sys.argv[1], sys.argv[2])
diff --git a/bin/pystitch-gettext b/bin/pystitch-gettext
new file mode 100755
index 0000000000..0687152748
--- /dev/null
+++ b/bin/pystitch-gettext
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+import pystitch
+
+
+# generate fake python code containing the descriptions of pystitch formats
+# as gettext calls so that pybabel will extract them into messages.po
+for format in pystitch.supported_formats():
+    print("# L10N description for pystitch file format: %s" % format['extension'])
+    print("_(%s)" % repr(format['description']))
diff --git a/bin/style-check b/bin/style-check
index bdac3a76c5..fa4cc74556 100755
--- a/bin/style-check
+++ b/bin/style-check
@@ -5,4 +5,4 @@
 # Instead of files, "--diff" may be passed to check only the lines changed
 # by a diff piped to standard input.
 
-flake8 --count --max-complexity=10 --max-line-length=150 --statistics --exclude=pyembroidery,__init__.py,build,src,dist,./*-metadata.py,./pyembroidery-format-descriptions.py "${@:-.}"
+flake8 --count --max-complexity=10 --max-line-length=150 --statistics --exclude=__init__.py,build,src,dist,./*-metadata.py,./pystitch-format-descriptions.py "${@:-.}"
diff --git a/lib/extensions/apply_threadlist.py b/lib/extensions/apply_threadlist.py
index 5b831ff59e..d01bd8e2f2 100644
--- a/lib/extensions/apply_threadlist.py
+++ b/lib/extensions/apply_threadlist.py
@@ -10,7 +10,7 @@
 
 import inkex
 
-import pyembroidery
+import pystitch
 
 from ..i18n import _
 from ..svg.tags import INKSTITCH_ATTRIBS
@@ -105,7 +105,7 @@ def parse_inkstitch_threadlist(self, path: str) -> List[List[Optional[str]]]:
 
     def parse_color_format(self, path: str) -> List[List[Optional[str]]]:
         colors = []
-        threads = pyembroidery.read(path).threadlist
+        threads = pystitch.read(path).threadlist
         for color in threads:
             if color.description is not None and color.description.startswith("Cut"):
                 # there is a maximum of 4 needles, we can simply take the last element from the description string
diff --git a/lib/extensions/batch_lettering.py b/lib/extensions/batch_lettering.py
index 70beaaf7cf..c0581e76df 100644
--- a/lib/extensions/batch_lettering.py
+++ b/lib/extensions/batch_lettering.py
@@ -14,7 +14,7 @@
 from inkex import Boolean, Group, errormsg
 from lxml import etree
 
-import pyembroidery
+import pystitch
 
 from ..extensions.lettering_along_path import TextAlongPath
 from ..i18n import _
@@ -69,7 +69,7 @@ def effect(self):
         if not self.options.formats:
             errormsg(_("Please specify at least one output file format"))
             return
-        available_formats = [file_format['extension'] for file_format in pyembroidery.supported_formats()] + ['svg']
+        available_formats = [file_format['extension'] for file_format in pystitch.supported_formats()] + ['svg']
         file_formats = self.options.formats.split(',')
         file_formats = [file_format.strip().lower() for file_format in file_formats if file_format.strip().lower() in available_formats]
         if not file_formats:
diff --git a/lib/extensions/zip.py b/lib/extensions/zip.py
index 13cae7bdc6..2cee5f048f 100644
--- a/lib/extensions/zip.py
+++ b/lib/extensions/zip.py
@@ -13,7 +13,7 @@
 from inkex.units import convert_unit
 from lxml import etree
 
-import pyembroidery
+import pystitch
 
 from ..i18n import _
 from ..output import write_embroidery_file
@@ -35,7 +35,7 @@ def __init__(self, *args, **kwargs):
 
         # it's kind of obnoxious that I have to do this...
         self.formats = []
-        for format in pyembroidery.supported_formats():
+        for format in pystitch.supported_formats():
             if 'writer' in format and format['category'] in ['embroidery', 'color', 'image', 'stitch', 'quilting']:
                 extension = format['extension']
                 self.arg_parser.add_argument('--format-%s' % extension, type=Boolean, default=False, dest=extension)
diff --git a/lib/inx/extensions.py b/lib/inx/extensions.py
index d69f0d75fc..cab1ece670 100755
--- a/lib/inx/extensions.py
+++ b/lib/inx/extensions.py
@@ -5,14 +5,14 @@
 
 import os
 
-import pyembroidery
+import pystitch
 
 from ..commands import (COMMANDS, GLOBAL_COMMANDS, LAYER_COMMANDS,
                         OBJECT_COMMANDS)
 from ..extensions import Input, Output, extensions
 from ..lettering.categories import FONT_CATEGORIES
 from ..threads import ThreadCatalog
-from .outputs import pyembroidery_output_formats
+from .outputs import pystitch_output_formats
 from .utils import build_environment, write_inx_file
 
 
@@ -31,8 +31,8 @@ def object_commands():
     return [(command, COMMANDS[command]) for command in OBJECT_COMMANDS]
 
 
-def pyembroidery_debug_formats():
-    for format in pyembroidery.supported_formats():
+def pystitch_debug_formats():
+    for format in pystitch.supported_formats():
         if 'writer' in format and format['category'] not in ['embroidery', 'image', 'color', 'stitch']:
             yield format['extension'], format['description']
 
@@ -55,8 +55,8 @@ def generate_extension_inx_files(alter_data):
         name = extension.name()
         template = env.get_template(f'{name}.xml')
         write_inx_file(name, template.render(alter_data,
-                                             formats=pyembroidery_output_formats(),
-                                             debug_formats=pyembroidery_debug_formats(),
+                                             formats=pystitch_output_formats(),
+                                             debug_formats=pystitch_debug_formats(),
                                              threadcatalog=threadcatalog(),
                                              font_categories=FONT_CATEGORIES,
                                              layer_commands=layer_commands(),
diff --git a/lib/inx/inputs.py b/lib/inx/inputs.py
index cd8b57bda3..667f71c976 100755
--- a/lib/inx/inputs.py
+++ b/lib/inx/inputs.py
@@ -3,13 +3,13 @@
 # Copyright (c) 2010 Authors
 # Licensed under the GNU GPL version 3.0 or later.  See the file LICENSE for details.
 
-import pyembroidery
+import pystitch
 
 from .utils import build_environment, write_inx_file
 
 
-def pyembroidery_input_formats():
-    for format in pyembroidery.supported_formats():
+def pystitch_input_formats():
+    for format in pystitch.supported_formats():
         if 'reader' in format and format['category'] in ['embroidery', 'color', 'stitch', 'quilting', 'debug']:
             yield format['extension'], format['description']
 
@@ -18,6 +18,6 @@ def generate_input_inx_files(alter_data):
     env = build_environment()
     template = env.get_template('input.xml')
 
-    for format, description in pyembroidery_input_formats():
+    for format, description in pystitch_input_formats():
         name = f"input_{format.upper()}"
         write_inx_file(name, template.render(alter_data, format=format, description=description))
diff --git a/lib/inx/outputs.py b/lib/inx/outputs.py
index 0cf9ac8473..51907f79f8 100644
--- a/lib/inx/outputs.py
+++ b/lib/inx/outputs.py
@@ -3,13 +3,13 @@
 # Copyright (c) 2010 Authors
 # Licensed under the GNU GPL version 3.0 or later.  See the file LICENSE for details.
 
-import pyembroidery
+import pystitch
 
 from .utils import build_environment, write_inx_file
 
 
-def pyembroidery_output_formats():
-    for format in pyembroidery.supported_formats():
+def pystitch_output_formats():
+    for format in pystitch.supported_formats():
         if 'writer' in format:
             description = format['description']
             if format['category'] == "color":
@@ -30,6 +30,6 @@ def generate_output_inx_files(alter_data):
     env = build_environment()
     template = env.get_template('output.xml')
 
-    for format, description, mimetype, category in pyembroidery_output_formats():
+    for format, description, mimetype, category in pystitch_output_formats():
         name = f"output_{format.upper()}"
         write_inx_file(name, template.render(alter_data, format=format, mimetype=mimetype, description=description))
diff --git a/lib/output.py b/lib/output.py
index 1b9c62a4ae..ff187165b4 100644
--- a/lib/output.py
+++ b/lib/output.py
@@ -8,9 +8,9 @@
 import sys
 
 import inkex
-from pyembroidery.exceptions import TooManyColorChangesError
+from pystitch.exceptions import TooManyColorChangesError
 
-import pyembroidery
+import pystitch as pyembroidery
 
 from .commands import global_command
 from .i18n import _
diff --git a/lib/stitch_plan/generate_stitch_plan.py b/lib/stitch_plan/generate_stitch_plan.py
index cdd66d9ee8..c9faff4f66 100644
--- a/lib/stitch_plan/generate_stitch_plan.py
+++ b/lib/stitch_plan/generate_stitch_plan.py
@@ -9,7 +9,7 @@
 
 import inkex
 
-import pyembroidery
+import pystitch as pyembroidery
 
 from ..i18n import _
 from ..svg import PIXELS_PER_MM, render_stitch_plan
diff --git a/lib/stitch_plan/read_file.py b/lib/stitch_plan/read_file.py
index 56567f3680..ada879582b 100644
--- a/lib/stitch_plan/read_file.py
+++ b/lib/stitch_plan/read_file.py
@@ -3,7 +3,7 @@
 # Copyright (c) 2010 Authors
 # Licensed under the GNU GPL version 3.0 or later.  See the file LICENSE for details.
 
-import pyembroidery
+import pystitch as pyembroidery
 from .stitch_plan import StitchPlan
 
 from ..svg import PIXELS_PER_MM
diff --git a/lib/threads/color.py b/lib/threads/color.py
index 335dc32b19..6644e5ec0a 100644
--- a/lib/threads/color.py
+++ b/lib/threads/color.py
@@ -6,7 +6,7 @@
 import colorsys
 
 from inkex import Color
-from pyembroidery.EmbThread import EmbThread
+from pystitch.EmbThread import EmbThread
 
 
 class ThreadColor(object):
