Making a single addon release that can target multiple Blender versions?

Hi

I build a py lib that contains higher level functions that target multiple versions of the same fucntionalities in 2.79 and 2.80. So I just call the corresponding higher level function instead of the Api call in my addons (like setActiveObject in the actual addon). The corresponging call is decided by the lib based on bpy.app.version

Now this works for functions but I cant integrate it well in a script because the main issue is bl_info. Created 2 bl_infos that are under 2 if statements basically at the top, since I need to run couple commands just before the bl_infos to make which one to register, this does not seem to work well.

So my question is this. Does the bl_info dict has to be at the top of the init.py ? if so what are the work arounds so that I stop making 2 different addon scripts. My compability lib works fine I just need to make sure this bl_info works so that the addon registers properly.

It is just that maintaining two different addons is not fun, while they are %99 of the same code lines.

thanks

Blender uses the ast module to parse bl_info before other statements in the scripts are even evaluated, so dynamically changing the dictionary probably won’t work. The only workaround I’ve cared to look for is to leave the bl_info with version (2, 80, 0) at the very top, then adding this line at the top of register():

bl_info['blender'] = getattr(bpy.app, "version")

2.79 will still load 2.80 scripts, at least for me. And this bit circumvents the version warning in 2.79. You’d still have to ensure that the module(s) account for the API differences.

1 Like

Hey thanks for the tip, I will try this.