-
-
Save NorfairKing/47aaf778eafffecc0d6ba8fa5aae30d5 to your computer and use it in GitHub Desktop.
Horrible, hacky packaging of orjson with Nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ fetchFromGitHub | |
, python | |
, maturin | |
, arrow | |
, dataclasses | |
, numpy | |
, pendulum | |
, psutil | |
, pytest | |
, pytz | |
, black | |
, isort | |
, mypy | |
, typing-extensions | |
}: | |
let | |
src = fetchFromGitHub { | |
owner = "ijl"; | |
repo = "orjson"; | |
rev = "789e03a31e525424dff6c170370f9e483725d508"; | |
sha256 = "00vhh2x5mb4dx4xk0gi0h0yw29hwargy51ks39dg4i6hc17f9aqs"; | |
}; | |
nixpkgs-mozilla = import (fetchFromGitHub { | |
owner = "mozilla"; | |
repo = "nixpkgs-mozilla"; | |
rev = "e912ed483e980dfb4666ae0ed17845c4220e5e7c"; | |
# date = 2020-02-19T12:55:00-05:00; | |
sha256 = "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3"; | |
}); | |
pkgs = import <nixpkgs> { | |
overlays = | |
[ | |
nixpkgs-mozilla | |
(self: super: | |
{ | |
rustc = self.latest.rustChannels.nightly.rust; | |
cargo = self.latest.rustChannels.nightly.rust; | |
} | |
) | |
]; | |
}; | |
naersk = pkgs.callPackage (pkgs.fetchFromGitHub { | |
owner = "nmattia"; | |
repo = "naersk"; | |
rev = "7d23ad7e33a92434b52129b16f1e2df2a9b8515e"; | |
sha256 = "11xgjjlp05ymiylb7i18aqrsa7acsifdk7w37jfd4dxmnzm69z1q"; | |
}) {}; | |
rustPkg = naersk.buildPackage { | |
root = src; | |
buildInputs = [ python maturin ]; | |
}; | |
in buildPythonPackage rec { | |
name = "${pname}-${version}"; | |
pname = "orjson"; | |
version = "2.6.0"; | |
inherit src; | |
inherit (rustPkg) crate_sources cargoconfig configurePhase RUSTC | |
cargo_release cargo_options cargo_build_options cargo_test_options | |
cargo_bins_jq_filter; | |
nativeBuildInputs = rustPkg.nativeBuildInputs ++ [ pkgs.maturin ]; | |
buildPhase = '' | |
export RUSTFLAGS="-Zmutable-noalias -C target-feature=+sse2 $RUSTFLAGS" | |
maturin build --manylinux off --no-sdist --release -i python3.6 -o dist | |
''; | |
installCheckPhase = '' | |
pytest test | |
''; | |
propagatedBuildInputs = [ | |
black | |
isort | |
mypy | |
typing-extensions | |
]; | |
checkInputs = [ | |
arrow | |
dataclasses | |
numpy | |
pendulum | |
psutil | |
pytest | |
pytz | |
typing-extensions | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment