1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, poetry-core
6, setuptools
7, shapely
8, pytestCheckHook
9}:
10
11buildPythonPackage rec {
12 pname = "preprocess-cancellation";
13 version = "0.2.0";
14 disabled = pythonOlder "3.6"; # >= 3.6
15 format = "pyproject";
16
17 # No tests in PyPI
18 src = fetchFromGitHub {
19 owner = "kageurufu";
20 repo = "cancelobject-preprocessor";
21 rev = version;
22 hash = "sha256-mn3/etXA5dkL+IsyxwD4/XjU/t4/roYFVyqQxlLOoOI=";
23 };
24
25 patches = [
26 ./pep-621.patch
27 ];
28
29 postPatch = ''
30 sed -i "/^addopts/d" pyproject.toml
31
32 # setuptools 61 compatibility
33 # error: Multiple top-level packages discovered in a flat-layout: ['STLs', 'GCode'].
34 mkdir tests
35 mv GCode STLs test_* tests
36 substituteInPlace tests/test_preprocessor.py \
37 --replace "./GCode" "./tests/GCode"
38 substituteInPlace tests/test_preprocessor_with_shapely.py \
39 --replace "./GCode" "./tests/GCode"
40 '';
41
42 nativeBuildInputs = [
43 poetry-core
44 setuptools
45 ];
46
47 propagatedBuildInputs = [
48 shapely
49 ];
50
51 nativeCheckInputs = [
52 pytestCheckHook
53 ];
54
55 pythonImportsCheck = [ "preprocess_cancellation" ];
56
57 meta = with lib; {
58 description = "Klipper GCode Preprocessor for Object Cancellation";
59 homepage = "https://github.com/kageurufu/cancelobject-preprocessor";
60 license = licenses.gpl3Only;
61 maintainers = with maintainers; [ zhaofengli ];
62 };
63}