diff --git a/pkgs/applications/graphics/inkscape/extensions.nix b/pkgs/applications/graphics/inkscape/extensions.nix index 4499792cbbd0..56082f1e4a93 100644 --- a/pkgs/applications/graphics/inkscape/extensions.nix +++ b/pkgs/applications/graphics/inkscape/extensions.nix @@ -44,6 +44,7 @@ mkdir -p $out/share/inkscape/extensions cp ${inkcut}/share/inkscape/extensions/* $out/share/inkscape/extensions ''); + inkstitch = callPackage ./extensions/inkstitch { }; silhouette = callPackage ./extensions/silhouette { }; textext = callPackage ./extensions/textext { pdflatex = texlive.combined.scheme-basic; diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix new file mode 100644 index 000000000000..0b07ee67a5f0 --- /dev/null +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix @@ -0,0 +1,72 @@ +{ + lib, + python3, + fetchFromGitHub, + gettext, +}: +let + version = "3.1.0"; +in +python3.pkgs.buildPythonApplication { + pname = "inkstitch"; + inherit version; + pyproject = false; # Uses a Makefile (yikes) + + src = fetchFromGitHub { + owner = "inkstitch"; + repo = "inkstitch"; + rev = "refs/tags/v${version}"; + hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY="; + }; + + nativeBuildInputs = [ + gettext + ]; + + dependencies = + with python3.pkgs; + [ + pyembroidery + inkex + wxpython + networkx + shapely + lxml + appdirs + numpy + jinja2 + requests + # Upstream wants colormath2 yet still refers to it as colormath. Curious. + colormath + flask + fonttools + trimesh + scipy + diskcache + flask-cors + ] + # Inkstitch uses the builtin tomllib instead when Python >=3.11 + ++ lib.optional (pythonOlder "3.11") tomli; + + makeFlags = [ "manual" ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/inkscape/extensions + cp -a inx $out/share/inkscape/extensions/inkstitch + + runHook postInstall + ''; + + nativeCheckInputs = with python3.pkgs; [ + pytestCheckHook + ]; + + meta = { + description = "Inkscape extension for machine embroidery design"; + homepage = "https://inkstitch.org/"; + license = with lib.licenses; [ gpl3Plus ]; + maintainers = with lib.maintainers; [ pluiedev ]; + }; +} diff --git a/pkgs/development/python-modules/pyembroidery/default.nix b/pkgs/development/python-modules/pyembroidery/default.nix new file mode 100644 index 000000000000..a5830f5a388e --- /dev/null +++ b/pkgs/development/python-modules/pyembroidery/default.nix @@ -0,0 +1,54 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + setuptools, + pytestCheckHook, +}: +let + pname = "pyembroidery"; + + # Mysteriously, the latest version published on PyPI has the version of 1.5.1, + # but the latest GitHub version stopped at 1.2.39. Further more Ink/Stitch requires the .exceptions + # module which is absent from the PyPI release. + # I guess this is *technically* the correct version name, but... yikes. + version = "1.5.1-unstable-2024-06-26"; +in +buildPythonPackage { + inherit pname version; + pyproject = true; + + src = fetchFromGitHub { + owner = "inkstitch"; + repo = "pyembroidery"; + rev = "b603b8d2b2bf91b5b0823a8a619562de5fd756e7"; + hash = "sha256-cnWQ/ZScdXTFMLHdceyCLjgEkcwv3KuZHwXWlsYCcBA="; + }; + + build-system = [ + setuptools + ]; + + pythonImportsCheck = [ + "pyembroidery" + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + # Failed assertions. + # See https://github.com/inkstitch/pyembroidery/issues/108 + disabledTests = [ + "test_generic_write_gcode" + "test_jef_trims_commands" + ]; + + meta = { + description = "Python library for the reading and writing of embroidery files"; + homepage = "https://github.com/inkstitch/pyembroidery"; + license = with lib.licenses; [ mit ]; + maintainers = with lib.maintainers; [ pluiedev ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 635c2d2ac947..29a9448e457c 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10229,6 +10229,8 @@ self: super: with self; { pybars3 = callPackage ../development/python-modules/pybars3 { }; + pyembroidery = callPackage ../development/python-modules/pyembroidery { }; + pymeta3 = callPackage ../development/python-modules/pymeta3 { }; pypemicro = callPackage ../development/python-modules/pypemicro { };