Difficulties with building debian package 5.2

i am trying to build debian package 5.2 from git sources.
step 1 : obtains sources

git clone https://github.com/gramps-project/gramps.git -b maintenance/gramps52
cd gramps

step 2 : build package

# build source distribution
python3 setup.py sdist
# extract sources from source distribution
cd dist
tar zxf gramps-5.2.0rc1.tar.gz
# rename source distribution to what expect debuild
mv gramps-5.2.0rc1.tar.gz gramps_5.2.0.orig.tar.gz
# run debuild
cd gramps-5.2.0rc1
export LANG=C

First Try : debuild looks for 5.1.5 sources instead of 5.2
So i update debian/changelog with dch -v 5.2.0-rc1 -M ; dch -r -M

diff --git a/debian/changelog b/debian/changelog
index 5a901c55e..010d3af70 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+gramps (5.2.0-rc1) unstable; urgency=medium
+  * New release.
+ -- Ross Gammon <rossgammon@debian.org>  Mon, 30 Oct 2023 02:53:42 +0100
 gramps (5.1.5-1) unstable; urgency=medium
   * New release

Second try : tests fails with : error «ResourcePath.ERROR: Unable to determine resource path»
So, i modify gramps/gen/utils/resourcepath.py to test if gramps is installed by testing data directory instead of .git, which don’t exists in source distribution :

index b4f0056d1..e6f48fcc9 100644
--- a/gramps/gen/utils/resourcepath.py
+++ b/gramps/gen/utils/resourcepath.py
@@ -74,7 +74,7 @@ class ResourcePath:
         package_path = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..")
-        installed = not os.path.exists(os.path.join(package_path, ".git"))
+        installed = not os.path.exists(os.path.join(package_path, "data"))
         if installed:
             test_path = os.path.join("gramps", "authors.xml")

Third try : fails on : File “/home/jean/src/gramps/dist/gramps-5.2.0rc1/gramps/gen/utils/test/file_test.py”, line 73, in test_mediapath
Don’t know why this test fails, nor why it should succeed, so i comment it :

diff --git a/gramps/gen/utils/test/file_test.py b/gramps/gen/utils/test/file_test.py
index 7b7d55b54..8bff4e445 100644
--- a/gramps/gen/utils/test/file_test.py
+++ b/gramps/gen/utils/test/file_test.py
@@ -70,7 +70,7 @@ class FileTest(unittest.TestCase):
-            self.assertTrue(os.path.exists(media_path(db)))
+            # self.assertTrue(os.path.exists(media_path(db)))
             # Test with absolute db.mediapath
             db.set_mediapath(os.path.abspath(USER_HOME) + "/test_abs")

Fourth try : fails in dh_auto_install «error: option --resourcepath not recognized»
It appears that option --resourcepath has been removed from setup.py, so :

diff --git a/debian/rules b/debian/rules
index 8f98d1fd0..1c18d4de8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,7 +4,6 @@
 #export DH_VERBOSE=1
 #export DH_OPTIONS=-v
 export PYBUILD_NAME=gramps
-export PYBUILD_INSTALL_ARGS_python3=--resourcepath=/usr/share --force
        dh $@ --with python3 --buildsystem=pybuild

Fifth try : success :slight_smile:

So i have a debian package, but are all my patches correct ?
Especially the patch on gramps/gen/utils/test/file_test.py ?

I had the same problem with LMDE 6, which is based on debian 12 (bookworm). Building 5.1 was impossible, and building 5.2 worked, but the install led to the same resource problem as you reported here.

I never had problems on LMDE 5 (debian 11), but I must add that I never tried to installl 5.2 on that.

Have you tried to contact Ross Gammon about this?

In v5.2, the resource path is detected automatically. As long as one of the three main installation schemes is used, the resource path can be derived from the package path.

Changes to the ResourcePath class and the unit tests shouldn’t be necessary. They indicate a problem with the installation.

But when debuild run the tests, gramps is not installed and sources are not issued from git, so “.git” doesn’t exists, and the line :

       installed = not os.path.exists(os.path.join(package_path, ".git"))

detects incorrectly that gramps is installed.

My change “.git” → “data” is not very selective. Something better could be :

       installed = not os.path.exists(os.path.join(package_path, "data/grampsxml.dtd"))

I just noticed that I misread the title, because it was about a package, and not a regular install. And I did a new test on Linux Mint 21.2, which is based on ubuntu 22.04.

