libpostal: Use real 1.1 release, add data files and enable tests (#362841)

Changed files
+35 -40
pkgs
-24
pkgs/by-name/li/libpostal/0001-test-adding-header-to-fix-warning.patch
···
-
From bfdb6b8f87cc1cae9ba47870ff23deae0bb8ba51 Mon Sep 17 00:00:00 2001
-
From: Al <albarrentine@gmail.com>
-
Date: Sun, 17 Dec 2017 20:17:01 -0500
-
Subject: [PATCH] [test] adding header to fix warning
-
-
---
-
test/test_expand.c | 2 +-
-
1 file changed, 1 insertion(+), 1 deletion(-)
-
-
diff --git a/test/test_expand.c b/test/test_expand.c
-
index 59ed9af7..2b211728 100644
-
--- a/test/test_expand.c
-
+++ b/test/test_expand.c
-
@@ -4,6 +4,7 @@
-
#include <stdarg.h>
-
-
#include "greatest.h"
-
+#include "../src/string_utils.h"
-
#include "../src/libpostal.h"
-
-
SUITE(libpostal_expansion_tests);
-
--
-
2.42.0
-
+31 -16
pkgs/by-name/li/libpostal/package.nix
···
-
{ lib, stdenv, fetchFromGitHub, fetchpatch, autoreconfHook }:
+
{ lib, stdenv, fetchFromGitHub, fetchzip, autoreconfHook, withData ? false }:
-
stdenv.mkDerivation rec {
+
let
+
releases = "https://github.com/openvenues/libpostal/releases";
+
assets-base = fetchzip {
+
url = "${releases}/download/v1.0.0/libpostal_data.tar.gz";
+
hash = "sha256-FpGCkkRhVzyr08YcO0/iixxw0RK+3Of0sv/DH3GbbME=";
+
stripRoot = false;
+
};
+
assets-parser = fetchzip {
+
url = "${releases}/download/v1.0.0/parser.tar.gz";
+
hash = "sha256-OHETb3e0GtVS2b4DgklKDlrE/8gxF7XZ3FwmCTqZbqQ=";
+
stripRoot = false;
+
};
+
assets-language-classifier = fetchzip {
+
url = "${releases}/download/v1.0.0/language_classifier.tar.gz";
+
hash = "sha256-/Gn931Nx4UDBaiFUgGqC/NJUIKQ5aZT/+OYSlcfXva8=";
+
stripRoot = false;
+
};
+
in stdenv.mkDerivation rec {
pname = "libpostal";
version = "1.1";
src = fetchFromGitHub {
owner = "openvenues";
repo = "libpostal";
-
rev = "v${version}";
-
sha256 = "sha256-gQTD2LQibaB2TK0SbzoILAljAGExURvDcF3C/TfDXqk=";
+
rev = "refs/tags/v${version}";
+
hash = "sha256-7G/CjYdVzsrvUFXGODoXgXoRp8txkl5SddcPtgltrjY=";
};
-
patches = [
-
# Fix darwin compilation with XCode 12 https://github.com/openvenues/libpostal/issues/511
-
(fetchpatch {
-
name = "Fix-C-compilation-macOS.patch";
-
url = "https://github.com/openvenues/libpostal/commit/9fcf066e38121b5c1439fc6bdc9a7e02234c8622.patch";
-
hash = "sha256-VpboGK+5sc1XrxMB051KWc8vP7Eu2g7zmTirzSaerns=";
-
})
-
# https://github.com/openvenues/libpostal/commit/bfdb6b8f87cc1cae9ba47870ff23deae0bb8ba51.patch
-
# with extra hunk removed so it applies
-
./0001-test-adding-header-to-fix-warning.patch
-
];
-
nativeBuildInputs = [ autoreconfHook ];
configureFlags = [
"--disable-data-download"
] ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "--disable-sse2" ];
+
+
postBuild = lib.optionalString withData ''
+
mkdir -p $out/share/libpostal
+
ln -s ${assets-language-classifier}/language_classifier $out/share/libpostal/language_classifier
+
ln -s ${assets-base}/transliteration $out/share/libpostal/transliteration
+
ln -s ${assets-base}/numex $out/share/libpostal/numex
+
ln -s ${assets-base}/address_expansions $out/share/libpostal/address_expansions
+
ln -s ${assets-parser}/address_parser $out/share/libpostal/address_parser
+
'';
+
doCheck = withData;
meta = with lib; {
description = "C library for parsing/normalizing street addresses around the world. Powered by statistical NLP and open geo data";
+4
pkgs/top-level/all-packages.nix
···
biblioteca = callPackage ../by-name/bi/biblioteca/package.nix {
webkitgtk = webkitgtk_6_0;
+
+
libpostalWithData = callPackage ../by-name/li/libpostal/package.nix {
+
withData = true;
+
};