============================== How to build CCTBX on Windows ============================== .. contents:: Introduction ============ This document describes how to build CCTBX from sources on Windows 7 or more recent versions. We cover how to build manually as well how to build automatically with BuildBot. Given that Windows does not have all the necessary tools for building CCTBX, how to set up these tools is covered here in some detail. A typical CCTBX installation takes up the order of 1Gb disk space. If you build CCTBX from scratch including an installer this will be of the order of 6Gb. Throughout this document the "command prompt" (archaichally termed the "DOS prompt" by some) refers to the commandline interpreter program, cmd.exe, which serves the same purpose as bash or tcsh on Unix. On the Startup menu it is located in the "Accessories" group. Necessary prerequisites ======================= To build CCTBX from scratch the following tools are required: - Python 2.7 (any version) - Microsoft Visual C++ 9.0 / Microsoft Visual Studio 2008 - TortoiseSVN with command line tools ( for updating sources ) - TortoiseGit (optionally) - Git ( for updating sources and providing some unix command line tools) - mtee.exe (optionally for duplicating stdout to file and console) Visual C++ 9.0 --------------- Microsoft Visual Studio 2008 compiler is available for free in the Windows 7 SDK from the Microsoft website: https://www.microsoft.com/en-gb/download/details.aspx?id=3138&fa43d42b-25b5-4a42-fe9b-1634f450f5ee=True . It should be titled "Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1". Rather than doing the automated installation from the website it may be convenient to download the DVD iso image of the SDK and then do the installation from that. The 32 bit version is named ``GRMSDK_EN_DVD.iso`` whereas the 64 bit version is named ``GRMSDKX_EN_DVD.iso``. There are newer versions of this SDK for Windows 7. But as these use more recent C-runtime libraries compiled programs may not be binary compatible with Python 2.7 which is compiled with Visual C++ 9.0. You would still be able to build individual statically linked executables with those newer compilers. But whether or not compiled python modules can run without crashing using a newer runtime is questionable. After installing the compiler it can be invoked once environment variables have been set by calling scripts such as ``vcvars32.bat`` or ``vcvars64.bat`` from a command prompt or in a build script prior to compiling. These files live in the folder :: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin OpenSSH tools -------------- The OpenSSH tools used for the Windows build are the ones that come with Git for Windows. If Git has been installed in :: C:\Program Files\Git then OpenSSH tools live in the directory :: C:\Program Files\Git\usr\bin which you must add to the %PATH% environment variable. To have the build run without interrupts the private keys matching your public keys on the remote svn or git repositories must be loaded prior to the build with ssh-agent. Create a .ssh directory in the directory pointed to by the %USERPROFILE% environment variable and store your private keys there. Then add the lines .. raw:: html
call "C:\Program Files\Git\cmd\start-ssh-agent.cmd" SETX SSH_AUTH_SOCK "%SSH_AUTH_SOCK%" SETX SSH_AGENT_PID "%SSH_AGENT_PID%"
ssh-add mykey_rsa
@REM Call script with argument x32 or x64 to specify platform. Optional 2nd argument is the release number, e.g. 123.456 @REM SETLOCAL ENABLEDELAYEDEXPANSION @REM enable the platform specific compiler and python executable set MYPLATFORM=%1 IF DEFINED MYPLATFORM ( IF %MYPLATFORM% == x32 ( call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat" set PYTHONEXE=C:\Python27_32\python.exe ) IF %MYPLATFORM% == x64 ( call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat" set PYTHONEXE=C:\Python27_64\python.exe ) ) @REM Platform specific compiler and python executable now set mkdir %MYPLATFORM% cd %MYPLATFORM% %PYTHONEXE% -c "import time; print '-' + str((int((time.time() - 1404950400) / (24*60*60))))" > buildnumber.txt SET /p BUILDNUMBER= < buildnumber.txt %PYTHONEXE% -c "import time; print 'dev-' + str((int((time.time() - 1404950400) / (24*60*60))))" > version.txt SET RELEASENUMBER=%2 IF DEFINED RELEASENUMBER ( SET CCTBXVERSION=!RELEASENUMBER!!BUILDNUMBER! ) ELSE ( SET CCTBXVERSION=dev!BUILDNUMBER! ) title Bootstrap %CCTBXVERSION% on %MYPLATFORM% @REM mkdir %CCTBXVERSION% @REM cd %CCTBXVERSION% mkdir Current del *.log cd Current @echo %DATE% %TIME% > ..\build%CCTBXVERSION%-%MYPLATFORM%.log @REM get latest bootstrap.py file set GETBOOTSTRAP=%3 IF DEFINED GETBOOTSTRAP ( @echo Get bootstrap.py | mtee /+ ..\build%CCTBXVERSION%-%MYPLATFORM%.log ( curl https://raw.githubusercontent.com/cctbx/cctbx_project/master/libtbx/auto_build/bootstrap.py > bootstrap.py ) 2>&1 ^ | mtee /+ ..\build%CCTBXVERSION%-%MYPLATFORM%.log ) @REM with no flags bootstrap defaults to doing cleanup, hot, update, base and build stages title Bootstrap %CCTBXVERSION% on %MYPLATFORM% build @echo %DATE% %TIME% >> ..\build%CCTBXVERSION%-%MYPLATFORM%.log %PYTHONEXE% bootstrap.py --builder=cctbx --nproc=10 2>&1 ^ | mtee /+ ..\build%CCTBXVERSION%-%MYPLATFORM%.log IF ERRORLEVEL 1 ( GOTO Makesummary ) @echo %DATE% %TIME% | mtee /+ ..\build%CCTBXVERSION%-%MYPLATFORM%.log @REM run tests title Bootstrap %CCTBXVERSION% on %MYPLATFORM% tests @echo %DATE% %TIME% > ..\tests%CCTBXVERSION%-%MYPLATFORM%.log %PYTHONEXE% bootstrap.py --builder=cctbx --nproc=10 tests 2>&1 ^ | mtee /+ ..\tests%CCTBXVERSION%-%MYPLATFORM%.log IF ERRORLEVEL 1 ( GOTO Makesummary ) @echo %DATE% %TIME% | mtee /+ ..\tests%CCTBXVERSION%-%MYPLATFORM%.log @REM create installer title Bootstrap %CCTBXVERSION% on %MYPLATFORM% create_installer @echo %DATE% %TIME% > ..\CreateInstaller%CCTBXVERSION%-%MYPLATFORM%.log call build\bin\libtbx.create_installer.bat --binary --version %CCTBXVERSION% ^ --install_script modules\cctbx_project\libtbx\auto_build\plus_installer.py ^ --dist_dir dist\%CCTBXVERSION% tmp/cctbx-installer-%CCTBXVERSION%-win7vc90 2>&1 ^ | mtee /+ ..\CreateInstaller%CCTBXVERSION%-%MYPLATFORM%.log IF ERRORLEVEL 1 ( GOTO Makesummary ) @echo %DATE% %TIME% | mtee /+ ..\CreateInstaller%CCTBXVERSION%-%MYPLATFORM%.log :Makesummary @echo %CCTBXVERSION%-%MYPLATFORM% > ..\summary.log %PYTHONEXE% -c "lines = open('..\\build%CCTBXVERSION%-%MYPLATFORM%.log','r').readlines(); lastlines = lines[(len(lines) - 5): ]; print ''.join(lastlines); " >> ..\summary.log %PYTHONEXE% -c "lines = open('..\\tests%CCTBXVERSION%-%MYPLATFORM%.log','r').readlines(); lastlines = lines[(len(lines) - 5): ]; print ''.join(lastlines); " >> ..\summary.log %PYTHONEXE% -c "lines = open('..\\CreateInstaller%CCTBXVERSION%-%MYPLATFORM%.log','r').readlines(); lastlines = lines[(len(lines) - 20): ]; print ''.join(lastlines); " >> ..\summary.log REM print concatenated summary of logfiles in a message box type ..\summary.log | msg %USERNAME% /time:86400 @ENDLOCAL EXIT
:GetWindowsSdkDirHelper @for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /v "CurrentInstallFolder"') DO ( if "%%i"=="CurrentInstallFolder" ( SET "WindowsSdkDir=%%k" ) )
:GetWindowsSdkDirHelper SET fname=%TEMP%\tmpSDKvars.txt reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /v "CurrentInstallFolder" > %fname% @SET WindowsSdkDir= @for /F "tokens=1,2*" %%i in (%fname%) DO ( if "%%i"=="CurrentInstallFolder" ( SET "WindowsSdkDir=%%k" ) ) del %fname%
C:\Python2.7.9x64\Scripts\easy_install.exe buildbot-slave
C:\Python2.7.9x64\Scripts\buildslave create-slave C:\Users\builder\slave cci-vm-6.lbl.gov:9989 intel-windows-x86_64 pass
START "Running BuildBot Slave. Do not close!" /MIN cmd /c C:\Python2.7.9x64\Scripts\buildslave start C:\Users\builder\slave