about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/ge/gerbolyze/package.nix
blob: ce177e6aa03bf0f6cc80d5d6b8aad247062120a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{ lib
, stdenv
, python3Packages
, fetchFromGitHub
, resvg
}:

let
  version = "3.1.7";
  src = fetchFromGitHub {
    owner = "jaseg";
    repo = "gerbolyze";
    rev = "v${version}";
    hash = "sha256-0iTelSlUJUafclRowwsUAoO44nc/AXaOKXnZKfKOIaE=";
    fetchSubmodules = true;
  };

  svg-flatten = stdenv.mkDerivation rec {
    inherit version src;
    pname = "svg-flatten";

    sourceRoot = "${src.name}/svg-flatten";

    postPatch = ''
      substituteInPlace Makefile \
        --replace "$(INSTALL) $(BUILDDIR)/$(BINARY) $(PREFIX)/bin" \
        "$(INSTALL) $(BUILDDIR)/$(BINARY) $(PREFIX)/bin/svg-flatten" \
    '';

    installPhase = ''
      runHook preInstall
      mkdir -p $out/bin
      PREFIX=$out make install
      runHook postInstall
    '';

    meta = with lib; {
      description = "svg-flatten SVG downconverter";
      homepage = "https://github.com/jaseg/gerbolyze";
      license = with licenses; [ agpl3 ];
      maintainers = with maintainers; [ wulfsta ];
      mainProgram = "svg-flatten";
      platforms = platforms.linux;
    };
  };
in python3Packages.buildPythonApplication rec {
  inherit version src;
  pname = "gerbolyze";

  format = "setuptools";

  nativeBuildInputs = [
    python3Packages.setuptools
  ];

  propagatedBuildInputs = [
    python3Packages.beautifulsoup4
    python3Packages.click
    python3Packages.numpy
    python3Packages.scipy
    python3Packages.python-slugify
    python3Packages.lxml
    python3Packages.gerbonara
    resvg
    svg-flatten
  ];

  preConfigure = ''
    # setup.py tries to execute a call to git in a subprocess, this avoids it.
    substituteInPlace setup.py \
      --replace "version = get_version()," \
                "version = '${version}'," \

    # setup.py tries to execute a call to git in a subprocess, this avoids it.
    substituteInPlace setup.py \
      --replace "long_description=format_readme_for_pypi()," \
                "long_description='\n'.join(Path('README.rst').read_text().splitlines()),"
  '';

  pythonImportsCheck = [ "gerbolyze" ];

  nativeCheckInputs = [ python3Packages.pytestCheckHook resvg svg-flatten ];

  meta = with lib; {
    description = "Directly render SVG overlays into Gerber and Excellon files";
    homepage = "https://github.com/jaseg/gerbolyze";
    license = with licenses; [ agpl3 ];
    maintainers = with maintainers; [ wulfsta ];
    mainProgram = "gerbolyze";
    platforms = platforms.linux;
  };
}