mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
python3Packages.craft-providers: init at 1.23.0
This commit is contained in:
parent
c8019ff09a
commit
bbc690a0df
111
pkgs/development/python-modules/craft-providers/default.nix
Normal file
111
pkgs/development/python-modules/craft-providers/default.nix
Normal file
|
@ -0,0 +1,111 @@
|
|||
{ lib
|
||||
, buildPythonPackage
|
||||
, fetchFromGitHub
|
||||
, nix-update-script
|
||||
, packaging
|
||||
, platformdirs
|
||||
, pydantic_1
|
||||
, pyyaml
|
||||
, requests-unixsocket
|
||||
, setuptools
|
||||
, setuptools-scm
|
||||
, urllib3
|
||||
, pytest-check
|
||||
, pytest-mock
|
||||
, pytestCheckHook
|
||||
, responses
|
||||
, freezegun
|
||||
, pytest-subprocess
|
||||
, pytest-logdog
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "craft-providers";
|
||||
version = "1.23.0";
|
||||
|
||||
pyproject = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "canonical";
|
||||
repo = "craft-providers";
|
||||
rev = "refs/tags/${version}";
|
||||
hash = "sha256-9ZoNgpuGytwozRsw0wnS3d2UBOIsh3VI/uzB1RD2Zac=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./inject-snaps.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace craft_providers/lxd/installer.py \
|
||||
--replace-fail "/var/snap/lxd/common/lxd/unix.socket" "/var/lib/lxd/unix.socket"
|
||||
|
||||
substituteInPlace craft_providers/__init__.py \
|
||||
--replace-fail "dev" "${version}"
|
||||
|
||||
# The urllib3 incompat: https://github.com/msabramo/requests-unixsocket/pull/69
|
||||
# This is already patched in nixpkgs.
|
||||
substituteInPlace pyproject.toml \
|
||||
--replace-fail "setuptools==67.8.0" "setuptools" \
|
||||
--replace-fail "urllib3<2" "urllib3"
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
setuptools-scm
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
packaging
|
||||
platformdirs
|
||||
pydantic_1
|
||||
pyyaml
|
||||
requests-unixsocket
|
||||
urllib3
|
||||
];
|
||||
|
||||
pythonImportsCheck = [
|
||||
"craft_providers"
|
||||
];
|
||||
|
||||
nativeCheckInputs = [
|
||||
freezegun
|
||||
pytest-check
|
||||
pytest-mock
|
||||
pytest-subprocess
|
||||
pytest-logdog
|
||||
pytestCheckHook
|
||||
responses
|
||||
];
|
||||
|
||||
preCheck = ''
|
||||
mkdir -p check-phase
|
||||
export HOME="$(pwd)/check-phase"
|
||||
'';
|
||||
|
||||
pytestFlagsArray = [ "tests/unit" ];
|
||||
|
||||
disabledTestPaths = [
|
||||
# Relies upon "logassert" python package which isn't in nixpkgs
|
||||
"tests/unit/bases/test_ubuntu_buildd.py"
|
||||
"tests/unit/bases/test_centos_7.py"
|
||||
"tests/unit/bases/test_almalinux.py"
|
||||
"tests/unit/actions/test_snap_installer.py"
|
||||
# Relies upon "pytest-time" python package which isn't in nixpkgs
|
||||
"tests/unit/multipass"
|
||||
"tests/unit/lxd"
|
||||
"tests/unit/test_base.py"
|
||||
"tests/unit/util/test_retry.py"
|
||||
];
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
|
||||
meta = {
|
||||
description = "Interfaces for instantiating and controlling a variety of build environments";
|
||||
homepage = "https://github.com/canonical/craft-providers";
|
||||
changelog = "https://github.com/canonical/craft-providers/releases/tag/${version}";
|
||||
license = lib.licenses.lgpl3Only;
|
||||
maintainers = with lib.maintainers; [ jnsgruk ];
|
||||
platforms = lib.platforms.linux;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
diff --git a/craft_providers/base.py b/craft_providers/base.py
|
||||
index 3c914a2..d9c2cf9 100644
|
||||
--- a/craft_providers/base.py
|
||||
+++ b/craft_providers/base.py
|
||||
@@ -655,37 +655,22 @@ class Base(ABC):
|
||||
),
|
||||
)
|
||||
|
||||
- if snap.channel:
|
||||
- try:
|
||||
- snap_installer.install_from_store(
|
||||
- executor=executor,
|
||||
- snap_name=snap.name,
|
||||
- channel=snap.channel,
|
||||
- classic=snap.classic,
|
||||
- )
|
||||
- except SnapInstallationError as error:
|
||||
- raise BaseConfigurationError(
|
||||
- brief=(
|
||||
- f"failed to install snap {snap.name!r} from store"
|
||||
- f" channel {snap.channel!r} in target environment."
|
||||
- ),
|
||||
- details=error.details,
|
||||
- ) from error
|
||||
- else:
|
||||
- try:
|
||||
- snap_installer.inject_from_host(
|
||||
- executor=executor,
|
||||
- snap_name=snap.name,
|
||||
- classic=snap.classic,
|
||||
- )
|
||||
- except SnapInstallationError as error:
|
||||
- raise BaseConfigurationError(
|
||||
- brief=(
|
||||
- f"failed to inject host's snap {snap.name!r} "
|
||||
- "into target environment."
|
||||
- ),
|
||||
- details=error.details,
|
||||
- ) from error
|
||||
+ try:
|
||||
+ channel = "latest/edge" if snap.name == "rockcraft" else "latest/stable"
|
||||
+ snap_installer.install_from_store(
|
||||
+ executor=executor,
|
||||
+ snap_name=snap.name,
|
||||
+ channel=channel,
|
||||
+ classic=snap.classic,
|
||||
+ )
|
||||
+ except SnapInstallationError as error:
|
||||
+ raise BaseConfigurationError(
|
||||
+ brief=(
|
||||
+ f"failed to install snap {snap.name!r} from store"
|
||||
+ f" channel {channel!r} in target environment."
|
||||
+ ),
|
||||
+ details=error.details,
|
||||
+ ) from error
|
||||
|
||||
def wait_until_ready(self, executor: Executor) -> None:
|
||||
"""Wait until base instance is ready.
|
|
@ -2447,6 +2447,8 @@ self: super: with self; {
|
|||
|
||||
cpyparsing = callPackage ../development/python-modules/cpyparsing { };
|
||||
|
||||
craft-providers = callPackage ../development/python-modules/craft-providers { };
|
||||
|
||||
cram = callPackage ../development/python-modules/cram { };
|
||||
|
||||
cramjam = callPackage ../development/python-modules/cramjam { };
|
||||
|
|
Loading…
Reference in a new issue