From 3582633bbbdc0ef8dd11c6296cbbd2ef8b7faab9 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Wed, 13 Mar 2024 16:35:28 +0000 Subject: [PATCH] python3Packages.craft-parts: init at 1.26.2 --- .../craft-parts/bash-path.patch | 41 ++++++ .../python-modules/craft-parts/default.nix | 119 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 162 insertions(+) create mode 100644 pkgs/development/python-modules/craft-parts/bash-path.patch create mode 100644 pkgs/development/python-modules/craft-parts/default.nix diff --git a/pkgs/development/python-modules/craft-parts/bash-path.patch b/pkgs/development/python-modules/craft-parts/bash-path.patch new file mode 100644 index 000000000000..80e63d48003d --- /dev/null +++ b/pkgs/development/python-modules/craft-parts/bash-path.patch @@ -0,0 +1,41 @@ +diff --git a/craft_parts/executor/step_handler.py b/craft_parts/executor/step_handler.py +index 404df69..f90e2ac 100644 +--- a/craft_parts/executor/step_handler.py ++++ b/craft_parts/executor/step_handler.py +@@ -243,8 +243,9 @@ class StepHandler: + print(script, file=script_file) + script_file.flush() + script_file.seek(0) ++ import shutil + process = subprocess.Popen( # pylint: disable=consider-using-with +- ["/bin/bash"], ++ [shutil.which("bash")], + stdin=script_file, + cwd=work_dir, + stdout=self._stdout, +@@ -394,7 +395,8 @@ def _create_and_run_script( + ) -> None: + """Create a script with step-specific commands and execute it.""" + with script_path.open("w") as run_file: +- print("#!/bin/bash", file=run_file) ++ import shutil ++ print(f"#!{shutil.which('bash')}", file=run_file) + print("set -euo pipefail", file=run_file) + + if build_environment_script_path: +diff --git a/craft_parts/plugins/validator.py b/craft_parts/plugins/validator.py +index b8d8f11..fce0e72 100644 +--- a/craft_parts/plugins/validator.py ++++ b/craft_parts/plugins/validator.py +@@ -142,9 +142,9 @@ class PluginEnvironmentValidator: + print(self._env, file=env_file) + print(cmd, file=env_file) + env_file.flush() +- ++ import shutil + proc = subprocess.run( +- ["/bin/bash", env_file.name], ++ [shutil.which("bash"), env_file.name], + check=True, + capture_output=True, + text=True, diff --git a/pkgs/development/python-modules/craft-parts/default.nix b/pkgs/development/python-modules/craft-parts/default.nix new file mode 100644 index 000000000000..bf8367a0ff49 --- /dev/null +++ b/pkgs/development/python-modules/craft-parts/default.nix @@ -0,0 +1,119 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, nix-update-script +, overrides +, pydantic_1 +, pydantic-yaml-0 +, pyxdg +, pyyaml +, requests +, requests-unixsocket +, types-pyyaml +, urllib3 +, pytestCheckHook +, pytest-check +, pytest-mock +, pytest-subprocess +, requests-mock +, hypothesis +, git +, squashfsTools +, setuptools +, setuptools-scm +}: + +buildPythonPackage rec { + pname = "craft-parts"; + version = "1.26.2"; + + pyproject = true; + + src = fetchFromGitHub { + owner = "canonical"; + repo = "craft-parts"; + rev = "refs/tags/${version}"; + hash = "sha256-wHv0JWffS916RK4Kgk+FuRthx+ajh0Ka4DBwGrLdUBs="; + }; + + patches = [ + ./bash-path.patch + ]; + + postPatch = '' + substituteInPlace setup.py \ + --replace-fail "pydantic-yaml[pyyaml]>=0.11.0,<1.0.0" "pydantic-yaml[pyyaml]" \ + --replace-fail "urllib3<2" "urllib3" + ''; + + nativeBuildInputs = [ + setuptools + setuptools-scm + ]; + + propagatedBuildInputs = [ + overrides + pydantic_1 + pydantic-yaml-0 + pyxdg + pyyaml + requests + requests-unixsocket + types-pyyaml + urllib3 + ]; + + pythonImportsCheck = [ + "craft_parts" + ]; + + nativeCheckInputs = [ + git + hypothesis + pytest-check + pytest-mock + pytest-subprocess + pytestCheckHook + requests-mock + squashfsTools + ]; + + pytestFlagsArray = [ "tests/unit" ]; + + preCheck = '' + export HOME=$(mktemp -d) + ''; + + disabledTests = [ + # Relies upon paths not present in Nix (like /bin/bash) + "test_run_builtin_build" + "test_run_prime" + "test_get_build_packages_with_source_type" + "test_get_build_packages" + ]; + + disabledTestPaths = [ + # Relies upon filesystem extended attributes, and suid/guid bits + "tests/unit/sources/test_base.py" + "tests/unit/packages/test_base.py" + "tests/unit/state_manager" + "tests/unit/test_xattrs.py" + "tests/unit/packages/test_normalize.py" + # Relies upon presence of apt/dpkg. + "tests/unit/packages/test_apt_cache.py" + "tests/unit/packages/test_deb.py" + "tests/unit/packages/test_chisel.py" + ]; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Software artifact parts builder from Canonical"; + homepage = "https://github.com/canonical/craft-parts"; + changelog = "https://github.com/canonical/craft-parts/releases/tag/${version}"; + license = lib.licenses.lgpl3Only; + maintainers = with lib.maintainers; [ jnsgruk ]; + platforms = lib.platforms.linux; + }; +} + diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index a70a4167070b..f89e68cf8362 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2447,6 +2447,8 @@ self: super: with self; { cpyparsing = callPackage ../development/python-modules/cpyparsing { }; + craft-parts = callPackage ../development/python-modules/craft-parts { }; + craft-providers = callPackage ../development/python-modules/craft-providers { }; cram = callPackage ../development/python-modules/cram { };