> On 23 Mar 2020, at 17:59, Frédéric De Jaeger <fdejae...@novaquark.com> wrote: > > Hi all, > > There is a recurring problem in my company where we use python in various > places (python3). > We do cross platform development windows/linux and our python scripts need to > run everywhere. > Some scripts are launched manually in a terminal. > Others are launched via windows' gui interface. > Others are launched through our build process (cmake based, but also manual > Makefile) > And others are launched via bash scripts. > And possible several other scenario I've forgot. > > On windows, most users use Cygwin to do their terminal based business (`git`, > `cmake`, ...). > > The issue is: There is no reliable way to launch a python script. > > The command: > > python myscript.py > > launches python3 on windows and python2 on 99% of the unix market. > > The command > > python3 myscript.py
The windows version would be py myscript.py If you have python 2 and 3 installed then py -3 myscript py.exe can run any installed version of python and if only one is installed that it will default to the one of only. re: use venv Do not see the need to add venv complexity to the mix just to start an installed python. The py.exe can run any installed version of python. I use that all the time when testing against multiple versions. py -2.7-32 myscript.py py -2.7-64 mysctipt.py ... py -3.7-64 myscript.py > > does not run on windows with the latest python distribution I've played with > (sorry if it has been fixed recently, this whole mail becomes pointless). > > Human can learn which command to run, it's ok. But for all other invocations > context, this becomes very annoying. Switching between linux and Windows requires all sorts of different UI to be aware of. How to get a terminal prompt, how to get a directory listing, etc. > Surprisingly, `cmake` is the more friendly, since `FindPython` will returns > a python3 first. > > At the moment, we have scripts that run under version 2 when run by a linux > user and version 3 on windows. This works by pure luck. > > If the standard python distro would just provide a simple `python3` > binary/alias, then all the stars would align perfectly. > the basic shebang > > #! /usr/bin/env python3 This does work out of the box because py.exe is run when you execute a .py in the CMD. C:\> my-py3-script.py Note: Installing python2 seems to prevent py.exe getting setup for .py files. You can check by doing: assoc .py ftype Python.File If Python.File is not using py.exe then you can fix that with this command from an Admin CMD. ftype Python.File="C:\windows\py.exe" "%1" %* Barry > > would work everywhere by default, without requiring any tweaking (install a > python3 alias on windows, or ask linux users to change the default `python` > symlink) > > I'm sure, I'm far from being the first user complaining about that. Sorry if > the request has been been made numerous time before. > > What it the status on this point ? > > Thanks a lot. > > Fred > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/PTYLAO7YXM4UH3CEI3BRBRALM3AL4HJQ/ > Code of Conduct: http://python.org/psf/codeofconduct/ > _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/RGNMOOH7GVHIUUDEYFFOT6DNHXYWDT2Z/ Code of Conduct: http://python.org/psf/codeofconduct/