Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting bqt env variables before executing register( ) #123

Open
martin-dgg opened this issue Aug 29, 2024 · 2 comments
Open

Setting bqt env variables before executing register( ) #123

martin-dgg opened this issue Aug 29, 2024 · 2 comments

Comments

@martin-dgg
Copy link

martin-dgg commented Aug 29, 2024

We are using bqt as a dependency of a custom addon we created. For this addon we need disable wrapping of blender using the env variable "BQT_DISABLE_WRAP".

Here we are facing the following problem:

We want to set this variable temporarily, while blender is open, using os.environ["BQT_DISABLE_WRAP"] = "1" in the register() function of our own Plugin. However since the Plugin needs bqt to be registered first, bqt can not take the env. var. into account.

Is there a way for us to set the environment variable before bqt is registered?

We have tried to enable the bqt addon in the register function of our own addon but this also did not work due to a _RestrictContext problem on blender side.
It appears to be impossible to access the correct context before all addons are loaded in.

So what we would need to have is something like this:

  1. Start blender
  2. Set disable_wrap using: os.environ["BQT_DISABLE_WRAP"] = "1"
  3. enable bqt
  4. enable our addon
@hannesdelbeke
Copy link
Collaborator

Since blender doesn't allow you to control the order plugins are loaded in on startup, i don't see an easy way how to do this after you started blender but before bqt loads.

what you could consider is

method 1

  • enable your plugin, it checks if bqt is enabled.
  • if bqt enabled, disable the bqt plugin, and ask the user to restart blender
  • now on startup your plugin loads. then after loading it can load the bqt plugin without saving the loaded plugins.

this would work as long as the user doesnt enable/disable any other plugins.

method 2

a cleaner solution is to create a "launcher" for the user that starts blender with modified environment variables.
this could be a little script, or a shortcut that modifies the ENV vars. and then launches blender.

other

i was looking at disabling wrap, since it is not as stable as i'd like it too be.
wrap was the original solution but since then i have been rewritting bqt to move away from wrap.
if the non wrap solution is stable enough, that will become the default behaviour of bqt. but i can't promise a timeline for that.

@hannesdelbeke
Copy link
Collaborator

tbh the easiest thing for now would be to clarify this as a warning on your tool in blender, if bqt is enabled in wrap mode.
inform the user they need to set this env var and restart blender.
and provide documentation on how to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants