1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 nix-update-script,
6 overrides,
7 pydantic,
8 pyxdg,
9 pyyaml,
10 requests,
11 requests-unixsocket,
12 pyfakefs,
13 pytestCheckHook,
14 pytest-check,
15 pytest-mock,
16 pytest-subprocess,
17 requests-mock,
18 hypothesis,
19 jsonschema,
20 git,
21 squashfsTools,
22 socat,
23 setuptools-scm,
24 stdenv,
25 ant,
26 maven,
27 jdk,
28}:
29
30buildPythonPackage rec {
31 pname = "craft-parts";
32 version = "2.8.0";
33
34 pyproject = true;
35
36 src = fetchFromGitHub {
37 owner = "canonical";
38 repo = "craft-parts";
39 tag = version;
40 hash = "sha256-1SnT/yB6vJm82yhszBRjeph13B91KYap8/KR4L9VcjM=";
41 };
42
43 patches = [ ./bash-path.patch ];
44
45 build-system = [ setuptools-scm ];
46
47 pythonRelaxDeps = [
48 "requests"
49 "urllib3"
50 "pydantic"
51 ];
52
53 dependencies = [
54 overrides
55 pydantic
56 pyxdg
57 pyyaml
58 requests
59 requests-unixsocket
60 ];
61
62 pythonImportsCheck = [ "craft_parts" ];
63
64 nativeCheckInputs = [
65 ant
66 git
67 hypothesis
68 jdk
69 jsonschema
70 maven
71 pyfakefs
72 pytest-check
73 pytest-mock
74 pytest-subprocess
75 pytestCheckHook
76 requests-mock
77 socat
78 squashfsTools
79 ];
80
81 pytestFlagsArray = [ "tests/unit" ];
82
83 preCheck = ''
84 export HOME=$(mktemp -d)
85 '';
86
87 disabledTests = [
88 # Relies upon paths not present in Nix (like /bin/bash)
89 "test_run_builtin_build"
90 "test_run_prime"
91 "test_get_build_packages_with_source_type"
92 "test_get_build_packages"
93 # Relies upon certain paths being present that don't make sense on Nix.
94 "test_java_plugin_jre_not_17"
95 ];
96
97 disabledTestPaths =
98 [
99 # Relies upon filesystem extended attributes, and suid/guid bits
100 "tests/unit/sources/test_base.py"
101 "tests/unit/packages/test_base.py"
102 "tests/unit/state_manager"
103 "tests/unit/test_xattrs.py"
104 "tests/unit/packages/test_normalize.py"
105 # Relies upon presence of apt/dpkg.
106 "tests/unit/packages/test_apt_cache.py"
107 "tests/unit/packages/test_deb.py"
108 "tests/unit/packages/test_chisel.py"
109 ]
110 ++ lib.optionals stdenv.hostPlatform.isAarch64 [
111 # These tests have hardcoded "amd64" strings which fail on aarch64
112 "tests/unit/executor/test_environment.py"
113 "tests/unit/features/overlay/test_executor_environment.py"
114 ];
115
116 passthru.updateScript = nix-update-script { };
117
118 meta = {
119 description = "Software artifact parts builder from Canonical";
120 homepage = "https://github.com/canonical/craft-parts";
121 changelog = "https://github.com/canonical/craft-parts/releases/tag/${src.tag}";
122 license = lib.licenses.lgpl3Only;
123 maintainers = with lib.maintainers; [ jnsgruk ];
124 platforms = lib.platforms.linux;
125 };
126}