Closed PeterMocary closed 3 months ago
This seems to be a problem with Meson build system. The editable version creates a MetaPathFinder
in the file _editable.py. This finder implements the previously mentioned find_spec
function and creates invalid path (see above in the make dev
example) to the submodule_search_locations
field. From the submodule_search_locations
definition there should be a path present where the submodules of a package are found and thus, this seems to be a bug in the Meson build system. However, I might be missing something due to my limited understanding of Meson.
Proposed fix:
PackageLoader
that would find the correct directory.origin
field instead of submodule_search_locations
which contains path to the package loader. This would be a very simple adaptation of the original PackageLoader
.Yeah, this is currently p***ing me off as well, as suddenly it manifested in my environment. I'm wondering how we could approach it. What is the best or least resistance.
Is there some alternative of using PackageLoader?
Seems that we could use "FileLoader" with absolute/relative paths that could solve our problem, I will try to look into this soon, as it annoys me now. @JiriPavela what do you think? Should we somehow try to fix the PackageLoader or go for FileLoader (this might introduce some other issues though).
Reading the documentation for the FileSystemLoader again, I might have dissregarded it previously due to the following: "Load templates from a directory in the file system. The path can be relative or absolute. Relative paths are relative to the current working directory."
This means that the developer cannot simply pass a relative path to the templates from the directory where the loader is called. Instead, the path will be interpreted relative to the current working directory from which the tool is executed. Therefore, it requires finding the absolute path to the template before passing it to the FileSystemLoader
.
This is why I suggested the "adjustment" of the PackageLoader
instead.
This should not pose a problem, we can easily extract the path wrt install directory. I am not 100% confident, but we are already using some of this magic elsewhere (to run scripts). So I could try to make it work. EDIT: If it is more complex, then we could use the custom PackageLoader, still good analysis of the problem from your part.
When loading a Jinja2 template the
PackageLoader
is used to locate the templates within the package. When is the perun package installed usingmake dev
thePackageLoader
fails and resutlts in a crash.The
PackageLoader
is used in view_diff, ktrace, and in the PIN engine, therefore this should be investigated further to ensure stable development enviroment.Triggered on PIN engine when generating a pintool from templates:
Note: The
[...]
is truncated path (e.g./home/user/projects
).The
ValueError
is triggered from the jinja2/loaders.py where one can see that import spec is used to extract submodule search locations. If we compare the value ofsubmodule_search_locations
in environment initialized withmake install
and another withmake dev
we see that the editable version frommake dev
environment contains path that is not existing.Environment initialized with
make dev
reporting invalid path insubmodule_search_locations
:Environment initialized with
make install
:This could be a problem with the build system since @JiriPavela pointed out that the behaviour with editable environment is not deterministic (however for me it happened every time so far).