On Mon, Oct 22, 2012 at 4:16 PM, Mark Lawrence firstname.lastname@example.org:
On 22/10/2012 13:42, anatoly techtonik wrote:
On Mon, Oct 22, 2012 at 2:44 PM, Paul Moore email@example.com wrote:
On 22 October 2012 11:51, anatoly techtonik firstname.lastname@example.org wrote:
I wonder if it will make the life easier if Python was installed with .py association to "%PYTHON_HOME%\python.exe" "%1" %* It will remove the need to run .py scripts in virtualenv with explicit 'python' prefix.
In Python 3.3 and later, the "py.exe" launcher is installed, and this is the association for ".py" files by default. It looks at the #! line of .py files, so you can run a specific Python interpreter by giving its full path. You can also specify (for example) "python3" or "python3.2" to run a specific Python version.
Yes, I've noticed that this nasty launcher gets in the way. So, do you propose to edit source files every time I need to test them with a new version of Python? My original user story:
I see nothing nasty in the launcher, rather it's extremely useful. You don't have to edit your scripts. Just use py -3.2, py -2 or whatever to run the script, the launcher will work out which version to run for you if you're not specific.
Nice. Didn't know about that.
I want to execute scripts in virtual environment (i.e. with Python
installed for this virtual environment) without 'python' prefix.
Here is another one. Currently Sphinx doesn't install with Python 3.2 and with Python 3.3 . Normally I'd create 3 environments to troubleshoot it and I can not modify all Sphinx files to point to the correct interpreter to just execute 'setup.py install'.
Please try running your scripts with the mechanism I've given above and report back what happens, hopefully success :)
Not really. It doesn't work with virtualenv at all.
E:\p>cat version.py import sys print(sys.version) E:\p>python version.py 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)]
E:\p>32\Scripts\activate (32) E:\p>python version.py 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]
(32) E:\p>version.py 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
(32) E:\p>py version.py 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
A solution would be to teach launcher to honor PYTHON_PATH variable if it is set (please don't confuse it with PYTHONPATH which purpose is still unclear on Windows).
What is PYTHON_PATH? IIRC I was told years ago *NOT* to use PYTHONPATH on Windows so its purpose to me isn't unclear, it's completely baffling.
Sorry, it was PYTHON_HOME - variable from .py association I proposed, i.e. "%PYTHON_HOME%\python.exe" "%1" %* If association is made in this way, then virtualenv could override PYTHON_HOME and get `version.py` command execute with it's own interpreter.
Now with py.exe it looks a better idea to have PYTHONBIN environment variable and the association set to "%PYTHONBIN%" "%1" %*. This way virtualenv can easily override it during activation to make .py files executable with whatever Python (or PyPy) it has configured.