Building addons make.py error "ModuleNotFoundError: No module named 'gramps'"

System: Ubuntu 22.04.4 LTS running on WSL on Windows 10 with a successful build of Gramps 5.2.0 from source. However, this is the first time I’m building addons (gramps52 branch) and running into an error with the ‘init’ command to make.py:

~/dev/addons-source$ GRAMPSPATH=/home/codefarmer/dev/gramps LANGUAGE='en_US.UTF-8' python3 make.py gramps52 init AllNamesQuickview
make.py: LANGUAGE is en_US.UTF-8... good!
Traceback (most recent call last):
  File "/home/codefarmer/dev/addons-source/make.py", line 214, in <module>
    from gramps.gen.plug import make_environment, PTYPE_STR
ModuleNotFoundError: No module named 'gramps'

The error is on L214 of make.py which is accessing Gramps modules. I’ve set GRAMPSPATH to point to the root of the gramps source folder. What am I overlooking?

BTW, I get the same error in the MSYS development environment.

1 Like

This looks like a bug. I’ll investigate.

I only tend to use the build and listing options myself, but init, update and compile are also important.

1 Like

Thanks for your time on this, @Nick-Hall . Because it’s the first time I’m building addons I am not sure which of the available make commands are to be used, and in what order. I was simply going by intuition that init has to be the first step. Build command works without errors, although listing command fails and I wonder if it is because things aren’t initialized properly?

~/dev/addons-source$ GRAMPSPATH=/home/codefarmer/dev/gramps LANGUAGE='en_US.UTF-8' python3 make.py gramps52 listing AllNamesQuickview
make.py: LANGUAGE is en_US.UTF-8... good!
Building listing for 'lt'...
Traceback (most recent call last):
  File "/home/codefarmer/dev/addons-source/make.py", line 864, in <module>
    fp_out = open(r("../addons/%(gramps_version)s/listings/") +
FileNotFoundError: [Errno 2] No such file or directory: '../addons/gramps52/listings/addons-lt.json'
1 Like

OK, ignore the error on listing command - just needed to create the “listings” directory manually, i.e. ../addons/gramps52/listings.

1 Like

Actually, I think that there is a problem with the listing option when a single addon is specified.

There is also some tidying up required - black formatting and removing duplicate and redundant code.

2 Likes

I’ve fixed the init command. There wasn’t a problem with the listing command.

The workflow for translations is to first run init to create the pot file:

python make.py gramps52 init MyAddon

Then run init again with a language to create the corresponding po file:

python make.py gramps52 init MyAddon fr

Finally the po files can be compiled into mo files using:

python make.py gramps52 compile MyAddon

When changes are made to an addon, we run build to create the tgz file:

python make.py gramps52 build MyAddon

and then the listings can be updated using:

python make.py gramps52 listing all

Set your GRAMPSPATH environment variable to point to your Gramps source code.

I’ve never used any of the other commands myself. The as-needed looks useful. I’ll look at creating some functions to remove some of the duplicate code.

2 Likes

Thanks, @Nick-Hall . Your change resolved the error, and the workflow description is very helpful.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.