From 17edd17ea92d7fc5f43760e231e22d1d53de9e81 Mon Sep 17 00:00:00 2001 From: Ilya Elenskiy Date: Mon, 12 Jun 2023 18:36:09 +0200 Subject: [PATCH] Python3Packages.pyqir: init at 0.8.2 --- .../python-modules/pyqir/default.nix | 55 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 5 ++ 2 files changed, 60 insertions(+) create mode 100644 pkgs/development/python-modules/pyqir/default.nix diff --git a/pkgs/development/python-modules/pyqir/default.nix b/pkgs/development/python-modules/pyqir/default.nix new file mode 100644 index 0000000000000..d26420f75f2e1 --- /dev/null +++ b/pkgs/development/python-modules/pyqir/default.nix @@ -0,0 +1,55 @@ +{ lib +, buildPythonPackage +, pythonOlder +, fetchFromGitHub +, rustPlatform +, libxml2 +, llvm # LLVM version provided must strictly match pyqir support list +}: +let + llvm-v-major = lib.versions.major llvm.version; + llvm-v-minor = builtins.substring 0 1 (lib.versions.minor llvm.version); +in +buildPythonPackage rec { + pname = "pyqir"; + version = "0.8.2"; + + format = "pyproject"; + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "qir-alliance"; + repo = pname; + rev = "v${version}"; + hash = "sha256-XqNQ2NUP4KzDMtLeREg+A4gT/G2vd1YnaMP+oNMKoIU="; + }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + name = "${pname}-${version}"; + hash = "sha256-frdmi94zuZgBC5enou6WjMiupAY+KItUfvYDuIavZKk="; + }; + + buildAndTestSubdir = "pyqir"; + + nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook ]; + + buildInputs = [ llvm libxml2.dev ]; + + maturinBuildFlags = "-F llvm${llvm-v-major}-${llvm-v-minor}"; + + preConfigure = '' + export LLVM_SYS_${llvm-v-major}${llvm-v-minor}_PREFIX=${llvm.dev} + ''; + + pythonImportsCheck = [ "pyqir" ]; + + passthru.llvm = llvm; + + meta = with lib; { + description = "API for parsing and generating Quantum Intermediate Representation (QIR)"; + homepage = "https://github.com/qir-alliance/pyqir"; + license = licenses.mit; + maintainers = with maintainers; [ evilmav ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b9051f34031dc..eff2d2818a65e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9138,6 +9138,11 @@ self: super: with self; { pypytools = callPackage ../development/python-modules/pypytools { }; + pyqir = callPackage ../development/python-modules/pyqir { + # pyqir supports only specific versions of LLVM + llvm = pkgs.llvm_14; + }; + pyqldb = callPackage ../development/python-modules/pyqldb { }; pyqrcode = callPackage ../development/python-modules/pyqrcode { };