about summary refs log tree commit diff
path: root/pkgs/applications/science/electronics
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-02-23 06:01:36 +0000
committerGitHub <noreply@github.com>2023-02-23 06:01:36 +0000
commit36f198081c5c954c4dae61a1da3f80d5bfc54079 (patch)
tree8b049737066d68fa17612fe2c0d6488cbd02b284 /pkgs/applications/science/electronics
parentcee7ce609da33494cc8a5e569f6ffbccfdc1548c (diff)
parent010946fcbd99c7dd20417ad387cf395c0d59d1b9 (diff)
downloadnixlib-36f198081c5c954c4dae61a1da3f80d5bfc54079.tar
nixlib-36f198081c5c954c4dae61a1da3f80d5bfc54079.tar.gz
nixlib-36f198081c5c954c4dae61a1da3f80d5bfc54079.tar.bz2
nixlib-36f198081c5c954c4dae61a1da3f80d5bfc54079.tar.lz
nixlib-36f198081c5c954c4dae61a1da3f80d5bfc54079.tar.xz
nixlib-36f198081c5c954c4dae61a1da3f80d5bfc54079.tar.zst
nixlib-36f198081c5c954c4dae61a1da3f80d5bfc54079.zip
Merge staging-next into staging
Diffstat (limited to 'pkgs/applications/science/electronics')
-rw-r--r--pkgs/applications/science/electronics/flatcam/default.nix32
-rw-r--r--pkgs/applications/science/electronics/flatcam/shapely-library-paths.patch31
2 files changed, 60 insertions, 3 deletions
diff --git a/pkgs/applications/science/electronics/flatcam/default.nix b/pkgs/applications/science/electronics/flatcam/default.nix
index 13fccd0e0fba..02b2d2d61ac0 100644
--- a/pkgs/applications/science/electronics/flatcam/default.nix
+++ b/pkgs/applications/science/electronics/flatcam/default.nix
@@ -1,10 +1,36 @@
 { lib
-, python3Packages
+, stdenv
+, python3
 , fetchFromBitbucket
 , fetchpatch
+, substituteAll
+, geos
 }:
 
-python3Packages.buildPythonApplication rec {
+let
+  python = python3.override {
+    packageOverrides = self: super: {
+      shapely = super.shapely.overridePythonAttrs (old: rec {
+        version = "1.8.4";
+        src = self.fetchPypi {
+          pname = "Shapely";
+          inherit version;
+          hash = "sha256-oZXlHKr6IYKR8suqP+9p/TNTyT7EtlsqRyLEz0DDGYw=";
+        };
+        # Environment variable used in shapely/_buildcfg.py
+        GEOS_LIBRARY_PATH = "${geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}";
+        patches = [
+          # Patch to search form GOES .so/.dylib files in a Nix-aware way
+          (substituteAll {
+            src = ./shapely-library-paths.patch;
+            libgeos_c = GEOS_LIBRARY_PATH;
+            libc = lib.optionalString (!stdenv.isDarwin) "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6";
+          })
+        ];
+      });
+    };
+  };
+in python.pkgs.buildPythonApplication rec {
   pname = "flatcam";
   version = "8.5";
 
@@ -15,7 +41,7 @@ python3Packages.buildPythonApplication rec {
     sha256 = "199kiiml18k34z1zhk2hbhibphmnv0kb11kxiajq52alps0mjb3m";
   };
 
-  propagatedBuildInputs = with python3Packages; [
+  propagatedBuildInputs = with python.pkgs; [
     matplotlib
     numpy
     packaging
diff --git a/pkgs/applications/science/electronics/flatcam/shapely-library-paths.patch b/pkgs/applications/science/electronics/flatcam/shapely-library-paths.patch
new file mode 100644
index 000000000000..d095eada9d6e
--- /dev/null
+++ b/pkgs/applications/science/electronics/flatcam/shapely-library-paths.patch
@@ -0,0 +1,31 @@
+diff --git a/shapely/geos.py b/shapely/geos.py
+index 88c5f53..1ccd6e4 100644
+--- a/shapely/geos.py
++++ b/shapely/geos.py
+@@ -96,6 +96,7 @@ if sys.platform.startswith('linux'):
+         alt_paths = [
+             'libgeos_c.so.1',
+             'libgeos_c.so',
++            '@libgeos_c@',
+         ]
+         _lgeos = load_dll('geos_c', fallbacks=alt_paths)
+ 
+@@ -160,6 +161,7 @@ elif sys.platform == 'darwin':
+             "/usr/local/lib/libgeos_c.dylib",
+             # homebrew Apple Silicon
+             "/opt/homebrew/lib/libgeos_c.dylib",
++            "@libgeos_c@",
+         ]
+         _lgeos = load_dll('geos_c', fallbacks=alt_paths)
+ 
+diff --git a/tests/test_dlls.py b/tests/test_dlls.py
+index c71da8e..c36262c 100644
+--- a/tests/test_dlls.py
++++ b/tests/test_dlls.py
+@@ -18,4 +18,5 @@ class LoadingTestCase(unittest.TestCase):
+             '/opt/homebrew/lib/libgeos_c.dylib',  # homebrew (macOS)
+             os.path.join(sys.prefix, "lib", "libgeos_c.so"), # anaconda (Linux)
+             'libgeos_c.so.1',
+-            'libgeos_c.so'])
++            'libgeos_c.so',
++            '@libgeos_c@'])