Skip to content

[BUG] can't import rules on editable meson installs #1636

@barentine

Description

@barentine

Describe the bug

Traceback

In [1]: from PYME.cluster.rules import LocalisationRule
using an old version of zeroconf (0.148.0), consider upgrading
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 from PYME.cluster.rules import LocalisationRule

File C:\Userfiles\andrew\code\python-microscopy\PYME\cluster\rules.py:118
    115             self._t_watch.start()
    117 import jinja2
--> 118 jenv = jinja2.Environment(loader=jinja2.PackageLoader('PYME.resources', 'web'))
    119 rg_template = jenv.get_template('rule_inline.html')
    120 class RuleGroupWatcher(object):

File ~\AppData\Local\miniforge3\envs\pipyme311\Lib\site-packages\jinja2\loaders.py:359, in PackageLoader.__init__(self, package_name, package_path, encoding)
    357             break
    358     else:
--> 359         raise ValueError(
    360             f"PackageLoader could not find a {package_path!r} directory"
    361             f" in the {package_name!r} package."
    362         )
    364 self._template_root = template_root

ValueError: PackageLoader could not find a 'web' directory in the 'PYME.resources' package.

It seems like the jinja2 PackageLoader does not work with meson editable installations (see here ), and like it won't work until jinja2 v3.2

I'm not immediately having luck swapping out the PackageLoader for FileSystemLoader.

To Reproduce
Steps to reproduce the behavior:

  1. install PYME for development via pip / meson
  2. from PYME.cluster.rules import LocalisationRule
  3. See error

Platform (please complete the following information - or copy-paste from error dialog if shown):

  • OS: [e.g. Win10] win11
  • Python version: 3.11
  • numpy version: 2.4.2
  • wxpython version [if a UI bug]: 4.2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions