Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Python3Packages.pyqir: init at 0.8.2 #237604

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions pkgs/development/python-modules/pyqir/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}
5 changes: 5 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down