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: https://gitlab.gnome.org/World/PasswordSafe/blob/master/meson.build#L36

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 https://github.com/mesonbuild/meson/issues/3551, the modules need to be checked by importing. For an example see https://gitlab.gnome.org/GNOME/gtk-doc/blob/b84b964327019b946534a4cd7838b591c1f69a60/meson.build#L42-50

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 https://github.com/mesonbuild/meson/issues/3551

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

Potentially interesting for this project is mesonpep517 which I am packaging and testing now.


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: https://gitlab.gnome.org/diamondburned/PasswordSafe/tree/pydep-fix

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: https://gitlab.gnome.org/World/PasswordSafe/merge_requests/70