Commit 0650d380 authored by Jeremy Fleischman's avatar Jeremy Fleischman Committed by Shahar "Dawn" Or
Browse files
parent 1f37289e
Loading
Loading
Loading
Loading
+87 −0
Original line number Diff line number Diff line
{ bc
, zip
, lib
, fetchFromGitHub
, bats
, buildPythonApplication
, pythonOlder
, callPackage
, kicad
, numpy
, click
, markdown2
, pytestCheckHook
, commentjson
, wxPython_4_2
, pcbnew-transition
, pybars3
, versioneer
}:
let
  solidpython = callPackage ./solidpython { };

  # https://github.com/yaqwsx/KiKit/issues/574
  # copy-pasted from nixpkgs#8d8e62e74f511160a599471549a98bc9e4f4818d
  shapely = callPackage ./shapely { };
in
buildPythonApplication rec {
  pname = "kikit";
  version = "1.3.0";
  format = "setuptools";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "yaqwsx";
    repo = "KiKit";
    rev = "v${version}";
    hash = "sha256-kDTPk/R3eZtm4DjoUV4tSQzjGQ9k8MKQedX4oUXYzeo=";
  };

  propagatedBuildInputs = [
    kicad
    numpy
    click
    markdown2
    commentjson
    # https://github.com/yaqwsx/KiKit/issues/575
    wxPython_4_2
    pcbnew-transition
    pybars3
    shapely
    # https://github.com/yaqwsx/KiKit/issues/576
    solidpython
  ];

  nativeBuildInputs = [
    versioneer
    bc
    zip
  ];

  nativeCheckInputs = [
    pytestCheckHook
    bats
  ];

  pythonImportsCheck = [
    "kikit"
  ];

  preCheck = ''
    export PATH=$PATH:$out/bin

    make test-system

    # pytest needs to run in a subdir. See https://github.com/yaqwsx/KiKit/blob/v1.3.0/Makefile#L43
    cd test/units
  '';

  meta = with lib; {
    description = "Automation for KiCAD boards";
    homepage = "https://github.com/yaqwsx/KiKit/";
    changelog = "https://github.com/yaqwsx/KiKit/releases/tag/v${version}";
    maintainers = with maintainers; [ jfly matusf ];
    license = licenses.mit;
  };
}
+2 −0
Original line number Diff line number Diff line
{ python3 }:
(python3.pkgs.callPackage ./default.nix { })
+71 −0
Original line number Diff line number Diff line
{ lib
, stdenv
, buildPythonPackage
, fetchPypi
, substituteAll
, pythonOlder
, geos
, pytestCheckHook
, cython
, numpy
}:

buildPythonPackage rec {
  pname = "Shapely";
  version = "1.8.4";
  disabled = pythonOlder "3.6";

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-oZXlHKr6IYKR8suqP+9p/TNTyT7EtlsqRyLEz0DDGYw=";
  };

  nativeBuildInputs = [
    geos # for geos-config
    cython
  ];

  propagatedBuildInputs = [
    numpy
  ];

  checkInputs = [
    pytestCheckHook
  ];

  # 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 = ./library-paths.patch;
      libgeos_c = GEOS_LIBRARY_PATH;
      libc = lib.optionalString (!stdenv.isDarwin) "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6";
    })
  ];

  preCheck = ''
    rm -r shapely # prevent import of local shapely
  '';

  disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
    # FIXME(lf-): these logging tests are broken, which is definitely our
    # fault. I've tried figuring out the cause and failed.
    #
    # It is apparently some sandbox or no-sandbox related thing on macOS only
    # though.
    "test_error_handler_exception"
    "test_error_handler"
    "test_info_handler"
  ];

  pythonImportsCheck = [ "shapely" ];

  meta = with lib; {
    description = "Geometric objects, predicates, and operations";
    homepage = "https://pypi.python.org/pypi/Shapely/";
    license = with licenses; [ bsd3 ];
    maintainers = with maintainers; [ knedlsepp ];
  };
}
+31 −0
Original line number Diff line number Diff line
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@'])
+66 −0
Original line number Diff line number Diff line
# SolidPython is an unmaintained library with old dependencies.
{ buildPythonPackage
, callPackage
, fetchFromGitHub
, fetchFromGitLab
, fetchpatch
, lib
, pythonRelaxDepsHook

, poetry-core
, prettytable
, pypng
, ply
, setuptools
, euclid3
}:
buildPythonPackage rec {
  pname = "solidpython";
  version = "1.1.3";
  format = "pyproject";

  src = fetchFromGitHub {
    owner = "SolidCode";
    repo = "SolidPython";
    rev = "d962740d600c5dfd69458c4559fc416b9beab575";
    hash = "sha256-3fJta2a5c8hV9FPwKn5pj01aBtsCGSRCz3vvxR/5n0Q=";
  };

  nativeBuildInputs = [
    poetry-core
    pythonRelaxDepsHook
  ];

  propagatedBuildInputs = [
    ply
    setuptools
    euclid3

    prettytable
  ];

  pythonRelaxDeps = [
    # SolidPython has PrettyTable pinned to a hyper-specific version due to
    # some ancient bug with Poetry. They aren't interested in unpinning because
    # SolidPython v1 seems to be deprecated in favor of v2:
    # https://github.com/SolidCode/SolidPython/issues/207
    "PrettyTable"
  ];

  pythonRemoveDeps = [
    # The pypng dependency is only used in an example script.
    "pypng"
  ];

  pythonImportsCheck = [
    "solid"
  ];

  meta = with lib; {
    description = "Python interface to the OpenSCAD declarative geometry language";
    homepage = "https://github.com/SolidCode/SolidPython";
    changelog = "https://github.com/SolidCode/SolidPython/releases/tag/v${version}";
    maintainers = with maintainers; [ jfly ];
    license = licenses.lgpl21Plus;
  };
}