1{ 2 buildPythonPackage, 3 fetchFromGitHub, 4 sudachidict, 5 setuptools, 6 sudachipy, 7}: 8 9buildPythonPackage rec { 10 pname = "sudachidict-${sudachidict.dict-type}"; 11 inherit (sudachidict) version meta; 12 pyproject = true; 13 14 src = fetchFromGitHub { 15 owner = "WorksApplications"; 16 repo = "SudachiDict"; 17 tag = "v${version}"; 18 hash = "sha256-nunc0obZ+4GvzP1+GgyOommBpK6sCAOXxwq04PWKf8c="; 19 }; 20 21 sourceRoot = "${src.name}/python"; 22 23 # setup script tries to get data from the network but we use the nixpkgs' one 24 postPatch = '' 25 substituteInPlace setup.py \ 26 --replace 'ZIP_NAME = urlparse(ZIP_URL).path.split("/")[-1]' "" \ 27 --replace "not os.path.exists(RESOURCE_DIR)" "False" 28 substituteInPlace INFO.json \ 29 --replace "%%VERSION%%" ${version} \ 30 --replace "%%DICT_VERSION%%" ${version} \ 31 --replace "%%DICT_TYPE%%" ${sudachidict.dict-type} 32 ''; 33 34 build-system = [ setuptools ]; 35 36 dependencies = [ sudachipy ]; 37 38 # we need to prepare some files before the build 39 # https://github.com/WorksApplications/SudachiDict/blob/develop/package_python.sh 40 preBuild = '' 41 install -Dm644 ${sudachidict}/share/system.dic -t sudachidict_${sudachidict.dict-type}/resources 42 touch sudachidict_${sudachidict.dict-type}/__init__.py 43 ''; 44}