about summary refs log tree commit diff
path: root/pkgs/by-name/ch/charmcraft/package.nix
blob: fc5ef145d1bc1e35bf98a071e9f9b5eb4272d4cb (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
  lib,
  git,
  python3,
  fetchFromGitHub,
  nix-update-script,
}:

let
  python = python3.override {
    packageOverrides = self: super: {
      pydantic-yaml = super.pydantic-yaml.overridePythonAttrs (old: rec {
        version = "0.11.2";
        src = fetchFromGitHub {
          owner = "NowanIlfideme";
          repo = "pydantic-yaml";
          rev = "refs/tags/v${version}";
          hash = "sha256-AeUyVav0/k4Fz69Qizn4hcJKoi/CDR9eUan/nJhWsDY=";
        };
        dependencies = with self; [
          deprecated
          importlib-metadata
          pydantic_1
          ruamel-yaml
          types-deprecated
        ];
      });
    };
  };
in
python.pkgs.buildPythonApplication rec {
  pname = "charmcraft";
  version = "3.1.1";

  pyproject = true;

  src = fetchFromGitHub {
    owner = "canonical";
    repo = "charmcraft";
    rev = "refs/tags/${version}";
    hash = "sha256-oxNbAIf7ltdDYkGJj29zvNDNXT6vt1jWaIqHJoMr7gU=";
  };

  postPatch = ''
    substituteInPlace charmcraft/__init__.py --replace-fail "dev" "${version}"
  '';

  dependencies = with python.pkgs; [
    craft-application
    craft-cli
    craft-parts
    craft-platforms
    craft-providers
    craft-store
    distro
    docker
    humanize
    jinja2
    jsonschema
    pydantic_1
    python-dateutil
    pyyaml
    requests
    requests-toolbelt
    requests-unixsocket
    snap-helpers
    tabulate
    urllib3
  ];

  build-system = with python.pkgs; [
    setuptools
    setuptools-scm
  ];

  pythonRelaxDeps = [ "urllib3" ];

  nativeCheckInputs =
    with python.pkgs;
    [
      hypothesis
      pyfakefs
      pytest-check
      pytest-mock
      pytest-subprocess
      pytestCheckHook
      responses
      setuptools
    ]
    ++ [ git ];

  preCheck = ''
    mkdir -p check-phase
    export HOME="$(pwd)/check-phase"
  '';

  pytestFlagsArray = [ "tests/unit" ];

  disabledTests = [
    # Relies upon the `charm` tool being installed
    "test_validate_missing_charm"
  ];

  passthru.updateScript = nix-update-script { };

  meta = {
    mainProgram = "charmcraft";
    description = "Build and publish Charmed Operators for deployment with Juju";
    homepage = "https://github.com/canonical/charmcraft";
    changelog = "https://github.com/canonical/charmcraft/releases/tag/${version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ jnsgruk ];
    platforms = lib.platforms.linux;
  };
}