简体   繁体   中英

How do I build the latest Python 2 for Windows?

I mean all of it, starting from all sources, and ending up with the .MSI file on the Python website. This includes building the distutils wininst*.exe files. I have found various READMEs that get me some of the way, but no comprehensive guide.

Since nobody answered, I'll post what I found here.

These instructions are for an 'offline' build machine, eg download/obtain everything you need prior to setting up the build environment. I don't connect my build machines to the internet. The instructions assume you downloaded the 2.7.10 PSF source release. This may have been made easier in git. I'm only showing the 32-bit build here, the 64-bit build needs some extra steps.

  • Microsoft Windows 7 Professional with service pack 1 (64-bit)
  • Install Microsoft Visual Studio Team System 2008 development edition, service pack 1
  • ActivePython 2.7.8.10 32-bit. Note: Needs to be 32-bit to get access to msm.merge2.1 which is a 32-bit COM object.
  • put Nasm.exe 2.11.06 in path
  • Install ActiveState Perl 64-bit, including Perl v5.20.2
  • Set the environment variable HOST_PYTHON to c:\\python27\\python.exe
  • Set the environment variable PYTHON to python

For building documentation, install the following. If you are connected to the internet you can let pip download these as they are dependencies of Sphinx.

  • pip install alabaster-0.7.6-py2-none-any.whl
  • install MarkupSafe-0.23 (no wheel available) by the usual route of python setup.py install from the source directory
  • pip install Jinja2-2.8-py2.py3-none-any.whl
  • pip install Pygments-2.0.2-py2-none-any.whl
  • pip install pytz-2015.4-py2.py3-none-any.whl
  • Install Babel-2.0, as above no wheel or egg, so needs to be from source.
  • pip install --no-deps sphinx_rtd_theme-0.1.8-py2.py3-none-any.whl (due to circular dependency with Sphinx)
  • pip install Sphinx-1.3.1-py2.py3-none-any.whl

Go to tools/buildbot/build.bat and edit the file, change the 'Debug' build targets to 'Release'. Remove '_d' from the kill_python exe name.

Go to the 'Doc' directory. Type 'make.bat htmlhelp' to build the help. Go to file Tools/buildbot/buildmsi.bat, and change the help workshop command line to point to what you created in the previous step, eg:

"%ProgramFiles%\HTML Help Workshop\hhc.exe" Doc\build\htmlhelp\python2710.hhp

Edit Tools/buildbot/external.bat, stop the build being a debug build by changing as follows:

if not exist tcltk\bin\tcl85g.dll (
    @rem all and install need to be separate invocations, otherwise nmakehlp is not found on install
    cd tcl-8.5.15.0\win
    nmake -f makefile.vc INSTALLDIR=..\..\tcltk clean all
    nmake -f makefile.vc INSTALLDIR=..\..\tcltk install
    cd ..\..
)

if not exist tcltk\bin\tk85g.dll (
    cd tk-8.5.15.0\win
    nmake -f makefile.vc INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.15.0 clean
    nmake -f makefile.vc INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.15.0 all
    nmake -f makefile.vc INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.15.0 install
    cd ..\..
)

if not exist tcltk\lib\tix8.4.3\tix84g.dll (
    cd tix-8.4.3.5\win
    nmake -f python.mak DEBUG=0 MACHINE=IX86 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk clean
    nmake -f python.mak DEBUG=0 MACHINE=IX86 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk all
    nmake -f python.mak DEBUG=0 MACHINE=IX86 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk install
    cd ..\..
)

In buildbot/external-common.bat, simply remove the clause building Nasm as we are already providing that as a binary.

I haven't documented the build of the wininst*.exe stubs from distutils, but the PSF ones are binary-identical to the ones in the ActiveState Python distribution 2.7.8.10, so you can just copy from there.

Finally, from the root directory run tools\\buildbot\\buildmsi.bat. This will build the 32-bit installer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM