tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
python3Packages.craft-providers: init at 1.23.0
Jon Seager
2 years ago
bbc690a0
c8019ff0
+171
3 changed files
expand all
collapse all
unified
split
pkgs
development
python-modules
craft-providers
default.nix
inject-snaps.patch
top-level
python-packages.nix
+111
pkgs/development/python-modules/craft-providers/default.nix
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
{ lib
2
+
, buildPythonPackage
3
+
, fetchFromGitHub
4
+
, nix-update-script
5
+
, packaging
6
+
, platformdirs
7
+
, pydantic_1
8
+
, pyyaml
9
+
, requests-unixsocket
10
+
, setuptools
11
+
, setuptools-scm
12
+
, urllib3
13
+
, pytest-check
14
+
, pytest-mock
15
+
, pytestCheckHook
16
+
, responses
17
+
, freezegun
18
+
, pytest-subprocess
19
+
, pytest-logdog
20
+
}:
21
+
22
+
buildPythonPackage rec {
23
+
pname = "craft-providers";
24
+
version = "1.23.0";
25
+
26
+
pyproject = true;
27
+
28
+
src = fetchFromGitHub {
29
+
owner = "canonical";
30
+
repo = "craft-providers";
31
+
rev = "refs/tags/${version}";
32
+
hash = "sha256-9ZoNgpuGytwozRsw0wnS3d2UBOIsh3VI/uzB1RD2Zac=";
33
+
};
34
+
35
+
patches = [
36
+
./inject-snaps.patch
37
+
];
38
+
39
+
postPatch = ''
40
+
substituteInPlace craft_providers/lxd/installer.py \
41
+
--replace-fail "/var/snap/lxd/common/lxd/unix.socket" "/var/lib/lxd/unix.socket"
42
+
43
+
substituteInPlace craft_providers/__init__.py \
44
+
--replace-fail "dev" "${version}"
45
+
46
+
# The urllib3 incompat: https://github.com/msabramo/requests-unixsocket/pull/69
47
+
# This is already patched in nixpkgs.
48
+
substituteInPlace pyproject.toml \
49
+
--replace-fail "setuptools==67.8.0" "setuptools" \
50
+
--replace-fail "urllib3<2" "urllib3"
51
+
'';
52
+
53
+
nativeBuildInputs = [
54
+
setuptools
55
+
setuptools-scm
56
+
];
57
+
58
+
propagatedBuildInputs = [
59
+
packaging
60
+
platformdirs
61
+
pydantic_1
62
+
pyyaml
63
+
requests-unixsocket
64
+
urllib3
65
+
];
66
+
67
+
pythonImportsCheck = [
68
+
"craft_providers"
69
+
];
70
+
71
+
nativeCheckInputs = [
72
+
freezegun
73
+
pytest-check
74
+
pytest-mock
75
+
pytest-subprocess
76
+
pytest-logdog
77
+
pytestCheckHook
78
+
responses
79
+
];
80
+
81
+
preCheck = ''
82
+
mkdir -p check-phase
83
+
export HOME="$(pwd)/check-phase"
84
+
'';
85
+
86
+
pytestFlagsArray = [ "tests/unit" ];
87
+
88
+
disabledTestPaths = [
89
+
# Relies upon "logassert" python package which isn't in nixpkgs
90
+
"tests/unit/bases/test_ubuntu_buildd.py"
91
+
"tests/unit/bases/test_centos_7.py"
92
+
"tests/unit/bases/test_almalinux.py"
93
+
"tests/unit/actions/test_snap_installer.py"
94
+
# Relies upon "pytest-time" python package which isn't in nixpkgs
95
+
"tests/unit/multipass"
96
+
"tests/unit/lxd"
97
+
"tests/unit/test_base.py"
98
+
"tests/unit/util/test_retry.py"
99
+
];
100
+
101
+
passthru.updateScript = nix-update-script { };
102
+
103
+
meta = {
104
+
description = "Interfaces for instantiating and controlling a variety of build environments";
105
+
homepage = "https://github.com/canonical/craft-providers";
106
+
changelog = "https://github.com/canonical/craft-providers/releases/tag/${version}";
107
+
license = lib.licenses.lgpl3Only;
108
+
maintainers = with lib.maintainers; [ jnsgruk ];
109
+
platforms = lib.platforms.linux;
110
+
};
111
+
}
+58
pkgs/development/python-modules/craft-providers/inject-snaps.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
diff --git a/craft_providers/base.py b/craft_providers/base.py
2
+
index 3c914a2..d9c2cf9 100644
3
+
--- a/craft_providers/base.py
4
+
+++ b/craft_providers/base.py
5
+
@@ -655,37 +655,22 @@ class Base(ABC):
6
+
),
7
+
)
8
+
9
+
- if snap.channel:
10
+
- try:
11
+
- snap_installer.install_from_store(
12
+
- executor=executor,
13
+
- snap_name=snap.name,
14
+
- channel=snap.channel,
15
+
- classic=snap.classic,
16
+
- )
17
+
- except SnapInstallationError as error:
18
+
- raise BaseConfigurationError(
19
+
- brief=(
20
+
- f"failed to install snap {snap.name!r} from store"
21
+
- f" channel {snap.channel!r} in target environment."
22
+
- ),
23
+
- details=error.details,
24
+
- ) from error
25
+
- else:
26
+
- try:
27
+
- snap_installer.inject_from_host(
28
+
- executor=executor,
29
+
- snap_name=snap.name,
30
+
- classic=snap.classic,
31
+
- )
32
+
- except SnapInstallationError as error:
33
+
- raise BaseConfigurationError(
34
+
- brief=(
35
+
- f"failed to inject host's snap {snap.name!r} "
36
+
- "into target environment."
37
+
- ),
38
+
- details=error.details,
39
+
- ) from error
40
+
+ try:
41
+
+ channel = "latest/edge" if snap.name == "rockcraft" else "latest/stable"
42
+
+ snap_installer.install_from_store(
43
+
+ executor=executor,
44
+
+ snap_name=snap.name,
45
+
+ channel=channel,
46
+
+ classic=snap.classic,
47
+
+ )
48
+
+ except SnapInstallationError as error:
49
+
+ raise BaseConfigurationError(
50
+
+ brief=(
51
+
+ f"failed to install snap {snap.name!r} from store"
52
+
+ f" channel {channel!r} in target environment."
53
+
+ ),
54
+
+ details=error.details,
55
+
+ ) from error
56
+
57
+
def wait_until_ready(self, executor: Executor) -> None:
58
+
"""Wait until base instance is ready.
+2
pkgs/top-level/python-packages.nix
···
2447
2448
cpyparsing = callPackage ../development/python-modules/cpyparsing { };
2449
0
0
2450
cram = callPackage ../development/python-modules/cram { };
2451
2452
cramjam = callPackage ../development/python-modules/cramjam { };
···
2447
2448
cpyparsing = callPackage ../development/python-modules/cpyparsing { };
2449
2450
+
craft-providers = callPackage ../development/python-modules/craft-providers { };
2451
+
2452
cram = callPackage ../development/python-modules/cram { };
2453
2454
cramjam = callPackage ../development/python-modules/cramjam { };