Unverified Commit 71589bc1 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

inkscape-extensions.inkstitch: fix editor opening (#366606)

parents 6c812309 cd87669d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -23143,6 +23143,12 @@
    githubId = 504580;
    name = "Thibaut Robert";
  };
  tropf = {
    name = "tropf";
    matrix = "@tropf:matrix.org";
    github = "tropf";
    githubId = 29873239;
  };
  troydm = {
    email = "d.geurkov@gmail.com";
    github = "troydm";
+27 −0
Original line number Diff line number Diff line
From af541a4f8ddda287f74687327e4ed89b79557777 Mon Sep 17 00:00:00 2001
From: tropf <tropf@noreply.codeberg.org>
Date: Mon, 5 Aug 2024 21:25:33 +0200
Subject: [PATCH 1/3] force frozen=true

Enforce installation in frozen mode, i.e. as a packaged version where
source can not be modified.
---
 inkstitch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/inkstitch.py b/inkstitch.py
index 50f33d19..398465ca 100644
--- a/inkstitch.py
+++ b/inkstitch.py
@@ -40,7 +40,7 @@ else:
     ini = {}
 # --------------------------------------------------------------------------------------------
 
-running_as_frozen = getattr(sys, 'frozen', None) is not None  # check if running from pyinstaller bundle
+running_as_frozen = True
 
 if not running_as_frozen:  # override running_as_frozen from DEBUG.toml - for testing
     if safe_get(ini, "DEBUG", "force_frozen", default=False):
-- 
2.36.0
+34 −0
Original line number Diff line number Diff line
From a86412c57833c24743214c9d3abb76093365769f Mon Sep 17 00:00:00 2001
From: tropf <tropf@noreply.codeberg.org>
Date: Mon, 5 Aug 2024 21:26:13 +0200
Subject: [PATCH 2/3] plugin invocation: use python script as entrypoint

Ink/Stitch is invoked by calling a script with command line parameters.
Depending on the distribution format, this is bundled into a standalone
binary -- at least for vanilla Ink/Stitch. For the nix version, we
follow manual install, which does *not* bundle the file. Hence, the
generation is patched to treat this packaged install as manual install,
and to still refer to the python file.

To keep the patchset small, only an if statement is changed, with the
intent of only using the else path.
---
 lib/inx/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/inx/utils.py b/lib/inx/utils.py
index 9168f2a2..00313639 100755
--- a/lib/inx/utils.py
+++ b/lib/inx/utils.py
@@ -21,7 +21,7 @@ def build_environment():
         extensions=['jinja2.ext.i18n']
     )
 
-    if "BUILD" in os.environ:
+    if False:
         # building a ZIP release, with inkstitch packaged as a binary
         # Command tag and icons path
         if sys.platform == "win32":
-- 
2.36.0
+42 −19
Original line number Diff line number Diff line
@@ -6,23 +6,6 @@
}:
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;
    [
@@ -47,18 +30,55 @@ python3.pkgs.buildPythonApplication {
    ]
    # Inkstitch uses the builtin tomllib instead when Python >=3.11
    ++ lib.optional (pythonOlder "3.11") tomli;
  pyEnv = python3.withPackages (_: dependencies);
in
python3.pkgs.buildPythonApplication {
  pname = "inkstitch";
  inherit version;
  pyproject = false; # Uses a Makefile (yikes)

  src = fetchFromGitHub {
    owner = "inkstitch";
    repo = "inkstitch";
    tag = "v${version}";
    hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY=";
  };

  nativeBuildInputs = [
    gettext
    pyEnv
  ];

  inherit dependencies;

  env = {
    # to overwrite version string
    GITHUB_REF = version;
    BUILD = "nixpkgs";
  };
  makeFlags = [ "manual" ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/inkscape/extensions
    cp -a inx $out/share/inkscape/extensions/inkstitch
    cp -a . $out/share/inkscape/extensions/inkstitch

    runHook postInstall
  '';

  patches = [
    ./0001-force-frozen-true.patch
    ./0002-plugin-invocation-use-python-script-as-entrypoint.patch
  ];

  postPatch = ''
    # Add shebang with python dependencies
    substituteInPlace lib/inx/utils.py --replace-fail ' interpreter="python"' ""
    sed -i -e '1i#!${pyEnv.interpreter}' inkstitch.py
    chmod a+x inkstitch.py
  '';

  nativeCheckInputs = with python3.pkgs; [
    pytestCheckHook
  ];
@@ -67,6 +87,9 @@ python3.pkgs.buildPythonApplication {
    description = "Inkscape extension for machine embroidery design";
    homepage = "https://inkstitch.org/";
    license = with lib.licenses; [ gpl3Plus ];
    maintainers = with lib.maintainers; [ pluiedev ];
    maintainers = with lib.maintainers; [
      tropf
      pluiedev
    ];
  };
}