Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing plugins directory on linux OS #8

Open
solumath opened this issue Oct 15, 2023 · 2 comments
Open

Missing plugins directory on linux OS #8

solumath opened this issue Oct 15, 2023 · 2 comments

Comments

@solumath
Copy link

I tried installing the Textension addon on ubuntu 22.04
Blender version 3.6.4 run from source

I notice that you are using os.path.join() which is incompatible with Linux directory paths which then raises error that there is no plugins directory.

I would suggest using pathlib which can handle both linux and windows directories. Because it's used everywhere in your code it's unusable on linux and throws multiple error paths. I would really appreciate compatibility with linux path system.

My suggestion for the get plugins would be:

def get_plugins_dict() -> dict:
    """Return a list of plugin submodules that can be enabled."""
    plugins_path = Path(textension.__path__[0]) / 'plugins'  # Use Path to handle file paths

    if not plugins_path.is_dir():
        print("Textension: missing 'plugins' directory.")
        return
    plugins = {}
    py_path = f"{__package__}.plugins"
    for info in pkgutil.iter_modules([str(plugins_path)]):  # Convert Path to string
        m = __import__(f"{py_path}.{info.name}", fromlist=(info.name,))
        if hasattr(m, "enable") and hasattr(m, "disable"):
            plugins[info.name] = m
    return plugins

Error that initiated this bug hunt.

Read prefs: "/home/solumath/.config/blender/3.6/config/userpref.blend"
Textension: missing 'plugins' directory.
Traceback (most recent call last):
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/utils.py", line 358, in wrapper
    ret = func(*args, **kw)
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/__init__.py", line 33, in register
    prefs.init()
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/prefs.py", line 13, in init
    _init_plugins()
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/prefs.py", line 58, in _init_plugins
    for name, module in plugins_dict.items():
AttributeError: 'NoneType' object has no attribute 'items'
Exception in module register(): /home/solumath/.config/blender/3.6/scripts/addons/textension/__init__.py
Traceback (most recent call last):
  File "/home/solumath/FIT2/BP/blender-3.6.4-linux-x64/3.6/scripts/modules/addon_utils.py", line 369, in enable
    mod.register()
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/utils.py", line 358, in wrapper
    ret = func(*args, **kw)
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/__init__.py", line 33, in register
    prefs.init()
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/prefs.py", line 13, in init
    _init_plugins()
  File "/home/solumath/.config/blender/3.6/scripts/addons/textension/prefs.py", line 58, in _init_plugins
    for name, module in plugins_dict.items():
AttributeError: 'NoneType' object has no attribute 'items'
@K-410
Copy link
Owner

K-410 commented Oct 15, 2023

Appreciate the code!
I do indeed use a lot of os.path. For performance reasons, Path objects are not ideal to use everywhere in the addon, but I'll get a copy of ubuntu and work my way through things.

@solumath
Copy link
Author

solumath commented Oct 15, 2023

then I would say try to remove "\" in code? just os.path.join(a, b)
Thank you anyway for your quick reesponse!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants