Trouble building passwordsafe: a meson-python-gtk3 package

Hello,

I’m trying to build this package, but I got a python module not found:

Found pkg-config: /nix/store/0bkzr1nxk03c2sp8yym9lw3ay8ixgf2n-pkg-config-0.29.2/bin/pkg-config (0.29.2)
Run-time dependency glib-2.0 found: YES 2.62.0
Run-time dependency gobject-introspection-1.0 found: YES 1.62.0
Run-time dependency gtk+-3.0 found: YES 3.24.10
Run-time dependency libhandy-0.0 found: YES 0.0.11
Run-time dependency pwquality found: YES 1.4.1

meson.build:35:4: ERROR: Problem encountered: Missing dependency pykeepass >= master

A full log can be found at /build/PasswordSafe-f229d4c/build/meson-logs/meson-log.txt
builder for '/nix/store/943x0nlbjgy00lyn0kcqk3v20q10s6ih-passwordsafe-3.32.0.drv' failed with exit code 1
error: build of '/nix/store/943x0nlbjgy00lyn0kcqk3v20q10s6ih-passwordsafe-3.32.0.drv' failed

Here’s the default.nix of mine:

{
	stdenv, fetchgit, makeWrapper, wrapGAppsHook,
	libhandy, libpwquality, python3Packages, gnome3,
	meson, pkgconfig, cmake, gobject-introspection,
}:

python3Packages.buildPythonApplication rec {
	pname = "passwordsafe";
	version = "3.32.0";

	name = "${pname}-${version}";

	src = fetchgit {
		url = "https://gitlab.gnome.org/World/PasswordSafe.git";
		rev = "f229d4c45546bcd85934659c206c2340531af9d1";
		sha256 = "0i612vcspykhfyw95p2fpbannzvavq4rrdfghnisrjrch4xayksf";
	};

	buildInputs = [
		libhandy
		libpwquality
		gnome3.gtk3
		gnome3.glib
		gobject-introspection
	];

	propagatedBuildInputs = with python3Packages; [
		pykeepass
		pygobject3
		libkeepass
	];

	nativeBuildInputs = [
		wrapGAppsHook
		meson
		pkgconfig
		cmake
	];

	dontWrapGApps = true;
	makeWrapperArgs = [ "\${gappsWrapperArgs[@]}" ];

	meta = with stdenv.lib; {
		description = "Password manager for GNOME which makes use of the KeePass v.4 format";
		homepage = https://gitlab.gnome.org/World/PasswordSafe;
		license = licenses.gpl3;
		platforms = platforms.linux;
	};
}

I don’t know anything about this stuff but it looks like it’s coming quite directly from meson.build: meson.build · master · World / Secrets · GitLab

I gotta say, that’s a weird looking error message for what the code seems to say…

Indeed, the project is incorrectly assuming that all python packages are installed to the same directory, which is not always the case – PYTHONPATH environment variable can be used.

Until meson implements Add a way to check for the presence of a Python module · Issue #3551 · mesonbuild/meson · GitHub, the modules need to be checked by importing. For an example see meson.build · b84b964327019b946534a4cd7838b591c1f69a60 · GNOME / gtk-doc · GitLab

I recommend opening an issue/MR upstream and patching the expression for now.

1 Like

:smile: I’ve actually done this for a similar application lollypop

And doesn’t the python module in meson support a modules check?

Perhaps I confused that for something else.

1 Like

~~Not at the moment, unfortunately. See Issues · mesonbuild/meson · GitHub

Oh, I completely forgot about that. That might be better.

Potentially interesting for this project is mesonpep517 which I am packaging and testing now.
https://github.com/NixOS/nixpkgs/pull/72784
It basically offers Meson as a PEP 517 compliant build backend to build a wheel, which is then used as usual.

1 Like

I’ve forked the branch for a future PR that patches that issue now: Files · pydep-fix · diamondburned / Password Safe · GitLab

That said, I have stumbled upon yet another issue:

Message: Compiling resources
Configuring about_dialog.ui using configuration
Found pkg-config: /nix/store/0bkzr1nxk03c2sp8yym9lw3ay8ixgf2n-pkg-config-0.29.2/bin/pkg-config (0.29.2)
Traceback (most recent call last):
  File "/nix/store/cyhaixglvnbny117lbsw66wjm1c3a0aa-meson-0.51.2/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 127, in run
    return options.run_func(options)
...
FileNotFoundError: [Errno 2] No such file or directory: 'glib-compile-resources': 'glib-compile-resources'

glib-compile-resources is provided by glib package.

glib is already in the list of dependencies

Since it is called at build time, it also needs to be in nativeBuildInputs. Python packages pass strictDeps = true to mkDerivation by default, so they separate runtime and build time dependencies.

1 Like

Thanks! That made it built. Another issue though: it’s complaining about a missing pwquality

Traceback (most recent call last):
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/bin/..gnome-passwordsafe-wrapped-wrapped", line 18, in <module>
    from passwordsafe.application import Application
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/application.py", line 7, in <module>
    from passwordsafe.main_window import MainWindow
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/main_window.py", line 5, in <module>
    from passwordsafe.create_database import CreateDatabase
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/create_database.py", line 2, in <module>
    from passwordsafe.created_database import CreatedDatabase
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/created_database.py", line 2, in <module>
    from passwordsafe.unlock_database import UnlockDatabase
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/unlock_database.py", line 3, in <module>
    from passwordsafe.unlocked_database import UnlockedDatabase
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/unlocked_database.py", line 4, in <module>
    from passwordsafe.database_settings_dialog import DatabaseSettingsDialog
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/database_settings_dialog.py", line 7, in <module>
    import passwordsafe.password_generator
  File "/nix/store/al09bl02j7ynr363g4j0mxw5znr12jpm-passwordsafe-3.32.1/lib/python3.7/site-packages/passwordsafe/password_generator.py", line 3, in <module>
    import pwquality
ModuleNotFoundError: No module named 'pwquality'

I couldn’t find any pwquality Python package in NixOS either.

Updated default.nix:

{
	stdenv, fetchgit, makeWrapper, wrapGAppsHook,
	libhandy, libpwquality, python3Packages, gtk3, glib,
	meson, ninja, pkgconfig, cmake, gobject-introspection,
}:

python3Packages.buildPythonApplication rec {
	pname = "passwordsafe";
	version = "3.32.1";

	format = "other";

	name = "${pname}-${version}";

	src = fetchgit {
		url = "https://gitlab.gnome.org/diamondburned/PasswordSafe.git";
		rev = "5ab72a2a48f45c41d7a1cca2dab9634ea36198f0";
		sha256 = "1i458p51wby00sjjfv9838b3hmgwzlbyvwqkxhzlsj7kzxr57c80";
	};

	buildInputs = [
		libhandy
		libpwquality
		gtk3
		glib
		gobject-introspection
	];

	propagatedBuildInputs = with python3Packages; [
		pykeepass
		pygobject3
		libkeepass
		pwquality
	];

	nativeBuildInputs = buildInputs ++ [
		wrapGAppsHook
		meson
		ninja
		pkgconfig
		cmake
	];

	meta = with stdenv.lib; {
		description = "Password manager for GNOME which makes use of the KeePass v.4 format";
		homepage = https://gitlab.gnome.org/World/PasswordSafe;
		license = licenses.gpl3;
		platforms = platforms.linux;
	};
}

Fixed it!

	buildInputs = [
		gtk3
		glib
		gobject-introspection
	];

	propagatedBuildInputs = [
		libhandy
		(libpwquality.override {
			python = python3;
		})

	] ++ (with python3.pkgs; [
		pykeepass
		pygobject3
		libkeepass
	]);

PR created: Improve meson check for Python modules (!70) · Merge requests · World / Secrets · GitLab

1 Like

Oh I would like to use this program on NixOS, is there any package or NUR package I could use?

For testing purpose I continued this package in my NUR repository. You can try the package nur.repos.onny.passwordsafe if you want :slight_smile: I’ve packaged version 3.99.2. Still not sure which features might be missing or bugs still present.

looks like libpwquality should have a related python package

1 Like

I have this working on my desktop with my database from keepass, I submitted a Nixpkgs PR https://github.com/NixOS/nixpkgs/pull/98044

1 Like