nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at r-updates 121 lines 3.6 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 cbor2, 5 docopt, 6 fetchFromGitHub, 7 fetchpatch2, 8 jsonconversion, 9 pytestCheckHook, 10 pytest_7, 11 setuptools, 12 six, 13 tabulate, 14 cmake, 15}: 16 17buildPythonPackage rec { 18 pname = "amazon-ion"; 19 version = "0.13.0"; 20 pyproject = true; 21 22 src = fetchFromGitHub { 23 owner = "amazon-ion"; 24 repo = "ion-python"; 25 tag = "v${version}"; 26 # Test vectors require git submodule 27 fetchSubmodules = true; 28 leaveDotGit = true; # During ion-c submodule build git history/hash used to infer version 29 postFetch = '' 30 # Generated file should match output of command in ion-c/cmake/VersionHeader.cmake 31 # Run Git before creating any files to avoid triggering false dirty suffix. 32 (cd "$out/ion-c" && v="$(git describe --long --tags --dirty --match "v*")" && echo -n "$v" > .nixpkgs-patching-IONC_FULL_VERSION.txt) 33 34 # Based on https://github.com/NixOS/nixpkgs/blob/183125f9/pkgs/build-support/fetchgit/nix-prefetch-git#L358 35 find "$out" -name .git -exec rm -rf '{}' '+' 36 ''; 37 hash = "sha256-VBbxGXPAwS3jwEsm64yEKqJKVKGvPStboLjHoRcoonE="; 38 }; 39 40 patches = [ 41 # backport changes that adapt code to more strict compilers 42 (fetchpatch2 { 43 name = "46aebb0-Address-incompatible-pointer-errors.patch"; 44 url = "https://github.com/amazon-ion/ion-c/commit/46aebb0b650a4cf61425ef1a8e78e2443023e853.patch?full_index=1"; 45 hash = "sha256-5qzSbZV9Oe5soJzkyCtVtWejedLEjAz7yuVotATPmbs="; 46 stripLen = 1; 47 extraPrefix = "ion-c/"; 48 }) 49 ]; 50 51 postPatch = '' 52 substituteInPlace setup.py \ 53 --replace "'pytest-runner'," "" 54 55 # Ion C building is in _download_ion_c() which will try to remove sources and re-download 56 substituteInPlace install.py \ 57 --replace-fail "isdir(_CURRENT_ION_C_DIR)" "False" 58 substituteInPlace install.py \ 59 --replace-fail "check_call(['git'" "check_call(['true'" 60 61 # Ion-C infers version based on Git. But there are issues with making .git folders deterministic. 62 # See https://github.com/NixOS/nixpkgs/issues/8567 63 # Hence, we'll inject version ourselves 64 substituteInPlace ion-c/cmake/VersionHeader.cmake \ 65 --replace-fail 'set(IONC_FULL_VERSION "''${CMAKE_PROJECT_VERSION}")' \ 66 "set(IONC_FULL_VERSION \"$(cat ion-c/.nixpkgs-patching-IONC_FULL_VERSION.txt)\")" 67 ''; 68 69 build-system = [ 70 setuptools 71 ]; 72 73 dontUseCmakeConfigure = true; # CMake invoked by install.py 74 75 # Can't use cmakeFlags since we do not control invocation of cmake. 76 # But build-release.sh in ion-c is sensitive to this env variable. 77 env.CMAKE_FLAGS = "-DCMAKE_SKIP_BUILD_RPATH=ON"; 78 79 nativeBuildInputs = [ 80 cmake 81 ]; 82 83 dependencies = [ 84 jsonconversion 85 six 86 ]; 87 88 nativeCheckInputs = [ 89 cbor2 90 docopt 91 (pytestCheckHook.override { pytest = pytest_7; }) 92 tabulate 93 ]; 94 95 disabledTests = [ 96 # ValueError: Exceeds the limit (4300) for integer string conversion 97 "test_roundtrips" 98 ]; 99 100 disabledTestPaths = [ 101 # Exclude benchmarks 102 "tests/test_benchmark_cli.py" 103 ]; 104 105 pythonImportsCheck = [ 106 "amazon.ion" 107 "amazon.ion.ionc" # C extension module for speedup 108 ]; 109 110 meta = { 111 description = "Python implementation of Amazon Ion"; 112 homepage = "https://github.com/amazon-ion/ion-python"; 113 changelog = "https://github.com/amazon-ion/ion-python/releases/tag/${src.tag}"; 114 sourceProvenance = with lib.sourceTypes; [ 115 fromSource 116 binaryNativeCode 117 ]; 118 license = lib.licenses.asl20; 119 maintainers = with lib.maintainers; [ terlar ]; 120 }; 121}