-
Notifications
You must be signed in to change notification settings - Fork 393
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
Add Py_SetProgramName to make sure sys.argv[0] is set #8631
Conversation
(@Myoldmopar feel free to correct any of the embedded Python vernacular or terminology) This has bubbled up into a larger problem than we had originally anticipated. To summarize, some Python libraries rely on import sys
print(sys.argv) On Mac, E+ has no problems running with or without the proposed change implemented in the commit here (b2a062e). I haven't tested this on Windows, but on Linux, the following is the result with or without adding
One workaround is to add the following at the top of each Python file: import sys
if not hasattr(sys, 'argv'):
sys.argv = [''] But it looks like we're not the only ones who have had this problem. See here: https://bugs.python.org/issue32573 It looks like the issue is resolved by just moving up to Python 3.8.x. I've tested installing Python 3.8.5 on GitHub Actions, so I'm going to bump the versions of the packaged E+ versions up to that here in this branch. There should be no changes for developers related to this change, it only changes the Python version that is packaged up with E+ releases. Also, we may not actually need to add |
@mitchute, on Windows:
|
@bonnema You'll have to add that to the top of any of the PythonPlugin files and then run it with EnergyPlus. |
🤦♂️
|
@bonnema I guess we were just the lucky ones to find it on Linux. |
... and why no one else complained 😄. I just added the Windows stuff for completeness on this PR. Your changes sound like a good fix all around. |
Right. I'd guess that the number of people who are using E+ on Linux with PyEMS is ..., well, @Myoldmopar, @jmarrec, and ... just us, I'd guess 🥇 🥈 🥉 |
…l deal with that problem later
@mitchute any luck on this? |
@Myoldmopar yeah, this works as expected. I think updating to 3.8 would be the preferred solution, but GitHub isn’t behaving so this can be good enough this close to release. |
As expected, this has no effect on our CI setup, and I like these changes. I agree, going to a new Python version will make the best sense, and we can figure that out immediately after release. I like not making that change right now. Thanks for this fix! |
Pull request overview
We have had issues while attempting to run E+ PythonPluings with third-party libraries (inside of a Docker container) with sys.argv[0] not being set. This should ensure this is set.
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.