And on that, the install from source seems to work, just like it seems to work on LMDE 6 (debian 12), but Gramps does detect a resource path problem, so the 5.2 installation is bad/incomplete on all platforms that I tried it on, meaning ubuntu 22.04 and debian 12.

Packagers are still free to set the GRAMPS_RESOURCES environment variable if the automatic detection doesn’t work.

What installation scheme are you using? Where did Gramps expect the resource files?

I simply use the instructions from the INSTALL file:

python3 setup.py build
sudo python3 setup.py install

And I only run the install after verifying that ‘python3 Gramps.py’ works as expected.

And to tell you the truth, I don’t know where Gramps expected the resource files, because I have never found a reason to look for them. And last time I looked at the wiki, I only found an example for a non standard setup, and nothing about where the resources should be after a standard install. That is because there is no simple description of what the resources actually are.

With a bit of guesswork, I figured out that I could start gramps with the GRAMPS_RESOURCES variable set to something similar to


which is the standard location for 5.1 on Linux Mint 21.2. I can’t give the real location, but it is something where gramps is replaced by a name with a version number in it. Trying to reproduce this on my production PC messes up my 5.1 installation, so I won’t run the install here tonight.

Anyway, last time I figured out the proper resource path, the next problam was that it couldn’t find the locale files, so it switched back to English. And on closer inspection, it showed that the 5.2 .mo files were not installed.

Since this install is quite destructive, I’m not going to try it tonight anymore, at 1 AM.

I just installed good old LMDE 5, based on debian 11, on another partition, and on that, setup.py install also created a Gramps 5.2 that can’t find its only resources. And trying to correct that by installing 5.1 in the same way does not cure the problem, even though Gramps 5.1 can be installed on that Linux Mint in the regular way, on a clean system.

In this case, I ran timeshift before trying the 5.2 install, so it juist took me a few minutes to get back on track, but that does not change my experience that the 5.2 install is quite destructive, and I assume that this may be related to the changes made to setup.py to make it work with setuptools, which are the only tools available on LMDE 6 and debian 12. Mint 21.2 has distutils and setuptools, so that is more flexible at the moment.

I have to go now, but when I come back, I like to check whether the install works with an older version of setup.py. And another thing that I like to try is to run setup.py install with another prefix, so that the install itself is not destructive.

Do we have documentation about this on the wiki?

I have same results here (debian bookworm)
It seems that with setuptools, installation with

python3 setup.py build
sudo python3 setup.py install

results in a new tree:
gramps is installed in /usr/local/lib/python3.11/dist-packages/gramps-5.2.0rc1-py3.11.egg
grampsapp.py is in /usr/local/lib/python3.11/dist-packages/gramps-5.2.0rc1-py3.11.egg/gramps
authors.xml is in /usr/local/lib/python3.11/dist-packages/gramps-5.2.0rc1-py3.11.egg/share/gramps

I can run gramps in this situation with this patch :

diff --git a/gramps/gen/utils/resourcepath.py b/gramps/gen/utils/resourcepath.py
index b4f0056d1..861407a14 100644
--- a/gramps/gen/utils/resourcepath.py
+++ b/gramps/gen/utils/resourcepath.py
@@ -74,7 +74,7 @@ class ResourcePath:
         package_path = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..")
-        installed = not os.path.exists(os.path.join(package_path, ".git"))
+        installed = not os.path.exists(os.path.join(package_path, "data"))
         if installed:
             test_path = os.path.join("gramps", "authors.xml")
@@ -96,6 +96,9 @@ class ResourcePath:
             elif tail == "python":
                 # Home installation scheme
                 base_path, tail = os.path.split(head)
+            elif tail.startswith("gramps-") and tail.endswith(".egg"):
+                # egg installation scheme
+                base_path = package_path
             if base_path is not None:
                 resource_path = os.path.join(base_path, "share")

H’m, that looks like a nice hack for the moment, but I prefer to get rid of this whole egg thing, because it’s redundant. The installation stores the files under the right Python version already, so it should be enough for that path to end at rc1, so that it can be distinguished from the final version, whatever that one is called.

And in the mean time I found that specifying a separate root for the install with the --root parameter is a nice way to prevent mess-ups.

The --root option is what the package maintainers use when they package Gramps. It should also be possible to use the --user, --home or --prefix schemes. See the legacy documentation for further details.

1 Like