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