Unverified Commit 6298ea9c authored by Martin Weinelt's avatar Martin Weinelt
Browse files

python311Packages.flit-gettext: init at 1.0.0

parent 4daac647
Loading
Loading
Loading
Loading
+79 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  substituteAll,

  # build-system
  flit-scm,
  wheel,

  # dependencies
  flit-core,
  gettext,

  # tests
  build,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "flit-gettext";
  version = "1.0.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "codingjoe";
    repo = "flit-gettext";
    rev = version;
    hash = "sha256-YsRfpciSrHmivEJKfzdp6UaPx2tSr3VdjU4ZIbYQX6c=";
  };

  patches = [
    (substituteAll {
      src = ./msgfmt-path.patch;
      msgfmt = lib.getExe' gettext "msgfmt";
    })
  ];

  postPatch = ''
    sed -i "s/--cov//" pyproject.toml
  '';

  nativeBuildInputs = [
    flit-scm
    wheel
  ];

  propagatedBuildInputs = [ flit-core ];

  optional-dependencies = {
    scm = [ flit-scm ];
  };

  nativeCheckInputs = [
    build
    pytestCheckHook
    wheel
  ] ++ optional-dependencies.scm;

  disabledTests = [
    # tests for missing msgfmt, but we always provide it
    "test_compile_gettext_translations__no_gettext"
  ];

  disabledTestPaths = [
    # calls python -m build, but can't find build
    "tests/test_core.py"
    "tests/test_scm.py"
  ];

  pythonImportsCheck = [ "flit_gettext" ];

  meta = with lib; {
    description = "Compiling gettext i18n messages during project bundling";
    homepage = "https://github.com/codingjoe/flit-gettext";
    license = licenses.bsd2;
    maintainers = with maintainers; [ hexa ];
  };
}
+13 −0
Original line number Diff line number Diff line
diff --git a/flit_gettext/utils.py b/flit_gettext/utils.py
index dd1b135..1c8877c 100644
--- a/flit_gettext/utils.py
+++ b/flit_gettext/utils.py
@@ -7,7 +7,7 @@ def compile_gettext_translations(config):
     """Compile gettext translations."""
     print("\33[1m* Compiling gettext translations...\33[0m")
 
-    msgfmt = shutil.which("msgfmt")
+    msgfmt = shutil.which("msgfmt") or "@msgfmt@"
 
     if msgfmt is None:
         raise OSError("msgfmt not found, please install gettext or check your PATH.")
+2 −0
Original line number Diff line number Diff line
@@ -4471,6 +4471,8 @@ self: super: with self; {
  flit-core = callPackage ../development/python-modules/flit-core { };
  flit-gettext = callPackage ../development/python-modules/flit-gettext { };
  flit-scm = callPackage ../development/python-modules/flit-scm { };
  floret = callPackage ../development/python-modules/floret { };