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

Consider removing call to Init in __init__ #200

Open
colinxs opened this issue Apr 8, 2020 · 3 comments
Open

Consider removing call to Init in __init__ #200

colinxs opened this issue Apr 8, 2020 · 3 comments

Comments

@colinxs
Copy link

colinxs commented Apr 8, 2020

While it's useful to have this happen automatically, it also makes it difficult to use GLFW in a package that is running on a headless machine and only uses GLFW for a small part of it's functionality. Given that it's just a single call to Init(), would you consider removing it from __init__?

@Gnimuc
Copy link
Contributor

Gnimuc commented Apr 9, 2020

I guess you could always set the environment variable DISPLAY=:0 to prune GLFW errors on a headless machine.

@jayschwa
Copy link
Member

Removing Init in __init__ would be a breaking change from a semantic versioning perspective, and I'm reluctant to do that (right now). However, I don't want to totally dismiss this issue either. Some ideas:

  • Apps and packages could avoid importing GLFW.jl for their code paths that do not use it.
  • GLFW.jl could avoid calling Init in __init__ if it detects the presence of some global symbol or environment variable.
  • GLFW.jl could remove the call to Init in __init__, but automatically call Init the first time some other function is executed, thereby preserving compatibility with existing apps or packages that will not call Init themselves.

@musm
Copy link
Contributor

musm commented Aug 12, 2020

Option 3 seems quite sensible. We do something similar in MATLAB.jl with regards to initialization, whereby we only initialize code after an appropriate constructor is called for the first time.

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

No branches or pull requests

4 participants