Python wheel kokoro for windows (#5034)
* Add kokoro config for building python wheels on windows * Move script to root * Debug * Debug * Change working directory * Add msbuild to path * Debug * Fix python dir name * Debug * Move artifacts to targeted directory * Update artifact directory * Debug * Debug * Automatic generation of version * Reduce file numberspull/5048/head
parent
af3b2ab915
commit
f2a1356966
3 changed files with 123 additions and 0 deletions
@ -0,0 +1,53 @@ |
|||||||
|
REM Move scripts to root |
||||||
|
cd github\protobuf |
||||||
|
copy kokoro\release\python\windows\build_single_artifact.bat build_single_artifact.bat |
||||||
|
|
||||||
|
REM Set environment variables |
||||||
|
set REPO_DIR=protobuf |
||||||
|
set PACKAGE_NAME=protobuf |
||||||
|
set BUILD_DLL=OFF |
||||||
|
set UNICODE=ON |
||||||
|
set PB_TEST_DEP="six==1.9" |
||||||
|
set OTHER_TEST_DEP="setuptools==38.5.1" |
||||||
|
set OLD_PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH% |
||||||
|
for /f "tokens=*" %%i in ( 'grep -i "version" python/google/protobuf/__init__.py ^| grep -o "'.*'"' ) do set BUILD_VERSION=%%i |
||||||
|
set BUILD_COMMIT=v%BUILD_VERSION:'=% |
||||||
|
|
||||||
|
REM Fetch multibuild |
||||||
|
git clone https://github.com/matthew-brett/multibuild.git |
||||||
|
|
||||||
|
REM Install zlib |
||||||
|
mkdir zlib |
||||||
|
curl -L -o zlib.zip http://www.winimage.com/zLibDll/zlib123dll.zip |
||||||
|
curl -L -o zlib-src.zip http://www.winimage.com/zLibDll/zlib123.zip |
||||||
|
7z x zlib.zip -ozlib |
||||||
|
7z x zlib-src.zip -ozlib\include |
||||||
|
SET ZLIB_ROOT=%cd%\zlib |
||||||
|
del /Q zlib.zip |
||||||
|
del /Q zlib-src.zip |
||||||
|
|
||||||
|
REM Create directory for artifacts |
||||||
|
SET ARTIFACT_DIR=%cd%\artifacts |
||||||
|
mkdir %ARTIFACT_DIR% |
||||||
|
|
||||||
|
REM Build wheel |
||||||
|
|
||||||
|
SET PYTHON=C:\python35_32bit |
||||||
|
SET PYTHON_VERSION=3.5 |
||||||
|
SET PYTHON_ARCH=32 |
||||||
|
CALL build_single_artifact.bat |
||||||
|
|
||||||
|
SET PYTHON=C:\python35 |
||||||
|
SET PYTHON_VERSION=3.5 |
||||||
|
SET PYTHON_ARCH=64 |
||||||
|
CALL build_single_artifact.bat |
||||||
|
|
||||||
|
SET PYTHON=C:\python36_32bit |
||||||
|
SET PYTHON_VERSION=3.6 |
||||||
|
SET PYTHON_ARCH=32 |
||||||
|
CALL build_single_artifact.bat |
||||||
|
|
||||||
|
SET PYTHON=C:\python36 |
||||||
|
SET PYTHON_VERSION=3.6 |
||||||
|
SET PYTHON_ARCH=64 |
||||||
|
CALL build_single_artifact.bat |
@ -0,0 +1,62 @@ |
|||||||
|
setlocal |
||||||
|
|
||||||
|
if %PYTHON%==C:\python35_32bit set generator=Visual Studio 14 |
||||||
|
if %PYTHON%==C:\python35_32bit set vcplatform=Win32 |
||||||
|
|
||||||
|
if %PYTHON%==C:\python35 set generator=Visual Studio 14 Win64 |
||||||
|
if %PYTHON%==C:\python35 set vcplatform=x64 |
||||||
|
|
||||||
|
if %PYTHON%==C:\python36_32bit set generator=Visual Studio 14 |
||||||
|
if %PYTHON%==C:\python36_32bit set vcplatform=Win32 |
||||||
|
|
||||||
|
if %PYTHON%==C:\python36 set generator=Visual Studio 14 Win64 |
||||||
|
if %PYTHON%==C:\python36 set vcplatform=x64 |
||||||
|
|
||||||
|
REM Prepend newly installed Python to the PATH of this build (this cannot be |
||||||
|
REM done from inside the powershell script as it would require to restart |
||||||
|
REM the parent CMD process). |
||||||
|
SET PATH=%PYTHON%;%PYTHON%\Scripts;%OLD_PATH% |
||||||
|
python -m pip install -U pip |
||||||
|
pip install wheel |
||||||
|
|
||||||
|
REM Check that we have the expected version and architecture for Python |
||||||
|
python --version |
||||||
|
python -c "import struct; print(struct.calcsize('P') * 8)" |
||||||
|
|
||||||
|
rmdir /s/q protobuf |
||||||
|
git clone https://github.com/google/protobuf.git |
||||||
|
|
||||||
|
REM Checkout release commit |
||||||
|
cd %REPO_DIR% |
||||||
|
git checkout %BUILD_COMMIT% |
||||||
|
|
||||||
|
REM ====================== |
||||||
|
REM Build Protobuf Library |
||||||
|
REM ====================== |
||||||
|
|
||||||
|
mkdir src\.libs |
||||||
|
|
||||||
|
mkdir vcprojects |
||||||
|
pushd vcprojects |
||||||
|
cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% -Dprotobuf_BUILD_TESTS=OFF ../cmake |
||||||
|
msbuild protobuf.sln /p:Platform=%vcplatform% /p:Configuration=Release |
||||||
|
dir /s /b |
||||||
|
popd |
||||||
|
copy vcprojects\Release\libprotobuf.lib src\.libs\libprotobuf.a |
||||||
|
copy vcprojects\Release\libprotobuf-lite.lib src\.libs\libprotobuf-lite.a |
||||||
|
SET PATH=%cd%\vcprojects\Release;%PATH% |
||||||
|
dir vcprojects\Release |
||||||
|
|
||||||
|
REM ====================== |
||||||
|
REM Build python library |
||||||
|
REM ====================== |
||||||
|
|
||||||
|
cd python |
||||||
|
|
||||||
|
REM sed -i 's/\ extra_compile_args\ =\ \[\]/\ extra_compile_args\ =\ \[\'\/MT\'\]/g' setup.py |
||||||
|
|
||||||
|
python setup.py bdist_wheel --cpp_implementation --compile_static_extension |
||||||
|
dir dist |
||||||
|
copy dist\* %ARTIFACT_DIR% |
||||||
|
dir %ARTIFACT_DIR% |
||||||
|
cd ..\.. |
@ -0,0 +1,8 @@ |
|||||||
|
# Configuration for Windows protoc release builds |
||||||
|
build_file: "protobuf/kokoro/release/python/windows/build_artifacts.bat" |
||||||
|
|
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "github/protobuf/artifacts/**" |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue