This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Create a 'python.bat' script to invoke interpreter from source root
Type: enhancement Stage: resolved
Components: Build, Windows Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zach.ware Nosy List: brian.curtin, loewis, python-dev, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2013-12-12 15:33 by zach.ware, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python.bat.diff zach.ware, 2013-12-12 15:33 review
Messages (5)
msg205957 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-12-12 15:33
The attached patch adds a CustomBuildStep to python.vcxproj which creates a 'python.bat' script in the root of the source tree for quicker and easier invocation for testing purposes, and to make the Windows Python developer experience a little closer to the UNIX experience.  Sample output:

"""
C:\path\to\cpython>type python.bat
@rem This script invokes the most recently built Python with all arguments
@rem passed through to the interpreter.  This file is generated by the
@rem build process and any changes *will* be thrown away by the next
@rem rebuild.
@rem This is only meant as a convenience for developing CPython
@rem and using it outside of that context is ill-advised.
@echo Running Debug^|Win32 interpreter...
@"C:\path\to\cpython\PCbuild\python_d.exe" %*

C:\path\to\cpython>python -c "import sys;print(sys.version)"
Running Debug|Win32 interpreter...
3.4.0b1 (default:6864abd8e83a+, Dec 12 2013, 08:35:32) [MSC v.1600 32 bit (Intel
)]
"""

As the commentary (which can likely be improved) states, the script is re-created by every rebuild, so it always points to the most recently built interpreter.  Also, being a CustomBuildStep, it is cleaned up automatically by the Clean build target.

I'm not sure whether echoing the interpreter configuration is the best idea, but I personally prefer that over echoing the full command which has the potential to be very long.  I think that the Configuration/Platform should be displayed somehow to reduce confusion since there could be up to 8 different interpreters living together in PCbuild (not to mention PC/VS10.0, when it exists someday) and python.bat will only point to one of them.

Note that the x64 changes are done by hand and untested; I don't have the ability to do so just yet.
msg215294 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-04-01 04:33
This appears to work correctly for PGO builds and x64 builds.  Does anyone have any objections to this, or suggestions for improvement?
msg216547 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2014-04-16 18:34
+1
msg217650 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-04-30 20:49
New changeset de35f6a3b292 by Zachary Ware in branch 'default':
Issue #19962: The Windows build process now creates "python.bat"
http://hg.python.org/cpython/rev/de35f6a3b292
msg217657 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-04-30 21:15
Thanks for the up-vote, Tim :)
History
Date User Action Args
2022-04-11 14:57:55adminsetgithub: 64161
2014-04-30 21:15:26zach.waresetstatus: open -> closed
resolution: fixed
messages: + msg217657

stage: patch review -> resolved
2014-04-30 20:49:59python-devsetnosy: + python-dev
messages: + msg217650
2014-04-16 18:34:31tim.goldensetmessages: + msg216547
2014-04-01 04:33:58zach.waresetmessages: + msg215294
versions: + Python 3.5, - Python 3.4
2013-12-14 03:59:57terry.reedysetnosy: + terry.reedy
2013-12-12 15:33:49zach.warecreate