It turns out if you try and read a .blend file from a folder in the add-ons on the Mac, you get an error. I figured a way around this for our users, but is there possibly a better way? I know other add-on developers are having the same problem.
Here’s the video with the workaround. Any suggestions are welcome
I did some testing and digging and found this is rather a path construction issue.
So I was reading a bit through the code to see what is going on.
I see you’re using os.getcwd(), but at least on MacOS that is problematic. Running Blender from the launcher has that return /, so the path you construct is wrong.
With a terminal where you’re not in the homedirectory loading of the add-on also fails , since os.getcwd() will be wrong.
A better and more portable way would be to use some of the utility functions provided by Blender.
For my own import_3dm add-on I use bpy.utils.script_path_user(), which on the different machines translates to all the 2.81 folders you are interested in (getBasePath() in your sketch_style/__init__.py). On my Mac this gives /Users/nathan/Library/Application Support/Blender/2.81/scripts
I believe the following getBasePath() revision will work on all platforms you choose to support:
p = bpy.utils.script_path_user()
p = os.path.join(p, "addons", "sketch_style")
p += os.sep
For proper and cross-platform fiddling I suggest to use at minimum os.path.join and os.sep, but also do look into using the module pathlib where possible. Anyway, the os.path.join() together with os.sep should be used where-ever you are creating paths. There are quite a few spots in the add-on where you do set up paths. Revisit those and switch to using the suggestion.
The improved getBasePath() has your add-on work much better at least here on MacOS
I noticed that it seems that Black is now hosted on the python software foundation’s github project:
I’m inclined to think that this means that Black is intended to eventually occupy the same spot in the python ecosystem as gofmt does in the Go ecosystem. Time will tell I suppose.
In any case, Black is a strict pep8 formatter with configurable line-lengths. I arbitrarily set the line length to 100, which is presumably why Black formatted the piece of code you commented on like it did.