Skip to content

Commit 71589bc

Browse files
inkscape-extensions.inkstitch: fix editor opening (#366606)
2 parents 6c81230 + cd87669 commit 71589bc

File tree

4 files changed

+109
-19
lines changed

4 files changed

+109
-19
lines changed

maintainers/maintainer-list.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23143,6 +23143,12 @@
2314323143
githubId = 504580;
2314423144
name = "Thibaut Robert";
2314523145
};
23146+
tropf = {
23147+
name = "tropf";
23148+
matrix = "@tropf:matrix.org";
23149+
github = "tropf";
23150+
githubId = 29873239;
23151+
};
2314623152
troydm = {
2314723153
email = "[email protected]";
2314823154
github = "troydm";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From af541a4f8ddda287f74687327e4ed89b79557777 Mon Sep 17 00:00:00 2001
2+
From: tropf <[email protected]>
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.
8+
---
9+
inkstitch.py | 2 +-
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:
17+
ini = {}
18+
# --------------------------------------------------------------------------------------------
19+
20+
-running_as_frozen = getattr(sys, 'frozen', None) is not None # check if running from pyinstaller bundle
21+
+running_as_frozen = True
22+
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+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From a86412c57833c24743214c9d3abb76093365769f Mon Sep 17 00:00:00 2001
2+
From: tropf <[email protected]>
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
8+
binary -- at least for vanilla Ink/Stitch. For the nix version, we
9+
follow manual install, which does *not* bundle the file. Hence, the
10+
generation is patched to treat this packaged install as manual install,
11+
and to still refer to the python file.
12+
13+
To keep the patchset small, only an if statement is changed, with the
14+
intent of only using the else path.
15+
---
16+
lib/inx/utils.py | 2 +-
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():
24+
extensions=['jinja2.ext.i18n']
25+
)
26+
27+
- if "BUILD" in os.environ:
28+
+ if False:
29+
# building a ZIP release, with inkstitch packaged as a binary
30+
# Command tag and icons path
31+
if sys.platform == "win32":
32+
--
33+
2.36.0
34+

pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@
66
}:
77
let
88
version = "3.1.0";
9-
in
10-
python3.pkgs.buildPythonApplication {
11-
pname = "inkstitch";
12-
inherit version;
13-
pyproject = false; # Uses a Makefile (yikes)
14-
15-
src = fetchFromGitHub {
16-
owner = "inkstitch";
17-
repo = "inkstitch";
18-
rev = "refs/tags/v${version}";
19-
hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY=";
20-
};
21-
22-
nativeBuildInputs = [
23-
gettext
24-
];
25-
269
dependencies =
2710
with python3.pkgs;
2811
[
@@ -47,18 +30,55 @@ python3.pkgs.buildPythonApplication {
4730
]
4831
# Inkstitch uses the builtin tomllib instead when Python >=3.11
4932
++ lib.optional (pythonOlder "3.11") tomli;
33+
pyEnv = python3.withPackages (_: dependencies);
34+
in
35+
python3.pkgs.buildPythonApplication {
36+
pname = "inkstitch";
37+
inherit version;
38+
pyproject = false; # Uses a Makefile (yikes)
39+
40+
src = fetchFromGitHub {
41+
owner = "inkstitch";
42+
repo = "inkstitch";
43+
tag = "v${version}";
44+
hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY=";
45+
};
46+
47+
nativeBuildInputs = [
48+
gettext
49+
pyEnv
50+
];
5051

52+
inherit dependencies;
53+
54+
env = {
55+
# to overwrite version string
56+
GITHUB_REF = version;
57+
BUILD = "nixpkgs";
58+
};
5159
makeFlags = [ "manual" ];
5260

5361
installPhase = ''
5462
runHook preInstall
5563
5664
mkdir -p $out/share/inkscape/extensions
57-
cp -a inx $out/share/inkscape/extensions/inkstitch
65+
cp -a . $out/share/inkscape/extensions/inkstitch
5866
5967
runHook postInstall
6068
'';
6169

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+
6282
nativeCheckInputs = with python3.pkgs; [
6383
pytestCheckHook
6484
];
@@ -67,6 +87,9 @@ python3.pkgs.buildPythonApplication {
6787
description = "Inkscape extension for machine embroidery design";
6888
homepage = "https://inkstitch.org/";
6989
license = with lib.licenses; [ gpl3Plus ];
70-
maintainers = with lib.maintainers; [ pluiedev ];
90+
maintainers = with lib.maintainers; [
91+
tropf
92+
pluiedev
93+
];
7194
};
7295
}

0 commit comments

Comments
 (0)