diff --git a/pkgs/development/python-modules/vl-convert-python/default.nix b/pkgs/development/python-modules/vl-convert-python/default.nix new file mode 100644 index 000000000000..dcce1668bba9 --- /dev/null +++ b/pkgs/development/python-modules/vl-convert-python/default.nix @@ -0,0 +1,61 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + rustPlatform, + protobuf, + libffi, + callPackage, + librusty_v8 ? callPackage ./librusty_v8.nix { }, + nix-update-script, +}: +buildPythonPackage rec { + pname = "vl-convert-python"; + version = "1.7.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "vega"; + repo = "vl-convert"; + tag = "v${version}"; + hash = "sha256-dmfY05i5nCiM2felvBcSuVyY8G70HhpJP3KrRGQ7wq8="; + }; + + patches = [ ./libffi-sys-system-feature.patch ]; + + cargoDeps = rustPlatform.fetchCargoVendor { + inherit src; + name = "${pname}-${version}"; + hash = "sha256-t952WH6zq7POVvdX3fI7kXXfPiaAXjfsvoqI/aq5Fn0="; + }; + + buildAndTestSubdir = "vl-convert-python"; + + env.RUSTY_V8_ARCHIVE = librusty_v8; + + build-system = [ + rustPlatform.maturinBuildHook + rustPlatform.cargoSetupHook + ]; + + nativeBuildInputs = [ protobuf ]; + + buildInputs = [ libffi ]; + + pythonImportsCheck = [ "vl_convert" ]; + + passthru.updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "vl-convert-python@(.*)" + ]; + }; + + meta = { + description = "Utilities for converting Vega-Lite specs from the command line and Python"; + license = lib.licenses.bsd3; + homepage = "https://github.com/vega/vl-convert"; + changelog = "https://github.com/vega/vl-convert/releases/tag/v${version}"; + maintainers = with lib.maintainers; [ antonmosich ]; + }; +} diff --git a/pkgs/development/python-modules/vl-convert-python/libffi-sys-system-feature.patch b/pkgs/development/python-modules/vl-convert-python/libffi-sys-system-feature.patch new file mode 100644 index 000000000000..bb86dd292cdb --- /dev/null +++ b/pkgs/development/python-modules/vl-convert-python/libffi-sys-system-feature.patch @@ -0,0 +1,10 @@ +diff --git a/vl-convert-python/Cargo.toml b/vl-convert-python/Cargo.toml +index 3d24fa4..25020db 100644 +--- a/vl-convert-python/Cargo.toml ++++ b/vl-convert-python/Cargo.toml +@@ -22,3 +22,5 @@ lazy_static = { workspace = true } + futures = { workspace = true } + pythonize = { workspace = true } + tokio = { workspace = true } ++ ++libffi = { version = "3.2.0", features = ["system"] } diff --git a/pkgs/development/python-modules/vl-convert-python/librusty_v8.nix b/pkgs/development/python-modules/vl-convert-python/librusty_v8.nix new file mode 100644 index 000000000000..53aaf4910485 --- /dev/null +++ b/pkgs/development/python-modules/vl-convert-python/librusty_v8.nix @@ -0,0 +1,28 @@ +{ + lib, + stdenv, + fetchurl, +}: + +let + fetch_librusty_v8 = + args: + fetchurl { + name = "librusty_v8-${args.version}"; + url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${stdenv.hostPlatform.rust.rustcTarget}.a.gz"; + sha256 = args.shas.${stdenv.hostPlatform.system}; + meta = { + inherit (args) version; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; + }; +in +fetch_librusty_v8 { + version = "0.105.1"; + shas = { + x86_64-linux = "sha256-f7aDA74Jn2h4rp9sACGHX4DBbN6yevgWCEKdfI1fJDU="; + aarch64-linux = "sha256-vuEP7in+A/PrBXSunRq1SC77dOuMiScsKcA712AuNuk="; + x86_64-darwin = "sha256-sNe2VCwZvy64jdbPwx7pZ91fFRv1xosOcGiAtSPbt8A="; + aarch64-darwin = "sha256-GmwTJADMxArwOvRN/w5KVmWGc1+WfraBc/wWe7dxHMg="; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 366ee388f55b..256f47de64f7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -18989,6 +18989,10 @@ self: super: with self; { inherit (pkgs.libsForQt5) wrapQtAppsHook; }; + vl-convert-python = callPackage ../development/python-modules/vl-convert-python { + inherit (pkgs) protobuf; + }; + vllm = callPackage ../development/python-modules/vllm { }; vmprof = callPackage ../development/python-modules/vmprof { };