Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Conversation

iLLiCiTiT
Copy link
Member

Issue

Blender can have set only one BLENDER_USER_SCRIPTS which is already occupied by OpenPype implementation.

Changes

  • blender install method also register plugins/scripts/addons from OPENPYPE_BLENDER_USER_SCRIPTS
  • advantage is that it should be possible to register multiple paths

Warning

  • this implementation is using "copy" of inner blender python module function so it may change over time
  • tested only on Windows with my custom plugin (didn't find other plugin that would use BLENDER_USER_PATH)
  • implemented only OpenPype 3 variant

Note

  • OPENPYPE_BLENDER_USER_SCRIPTS was added with PR

Closes: #1050

@iLLiCiTiT iLLiCiTiT self-assigned this May 19, 2021

try:
return importlib.reload(mod)
except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.
do not use bare 'except'

if unregister:
try:
unregister()
except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.
do not use bare 'except'

if register:
try:
register()
except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.
do not use bare 'except'

@iLLiCiTiT iLLiCiTiT requested a review from a team May 19, 2021 08:55
@iLLiCiTiT iLLiCiTiT added backend type: bug Something isn't working type: enhancement Enhancements to existing functionality labels May 19, 2021
@mkolar
Copy link
Member

mkolar commented May 19, 2021

@simonebarbieri could you please have a look if this works for you and give review?

import addon_utils


def load_scripts(paths):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'load_scripts' is too complex (31)

@iLLiCiTiT
Copy link
Member Author

Fixed addons set through the BLENDER_USER_SCRIPTS environment.

@mkolar mkolar merged commit 1373d7f into develop May 21, 2021
@mkolar mkolar deleted the bugfix/1050-blender-cannot-initialize-avalon-if-blender_user_scripts-is-already-used branch May 21, 2021 09:01
@mkolar mkolar added this to the 3.0.0-rc.6 milestone May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working type: enhancement Enhancements to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blender: cannot initialize Avalon if BLENDER_USER_SCRIPTS is already used
3 participants