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

use startup.py instead of --code option #1

Open
haubourg opened this issue Jul 1, 2021 · 4 comments
Open

use startup.py instead of --code option #1

haubourg opened this issue Jul 1, 2021 · 4 comments

Comments

@haubourg
Copy link
Owner

haubourg commented Jul 1, 2021

This is much leaner and the way the documentation recommends it.

Let's dig why it didn't work at start in my setup :)

@nicogodet
Copy link

I need to confirm on my test machine but qgis_constrained_settings.py should looks like :

-if __name__ == "__main__":
+if __name__ == "startup": 
   main()

https://github.com/qgis/QGIS/blob/23036461dd23846b1e820114a83588ba5c269373/src/python/qgspythonutilsimpl.cpp#L206-L208

I ran these 3 lines in QGIS python console and I add print(__name__) before main() definition.

> spec = importlib.util.spec_from_file_location('startup','C:/Users/Nicolas Godet/AppData/Roaming/QGIS/QGIS3/startup.py')
> module = importlib.util.module_from_spec(spec)
> spec.loader.exec_module(module)
startup

So main() was never called...

@haubourg
Copy link
Owner Author

@nicogodet thanks for raising this. I have no windows machine to test this by now but this makes sense. Tell me when you confirm this on your test machine. Any PR welcome :)

@nicogodet
Copy link

@haubourg I confirm it should be as described in my previous message. I will prepare a PR.

@nicogodet
Copy link

See e4650cd

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