-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix python executable on Windows. #23
Conversation
That should not be necessary. If you have installed Python using the installer it associates the |
Actually no I have installed Python properly, but I then have switched the default program for .py files. |
One more thing is that using the Python executable explicitly assumes that the caller knows which Python version the script should be run with. Otherwise the scripts shebang line can make that decision. So invoking it without seems to be the better choice imo. @stonier Can you comment on this ticket with your experience building/running ROS under Windows? How does it work for you that |
Since it works for our message generation, I'm guessing it's just able to utilise the default. Since @AurelienBallier changed that, I can imagine the result is catostrophic. Not that he's doing something wrong, windows doesn't have the schebang to split the execution program from the default opening program. At least not until python 3.3 when apparently some mechanism is coming to windows. Some observations:
|
Ok, first of all I have found that my weird behavior was coming from file association but not because of the 'system', here is some explanations :
This solution make my patch useless as far as we keep python as the associated program to But as @stonier pointed out, shebang is not interpreted on Windows. So, there is no way to enforce a specific version right now. As for shebang policy, I also made some research about this new shebang interpreter in python 3.3, and I've found some interesting informations on http://pymolurus.blogspot.fr/2012/07/python-launcher-brings-shebang-line.html. |
I will close this pull request since the patch is not necessary to make Python scripts be executed by the Python interpreter on Windows. In order to rely on the shebang line other locations should even avoid using |
…le Python scripts (ros/genpy#23)
…le Python scripts (ros/genpy#23)
…le Python scripts (ros/genpy#23)
@dirk-thomas By not including this, you're effectively saying that windows people should never assign a different default to .py extensions. That is something that ros should not and can't dictate and is a difficult situation for windows since handling executions in the shell and opening editors is governed by the same rule. I'm curious as to why @AurelienBallier switched the default. Is that an esoteric or fairly common use case? |
In several locations where Python scripts are invoked the Python interpreter is not listed explicitly. Since that has been working until now under Windows my recent commits only unified this behavior (by generally not using the Python executable when invoking executable Python scripts). @stonier Do you think we should prepend the Python executable to every invocation of Python scripts in order to allow users to assign a different handler to |
Looking at python.cmake in catkin, it seems as if the initial design of catkin was to utilise cmake for python discovery (this is where the PYTHON_EXECUTABLE gets set). This is also where some custom decisions for python could probably be made. It already customises the install dir for python depending on python setuptools being WIN32 or no. Creating and using a variable that would get set to PYTHON_EXECUTABLE if a non-schebang platform (currently WIN32), and empty otherwise would satisfy both parties until a windows implementation with schebang support is made ready. And yes, you're right, there are other places where it's needed but at least this gives robust support to windows for catkin related stuff. Other areas can be incrementally improved as we hit on problems. I know roslaunch/rosrun have an ugly (and naive) commit which could be improved to enable windows to run python scripts without .py endings as well. |
On non-Windows systems we definitely don't want to use the For Windows I would consider that |
👍 totally agreed.
I was actually thinking about a name for that variable in the previous post, but nothing really decent came to mind! I think that is a good descriptive name, or possibly better might be PYTHON_EXECUTABLE_ONLY_SET_FOR_NON_SCHEBANG_PLATFORMS, but that's getting ridiculously long. |
Nothing fancy, I just wanted to be able to fast double-click to open
Yes, that will allow end users to mess up with their file association, and still take advantages of shebangs. |
…executable Python scripts (ros/genpy#23)" This reverts commit 3a8d043.
We talked about that more and don't want the behavior on different platform to diverge further. Therefore we will keep the |
Fix python executable on Windows.
If you find further locations where Python scripts are invoked without |
Ok, thanks for the merge. |
Hi,
Please consider adding this small patch.
It's useful to make sure the python script is executed using python and not the system default program.
Regards,