How to support Linux?

I am currently adding some features to an addon I made a while back: https://github.com/Zyl9393/mouse_strafing

One of the things I would like to have working is Linux support. When importing the .zip file with the addon files on Windows (through the “Install” button on the Add-ons page in Blender Preferences) the addon loads and works fine. When doing the same on Linux, I get this error:

Traceback (most recent call last):
  File "/home/me/blender-2.91.0-linux64/2.91/scripts/modules/addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "/home/me/.config/blender/2.91/scripts/addons/mouse_strafing\__init__.py", line 27, in <module>
    from . import mouse_strafing
ImportError: attempted relative import with no known parent package

I have looked at how other Blender Add-ons have their import statements, and see no striking differences. What do I need to change to get it working?

2 Likes

I don’t know how to code but maybe giving a like will make you more noticeable.

Hello Zyl

I checked your addon and the code did not seem to have any glaring problems which made this bit harder determine the problem.

I downloaded the addon zip and trying to extract that revealed following files:

mouse_strafing\prefs.py
mouse_strafing\mouse_strafing.py
mouse_strafing\__init__.py

The ZIP package does not contain subfolders at all and this is the problem.

I extracted the files, named them and zipped again with proper subfolder and it should work: mouse_strafing.zip (6.8 KB)

That’s strange. When I open the original and your .zip file in WinRAR, they look the same, with a single folder mouse_strafing at the root. When I open them on Linux (using Ark), only your file shows the root folder. For mine, the files are displayed as if they were in root. How did you create that archive? And what’s going on?

EDIT: Looking more closely, it seems that Linux ignores Windows path separators (\), but Windows respects Linux path separators (/). I wasn’t aware .zip file format is this garbage. It seems Microsoft have added workaround in favor of Linux: https://github.com/PowerShell/Microsoft.PowerShell.Archive/pull/62 but I can’t figure out how to update. I’ll look into writing a Go program to create correct archive.

I used just the basic “Compress…” feature which uses the basic system zip libraries under the hood.

I expected file case sensitivity issues here but it’s the first time I’ve seen anything like in your package happening. I wonder which software you used to create that package?

EDIT: this is definetly not normal and usually zip files created with 7zip, winzip, winrar etc do not act like this.

I just made https://github.com/Zyl9393/justzip which fixes the issue.