nangtani / blender-addon-tester

The blender addon tester is a test harness to enable pytest hook to allow addons to be tested inside a defined version of blender.
MIT License
64 stars 13 forks source link

Changing addon install directory does not work #26

Open douglaskastle opened 4 years ago

douglaskastle commented 4 years ago

A feature was added to change the location of the addon installation.

bpy.context.user_preferences.filepaths.script_directory = addon_dir

turns out this value does not take effect until there is a restart. I can not find a command to restart blender, so while this value does change successfully, it no effect on testing.

https://docs.blender.org/api/current/bpy.types.PreferencesFilePaths.html#bpy.types.PreferencesFilePaths.script_directory

FrankFirsching commented 3 years ago

It's not needed to set the script directory in the preferences while running blender. It's possible to set the environment variable BLENDER_USER_SCRIPTS before starting blender. I do this in the script, that's firing up blender-addon-tester and it works fine, although it would be nice, if blender-addon-tester would take care of this.

douglaskastle commented 3 years ago

I think i have figured out what was wrong, when you are installing you need to define the target, if you don't it just uses the default, use target='PREFS':

bpy.ops.preferences.addon_install(overwrite=True, filepath=zfile.as_posix())

versus:

bpy.ops.preferences.addon_install(overwrite=True, target='PREFS', filepath=zfile.as_posix())