diff -r b79025925eab .hgignore --- a/.hgignore Wed Apr 03 13:49:36 2013 +0100 +++ b/.hgignore Wed Apr 03 11:37:43 2013 -0500 @@ -17,11 +17,13 @@ platform$ pyconfig.h$ python$ +python.bat$ python.exe$ python-config$ python-config.py$ reflog.txt$ tags$ +win-config.dat$ Lib/plat-mac/errors.rsrc.df.rsrc Doc/tools/sphinx/ Doc/tools/docutils/ diff -r b79025925eab Doc/using/windows.rst --- a/Doc/using/windows.rst Wed Apr 03 13:49:36 2013 +0100 +++ b/Doc/using/windows.rst Wed Apr 03 11:37:43 2013 -0500 @@ -563,13 +563,9 @@ +--------------------+--------------+-----------------------+ | Directory | MSVC version | Visual Studio version | +====================+==============+=======================+ -| :file:`PC/VC6/` | 6.0 | 97 | +| :file:`PC/VS9.0/` | 9.0 | 2008 | +--------------------+--------------+-----------------------+ -| :file:`PC/VS7.1/` | 7.1 | 2003 | -+--------------------+--------------+-----------------------+ -| :file:`PC/VS8.0/` | 8.0 | 2005 | -+--------------------+--------------+-----------------------+ -| :file:`PCbuild/` | 9.0 | 2008 | +| :file:`PCbuild/` | 10.0 | 2010 | +--------------------+--------------+-----------------------+ Note that not all of these build directories are fully supported. Read the diff -r b79025925eab PCbuild/readme.txt --- a/PCbuild/readme.txt Wed Apr 03 13:49:36 2013 +0100 +++ b/PCbuild/readme.txt Wed Apr 03 11:37:43 2013 -0500 @@ -1,15 +1,14 @@ Building Python using VC++ 10.0 ------------------------------ -This directory is used to build Python for Win32 and x64 platforms, e.g. -Windows 2000, XP, Vista and Windows Server 2008. In order to build 32-bit -debug and release executables, Microsoft Visual C++ 2008 Express Edition is -required at the very least. In order to build 64-bit debug and release -executables, Visual Studio 2008 Standard Edition is required at the very -least. In order to build all of the above, as well as generate release builds -that make use of Profile Guided Optimisation (PG0), Visual Studio 2008 -Professional Edition is required at the very least. The official Python -releases are built with this version of Visual Studio. +This directory is used to build Python for Win32 and x64 platforms, e.g. +Windows XP and later. In order to build 32-bit debug and release executables, +Microsoft Visual C++ 2010 Express Edition is required at the very least. In +order to build 64-bit debug and release executables, Visual Studio 2010 Standard +Edition is required at the very least. In order to build all of the above, as +well as generate release builds that make use of Profile Guided Optimisation +(PG0), Visual Studio 2010 Professional Edition is required at the very least. +The official Python releases are built with this version of Visual Studio. For other Windows platforms and compilers, see ../PC/readme.txt. @@ -27,7 +26,7 @@ The solution is configured to build the projects in the correct order. "Build Solution" or F7 takes care of dependencies except for x64 builds. To make -cross compiling x64 builds on a 32bit OS possible the x64 builds require a +cross compiling x64 builds on a 32bit OS possible the x64 builds require a 32bit version of Python. NOTE: @@ -36,6 +35,11 @@ specifically making changes to the subsystems they implement, or are running a Python core buildbot test slave; see SUBPROJECTS below) +Python can also be built from the command line, using the supplied +"configure.bat" and "make.bat" scripts. The most common usage is: + + configure --with-pydebug && make + When using the Debug setting, the output files have a _d added to their name: python34_d.dll, python_d.exe, parser_d.pyd, and so on. Both the build and rt batch files accept a -d option for debug builds. @@ -47,16 +51,12 @@ Legacy support -------------- -You can find build directories for older versions of Visual Studio and +You can find build directories for older versions of Visual Studio and Visual C++ in the PC directory. The legacy build directories are no longer actively maintained and may not work out of the box. -PC/VC6/ - Visual C++ 6.0 -PC/VS7.1/ - Visual Studio 2003 (7.1) -PC/VS8.0/ - Visual Studio 2005 (8.0) +PC/VS9.0/ + Visual Studio 2008 (9.0) C RUNTIME @@ -65,8 +65,8 @@ Visual Studio 2010 uses version 10 of the C runtime (MSVCRT9). The executables no longer use the "Side by Side" assemblies used in previous versions of the compiler. This simplifies distribution of applications. -The run time libraries are avalible under the VC/Redist folder of your visual studio -distribution. For more info, see the Readme in the VC/Redist folder. +The run time libraries are avalible under the VC/Redist folder of your visual +studio distribution. For more info, see the Readme in the VC/Redist folder. SUBPROJECTS ----------- @@ -108,7 +108,7 @@ within our pcbuild.sln, which means this module expects to find a pre-built Tcl/Tk in either ..\..\tcltk for 32-bit or ..\..\tcltk64 for 64-bit (relative to this directory). See below for instructions to build - Tcl/Tk. + Tcl/Tk. _bz2 Python wrapper for the libbzip2 compression library. Homepage http://www.bzip.org/ @@ -117,8 +117,8 @@ svn export http://svn.python.org/projects/external/bzip2-1.0.6 - ** NOTE: if you use the Tools\buildbot\external(-amd64).bat approach for - obtaining external sources then you don't need to manually get the source + ** NOTE: if you use the `make external` approach for obtaining + external sources then you don't need to manually get the source above via subversion. ** A custom pre-link step in the bz2 project settings should manage to @@ -128,7 +128,7 @@ bzip2-1.0.6\ when you do a clean, so if you want to rebuild bzip2.lib you need to clean up bzip2-1.0.6\ by hand. - All of this managed to build libbz2.lib in + All of this managed to build libbz2.lib in bzip2-1.0.6\$platform-$configuration\, which the Python project links in. _lzma Python wrapper for the liblzma compression library. @@ -144,8 +144,8 @@ svn export http://svn.python.org/projects/external/openssl-1.0.1d - ** NOTE: if you use the Tools\buildbot\external(-amd64).bat approach for - obtaining external sources then you don't need to manually get the source + ** NOTE: if you use the `make external` approach for obtaining + external sources then you don't need to manually get the source above via subversion. ** Alternatively, get the latest version from http://www.openssl.org. @@ -155,17 +155,17 @@ You must install the NASM assembler from http://nasm.sf.net for x86 builds. Put nasmw.exe anywhere in your PATH. - Note: recent releases of nasm only have nasm.exe. Just rename it to + Note: recent releases of nasm only have nasm.exe. Just rename it to nasmw.exe. You can also install ActivePerl from http://www.activestate.com/activeperl/ - if you like to use the official sources instead of the files from + if you like to use the official sources instead of the files from python's subversion repository. The svn version contains pre-build makefiles and assembly files. The build process makes sure that no patented algorithms are included. - For now RC5, MDC2 and IDEA are excluded from the build. You may have + For now RC5, MDC2 and IDEA are excluded from the build. You may have to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process complains about missing files or forbidden IDEA. Again the files provided in the subversion repository are already fixed. @@ -186,30 +186,16 @@ this by hand. The subprojects above wrap external projects Python doesn't control, and as -such, a little more work is required in order to download the relevant source -files for each project before they can be built. The buildbots do this each -time they're built, so the easiest approach is to run either external.bat or -external-amd64.bat in the ..\Tools\buildbot directory from ..\, i.e.: +such, a little more work is required in order to download the relevant source +files for each project before they can be built. The simple method is to use +the make.bat script's "external" target, which requires "svn.exe" to be on your +PATH. It extracts all the external subprojects from +http://svn.python.org/external and places them in ..\.. (relative to this +directory). The "tcltk" target is also available to build Tcl/Tk, which +requires "configure.bat" to have been run. The "build" target ensures that all +externals are present and Tcl/Tk is built before building Python. - C:\..\svn.python.org\projects\python\trunk\PCbuild>cd .. - C:\..\svn.python.org\projects\python\trunk>Tools\buildbot\external.bat - -This extracts all the external subprojects from http://svn.python.org/external -via Subversion (so you'll need an svn.exe on your PATH) and places them in -..\.. (relative to this directory). The external(-amd64).bat scripts will -also build a debug build of Tcl/Tk; there aren't any equivalent batch files -for building release versions of Tcl/Tk lying around in the Tools\buildbot -directory. If you need to build a release version of Tcl/Tk it isn't hard -though, take a look at the relevant external(-amd64).bat file and find the -two nmake lines, then call each one without the 'DEBUG=1' parameter, i.e.: - -The external-amd64.bat file contains this for tcl: - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install - -So for a release build, you'd call it as: - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install - - XXX Should we compile with OPTS=threads? + XXX Should we compile Tcl/Tk with OPTS=threads? XXX Our installer copies a lot of stuff out of the Tcl/Tk install XXX directory. Is all of that really needed for Python use of Tcl/Tk? @@ -238,7 +224,7 @@ junction as follows (using the directory structure above as an example): C:\..\python\trunk\external <- already exists and has built versions - of the external subprojects + of the external subprojects C:\..\python\branches\py3k>linkd.exe external ..\..\trunk\external Link created at: external @@ -297,16 +283,16 @@ -------------- The solution has no configuration for static libraries. However it is easy -it build a static library instead of a DLL. You simply have to set the +it build a static library instead of a DLL. You simply have to set the "Configuration Type" to "Static Library (.lib)" and alter the preprocessor macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to -change the "Runtime Library" from "Multi-threaded DLL (/MD)" to +change the "Runtime Library" from "Multi-threaded DLL (/MD)" to "Multi-threaded (/MT)". Visual Studio properties ------------------------ -The PCbuild solution makes heavy use of Visual Studio property files +The PCbuild solution makes heavy use of Visual Studio property files (*.vsprops). The properties can be viewed and altered in the Property Manager (View -> Other Windows -> Property Manager). diff -r b79025925eab configure.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configure.bat Wed Apr 03 11:37:43 2013 -0500 @@ -0,0 +1,49 @@ +@echo off + +setlocal +pushd %~dp0 + +set PY_CONFIGURATION= +set PY_PLATFORM= + +for %%o in (%*) do ( + if "%%o" EQU "-h" goto help + if "%%o" EQU "--help" goto help + if "%%o" EQU "--with-pydebug" set PY_CONFIGURATION=Debug + if "%%o" EQU "--with-64-bit" set PY_PLATFORM=x64 + if "%%o" EQU "--without-64-bit" set PY_PLATFORM=Win32 +) + +if "%PY_CONFIGURATION%" EQU "" set PY_CONFIGURATION=Release + +if "%PY_PLATFORM%" EQU "" ( + if DEFINED ProgramFiles(x86^) ( + set PY_PLATFORM=x64 + ) else ( + set PY_PLATFORM=Win32 + ) +) + +echo PY_CONFIGURATION=%PY_CONFIGURATION% > win-config.dat +echo PY_PLATFORM=%PY_PLATFORM% >> win-config.dat + +echo Configuration set to "%PY_CONFIGURATION%" +echo Platform set to "%PY_PLATFORM%" +echo. +echo Saved in %~dp0win-config.dat + +goto end + + + +:help +echo Available options: +echo -h, --help Display this help message +echo --with-pydebug Build with debug configuration +echo --with(out)-64-bit Enable/disable 64 bit support +goto end + + + +:end +popd diff -r b79025925eab make.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make.bat Wed Apr 03 11:37:43 2013 -0500 @@ -0,0 +1,409 @@ +@echo off +rem This is a simple emulation of a very limited subset of the functionality of +rem the UNIX make utility, specific to the CPython project. + +rem Written by Zachary Ware + +setlocal +setlocal enabledelayedexpansion +pushd %~dp0 +set this=%~n0 + +rem Set default versions for externals. This should be the only place in this +rem file these need to be changed when updated. + +set BZ2VERSION=bzip2-1.0.6 +set OPENSSLVERSION=openssl-1.0.1d +set TCLVERSION=tcl-8.5.11.0 +set TKVERSION=tk-8.5.11.0 +set SQLITEVERSION=sqlite-3.7.12 +set LZMAVERSION=xz-5.0.3 + + +rem Set configure vars +if EXIST win-config.dat for /F %%x in (win-config.dat) do set %%x + +echo %1 | findstr /C:"=" 1>nul + +if %ERRORLEVEL% EQU 1 ( + set TARGET=%1 +) else ( + set TARGET=build + set %1 + goto parse-arg-loop +) + +if [%TARGET%] EQU [] ( + set TARGET=build + goto after-parse-loop +) else if [%TARGET%] EQU [all] ( + set TARGET=build +) else if [%TARGET%] EQU [-C] ( + goto -C +) + +:parse-arg-loop +shift +if [%1] EQU [] goto after-parse-loop + +echo %1 | findstr /C:"=" 1>nul + +if %ERRORLEVEL% EQU 1 ( + set ARGS=%ARGS% %1 +) else ( + set %1 +) +goto parse-arg-loop +:after-parse-loop + +rem Find an interpreter to use, if one isn't provided + +if "%PYTHON%" EQU "" ( + if EXIST PCbuild\amd64\python.exe ( + set PYTHON=PCbuild\amd64\python.exe + ) else if EXIST PCbuild\amd64\python_d.exe ( + set PYTHON=PCbuild\amd64\python_d.exe + ) else if EXIST PCbuild\python.exe ( + set PYTHON=PCbuild\python.exe + ) else if EXIST PCbuild\python_d.exe ( + set PYTHON=PCbuild\python_d.exe + ) else if EXIST %systemroot%\py.exe ( + set PYTHON=py -3 + ) else ( + set PYTHON=python + ) +) + + +rem Set some internal vars + +if "%PY_PLATFORM%" EQU "x64" ( + set _vcvarsarg=x86_amd64 + set _pcbuilddir=PCbuild\amd64 +) else ( + set _vcvarsarg=x86 + set _pcbuilddir=PCbuild +) + +if "%PY_CONFIGURATION%" EQU "Debug" ( + set _pybuildextension=_d.exe + set _tclbuildextension=!TCLVERSION:~4,3! + set _tclbuildextension=!_tclbuildextension:.=!g.dll + set _tcldebugsetting=1 +) else ( + set _pybuildextension=.exe + set _tclbuildextension=!TCLVERSION:~4,3! + set _tclbuildextension=!_tclbuildextension:.=!.dll + set _tcldebugsetting=0 +) + +rem Go to the proper target, or fall through to a help message + +for %%x in ( + build, buildbottest, clean, clobber, external, importlib, msi, + patchcheck, tcltk, test +) do if "%TARGET%" EQU "%%x" goto %%x + +echo. +echo The Python Make Script for Windows +echo ---------------------------------- +echo Please note that this script is only intended to emulate a very small +echo portion of the UNIX make utility, and only for the CPython project. +echo. +echo Usage: +echo %this% [all ^| build] -- Build CPython +echo %this% clean -- Clean out build artifacts +echo %this% clobber -- Clean out build artifacts and remove externals +echo %this% patchcheck -- Run Tools\scripts\patchcheck.py +echo %this% external -- Fetch external libraries in preparation for building +echo %this% importlib -- Build and run the _freeze_importlib project +echo %this% msi -- Build a Python .msi +echo %this% tcltk -- Build Tcl/Tk and install .dlls +echo %this% test -- Test Python (currently %PYTHON%) +echo %this% buildbottest -- Test Python with default options for buildbots +echo. +echo %this% -C DIR [args] -- Change dir to DIR and call another make.bat in that +echo dir with 'args'. E.g. ``make -C Doc html`` +echo. +echo You can also set environment variables for the duration of the script by +echo including them in the command line, e.g.: +echo. +echo make test "TESTOPTS=-j4" +echo. +echo You must include the double quotes^^! +goto end + + + +:build +if "%PY_PLATFORM%" EQU "" goto no-configure +if "%PY_CONFIGURATION%" EQU "" goto no-configure + +echo Configured for %PY_CONFIGURATION% %PY_PLATFORM% build. + +call :external + +if NOT EXIST %_pcbuilddir%\tcl%_tclbuildextension% set _NeedTclTk=1 +if NOT EXIST %_pcbuilddir%\tk%_tclbuildextension% set _NeedTclTk=1 + +if DEFINED _NeedTclTk ( + set _NeedTclTk= + echo Building Tcl/Tk... + call :tcltk +) else echo Tcl/Tk .dlls found, no need to build. + +call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" %_vcvarsarg% +@echo on +@echo Building kill_python... +msbuild PCbuild\kill_python.vcxproj /p:Configuration=Debug /p:PlatformTarget=%PY_PLATFORM% +@echo Killing all Pythons running from this checkout... +%_pcbuilddir%\kill_python_d.exe +@echo Building Python... +msbuild PCbuild\pcbuild.sln /p:Configuration=%PY_CONFIGURATION% /p:Platform=%PY_PLATFORM% + +@echo off +echo Creating python.bat (convenience batch file)... +echo @%~dp0%_pcbuilddir%\python%_pybuildextension% %%* > python.bat +goto end + + + +:clean +if "%PY_PLATFORM%" EQU "" goto no-configure +if "%PY_CONFIGURATION%" EQU "" goto no-configure + + +echo Configured for %PY_PLATFORM% platform. + +pushd %~dp0 + +call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" %_vcvarsarg% +@echo on +@echo Deleting .pyc/.pyo files ... +del /s Lib\*.pyc Lib\*.pyo +@echo Deleting test leftovers ... +rmdir /s /q build + +pushd PCbuild + +msbuild /target:clean pcbuild.sln /p:Configuration=Release /p:Platform=%PY_PLATFORM% +msbuild /target:clean pcbuild.sln /p:Configuration=Debug /p:Platform=%PY_PLATFORM% + +popd + +@echo Removing python.bat... +del python.bat +@echo off +goto end + + + +:clobber +echo Cleaning build... +call :clean + +@echo on +@echo Removing Tcl/Tk .dlls... +del %_pcbuilddir%\tcl*.dll +del %_pcbuilddir%\tk*.dll + +@echo Removing configuration file... +del win-config.dat + +pushd .. + +@echo Clearing externals... +if EXIST %BZ2VERSION% rmdir /S /Q %BZ2VERSION% +if EXIST %OPENSSLVERSION% rmdir /S /Q %OPENSSLVERSION% +if EXIST %TCLVERSION% rmdir /S /Q %TCLVERSION% +if EXIST %TKVERSION% rmdir /S /Q %TKVERSION% +if EXIST tcltk rmdir /S /Q tcltk +if EXIST tcltk64 rmdir /S /Q tcltk64 +if EXIST %SQLITEVERSION% rmdir /S /Q %SQLITEVERSION% +if EXIST %LZMAVERSION% rmdir /S /Q %LZMAVERSION% + +@echo off +echo Done! + +goto end + + + +:-C +shift +cd %1 + +:concat-args-loop +shift +if [%1] EQU [] goto after-concat-loop +set ARGS=%ARGS% %1 +goto concat-args-loop +:after-concat-loop + +call make.bat %ARGS% +goto end + + + +:external + +pushd .. + +rem bzip +if NOT EXIST %BZ2VERSION% ( + echo Fetching bzip2 sources... + svn export http://svn.python.org/projects/external/%BZ2VERSION% +) + +rem OpenSSL +if NOT EXIST %OPENSSLVERSION% ( + echo Fetching OpenSSL sources... + svn export http://svn.python.org/projects/external/%OPENSSLVERSION% +) + +rem tcl/tk +if NOT EXIST %TCLVERSION% ( + if EXIST tcltk rmdir /s/q tcltk + if EXIST tcltk64 rmdir /s/q tcltk64 + echo Fetching Tcl sources... + svn export http://svn.python.org/projects/external/%TCLVERSION% +) +if NOT EXIST %TKVERSION% ( + if EXIST tcltk rmdir /s/q tcltk + if EXIST tcltk64 rmdir /s/q tcltk64 + echo Fetching Tk sources... + svn export http://svn.python.org/projects/external/%TKVERSION% +) + +rem sqlite3 +if not exist %SQLITEVERSION% ( + echo Fetching SQLite3 sources... + svn export http://svn.python.org/projects/external/%SQLITEVERSION% +) + +rem lzma +if not exist %LZMAVERSION% ( + echo Fetching LZMA sources... + svn export http://svn.python.org/projects/external/%LZMAVERSION% +) + +goto end + + + +:importlib +call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86 +@echo on +msbuild PCbuild\_freeze_importlib.vcxproj /p:Configuration=Release /p:PlatformTarget=Win32 +@echo off +goto end + + + +:msi +@echo on +@rem build a release version of everything + +call make "PY_CONFIGURATION=Release" + +@rem build the documentation +call Doc\make.bat htmlhelp + +@echo on +@rem build the MSI file +cd PC +nmake /f icons.mak +cd ..\Tools\msi +del *.msi +nmake /f msisupport.mak +cmd /c "py -2 msi.py" + +@echo off +goto end + + + +:patchcheck +cmd /c %PYTHON% Tools\scripts\patchcheck.py +goto end + + + +:tcltk +call :external + +pushd ..\%TCLVERSION%\win + +if "%PY_PLATFORM%" EQU "" goto no-configure + +if "%PY_PLATFORM%" EQU "x64" ( + set _tclmachine=AMD64 + set _tclinstdir=..\..\tcltk64 +) else ( + set _tclmachine=IX86 + set _tclinstdir=..\..\tcltk +) + +if EXIST %_tclinstdir% ( + echo Clearing previous build... + rmdir /S /Q %_tclinstdir% +) + +call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" %_vcvarsarg% + +rem all and install need to be separate invocations, otherwise nmakehlp is not found on install +@echo on +nmake -f makefile.vc DEBUG=%_tcldebugsetting% MACHINE=%_tclmachine% INSTALLDIR=%_tclinstdir% clean +nmake -f makefile.vc DEBUG=%_tcldebugsetting% MACHINE=%_tclmachine% INSTALLDIR=%_tclinstdir% all +nmake -f makefile.vc DEBUG=%_tcldebugsetting% MACHINE=%_tclmachine% INSTALLDIR=%_tclinstdir% install +@echo off +popd + +if NOT %ERRORLEVEL% == 0 ( + echo Building Tcl failed, skipping Tk + goto end +) + +pushd ..\%TKVERSION%\win +@echo on +nmake -f makefile.vc OPTS=noxp DEBUG=%_tcldebugsetting% MACHINE=%_tclmachine% INSTALLDIR=%_tclinstdir% TCLDIR=..\..\%TCLVERSION% clean +nmake -f makefile.vc OPTS=noxp DEBUG=%_tcldebugsetting% MACHINE=%_tclmachine% INSTALLDIR=%_tclinstdir% TCLDIR=..\..\%TCLVERSION% all +nmake -f makefile.vc OPTS=noxp DEBUG=%_tcldebugsetting% MACHINE=%_tclmachine% INSTALLDIR=%_tclinstdir% TCLDIR=..\..\%TCLVERSION% install + + +popd +pushd PCbuild + +del ..\%_pcbuilddir%\tcl*.dll +del ..\%_pcbuilddir%\tk*.dll + +xcopy /Y %_tclinstdir%\bin\tcl%_tclbuildextension% ..\%_pcbuilddir% +xcopy /Y %_tclinstdir%\bin\tk%_tclbuildextension% ..\%_pcbuilddir% +@echo off +goto end + + + +:test +if [%TESTPYTHON%] EQU [] set TESTPYTHON=%PYTHON% +cmd /c %TESTPYTHON% Tools\scripts\run_tests.py %TESTOPTS% %ARGS% +goto end + + + +:buildbottest +if "%TESTTIMEOUT%" EQU "" set TESTTIMEOUT=3600 +set TESTOPTS=-j 1 -u all -W --timeout=%TESTTIMEOUT% %TESTOPTS% %ARGS% +set ARGS= +call :test +goto end + + + +:no-configure +echo Please run configure.bat with any desired options first. + + + +:end +popd