Skip to content

Commit

Permalink
libpostal: Use real 1.1 release, add data files and enable tests (#36…
Browse files Browse the repository at this point in the history
  • Loading branch information
fpletz authored Dec 14, 2024
2 parents ee2ab5b + ea1978d commit e0fa4d8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 40 deletions.

This file was deleted.

47 changes: 31 additions & 16 deletions pkgs/by-name/li/libpostal/package.nix
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
{ 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";
homepage = "https://github.com/openvenues/libpostal";
Expand Down
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18838,4 +18838,8 @@ with pkgs;
biblioteca = callPackage ../by-name/bi/biblioteca/package.nix {
webkitgtk = webkitgtk_6_0;
};

libpostalWithData = callPackage ../by-name/li/libpostal/package.nix {
withData = true;
};
}

0 comments on commit e0fa4d8

Please sign in to comment.