-
Notifications
You must be signed in to change notification settings - Fork 124
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
How to detect code is running from a Pynsist installation #207
Comments
There's no specific way to check this. It's meant to be not such a weird
configuration as freezing an application, so it shouldn't need special
casing in the same way.
What specific behaviour do you want to achieve? I'd suggest that it's
better to focus on specific conditions - e.g. is the directory this module
is in writable - rather than labeled situations.
There's an analogy here with frontend web development. It's really tempting
to check for specific browsers, but it's usually better to check if the
features you want to use are available.
…On Fri, 4 Sep 2020, 11:22 Carlos Pereira Atencio, ***@***.***> wrote:
Is there a way during runtime to determine if the code is running from a
Pynsist installation?
I had a look at the docs and issue tracker, but didn't find anything.
PyInstaller has sys.frozen:
https://pyinstaller.readthedocs.io/en/v3.3.1/runtime-information.html
Briefcase has PEP 566 package metadata: beeware/briefcase#425
<beeware/briefcase#425>
Does Pynsist have something similar?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#207>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACQB5MXP4YXK34TKZNUTALSEC5WLANCNFSM4QX7OQIQ>
.
|
I'll leave this open for now because I'm interested to collect views (@carlosperate's or anyone else's) on what specific things people want to achieve with such a feature. My gut feeling is that this would be a bad idea. Code installed by Pynsist shouldn't need to know how it got there. It should just be some Python code, running on Windows. Any special behaviour for the installed application is another corner for bugs to hide in. But I don't want to be dogmatic about this - maybe there's a real use case I don't know about. |
Sorry for the late reply @takluyver, I somehow missed the original response.
That's a very good point and I agree. My original request was for a an old Mu use case in which a config file could be loaded from the project root when running from source code, or from the same folder where the packaged executable is running from (back when it was using PyInstaller). |
Thanks! For the use case of finding a config file, I might be tempted to suggest either:
|
Thanks @takluyver.
That's a good idea as well, thanks! We could add that as another check as well. Thank you for your time and help! I completely understand your point of view herel, so if this feature falls out of scope for pynsist feel free to close the ticket 👍 |
Is this a fixed config file that gets installed as part of the application and not changed? Or something that gets modified by the user (possibly via some settings editor)? I think this might be an XY problem - where X is 'how can we find this config file in all scenarios', and Y is 'how can we detect which of these N specific scenarios the code is running in'. I.e. I suspect that there may be a better solution which doesn't involve figuring out which scenario it's in. But I don't want to be high-handed about this - you're the one working on an application and you know what it needs better than I do. Maybe detecting a Pynsist installation is a sensible thing to do! But I'd like to understand the use case better. |
As mentioned in my comment: #216 (comment) the package metadata is not available on a pynsist app, so one could abuse this fact to detect that the code is running from an installed copy. However, it would make me happy if the metadata would be available so maybe is a short-lived workaround... |
Is there a way during runtime to determine if the code is running from a Pynsist installation?
I had a look at the docs and issue tracker, but didn't find anything.
PyInstaller has sys.frozen: https://pyinstaller.readthedocs.io/en/v3.3.1/runtime-information.html
Briefcase has PEP 566 package metadata: beeware/briefcase#425
Does Pynsist have something similar?
The text was updated successfully, but these errors were encountered: