Add dependencies locally

This commit is contained in:
Ahrimdon
2024-02-27 01:34:37 -05:00
parent 94a290358e
commit 6a90d22254
5704 changed files with 2770402 additions and 12 deletions

View File

@ -0,0 +1,88 @@
REM Move scripts to root
set REPO_DIR_STAGE=%cd%\github\protobuf-stage
xcopy /S github\protobuf "%REPO_DIR_STAGE%\"
cd github\protobuf
copy kokoro\release\python\windows\build_single_artifact.bat build_single_artifact.bat
REM Set environment variables
set PACKAGE_NAME=protobuf
set REPO_DIR=protobuf
set BUILD_DLL=OFF
set UNICODE=ON
set OTHER_TEST_DEP="setuptools==38.5.1"
set OLD_PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
REM Fetch multibuild
git clone https://github.com/matthew-brett/multibuild.git
REM Pin multibuild scripts at a known commit to avoid potentially unwanted future changes from
REM silently creeping in (see https://github.com/protocolbuffers/protobuf/issues/9180).
REM IMPORTANT: always pin multibuild at the same commit for:
REM - linux/build_artifacts.sh
REM - linux/build_artifacts.sh
REM - windows/build_artifacts.bat
cd multibuild
git checkout b89bb903e94308be79abefa4f436bf123ebb1313
cd ..
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:\python37_32bit
SET PYTHON_VERSION=3.7
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python37
SET PYTHON_VERSION=3.7
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
powershell -File kokoro/release/python/windows/install_python_interpreters.ps1
SET PYTHON=C:\python38_32bit
SET PYTHON_VERSION=3.8
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python38
SET PYTHON_VERSION=3.8
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python39_32bit
SET PYTHON_VERSION=3.9
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python39
SET PYTHON_VERSION=3.9
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python310_32bit
SET PYTHON_VERSION=3.10
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python310
SET PYTHON_VERSION=3.10
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
goto :EOF
:error
exit /b %errorlevel%

View File

@ -0,0 +1,78 @@
setlocal
if %PYTHON%==C:\python37_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python37_32bit set vcplatform=Win32
if %PYTHON%==C:\python37 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python37 set vcplatform=x64
if %PYTHON%==C:\python38_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python38_32bit set vcplatform=Win32
if %PYTHON%==C:\python38 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python38 set vcplatform=x64
if %PYTHON%==C:\python39_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python39_32bit set vcplatform=Win32
if %PYTHON%==C:\python39 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python39 set vcplatform=x64
if %PYTHON%==C:\python310_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python310_32bit set vcplatform=Win32
if %PYTHON%==C:\python310 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python310 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=C:\Program Files\CMake\bin;%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 %REPO_DIR%
xcopy /s %REPO_DIR_STAGE% "%REPO_DIR%\"
REM Checkout release commit
cd %REPO_DIR%
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 || goto :error
msbuild protobuf.sln /p:Platform=%vcplatform% /p:Configuration=Release || goto :error
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 ..\..
goto :EOF
:error
exit /b %errorlevel%

View File

@ -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/**"
}
}

View File

@ -0,0 +1,114 @@
#!/usr/bin/env powershell
# Install Python 3.8 for x64 and x86 in order to build wheels on Windows.
# Originally from grpc/tools/internal_ci/helper_scripts/install_python_interpreters.ps1
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'
trap {
$ErrorActionPreference = "Continue"
Write-Error $_
exit 1
}
# Avoid "Could not create SSL/TLS secure channel"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
function Install-Python {
Param(
[string]$PythonVersion,
[string]$PythonInstaller,
[string]$PythonInstallPath,
[string]$PythonInstallerHash
)
$PythonInstallerUrl = "https://www.python.org/ftp/python/$PythonVersion/$PythonInstaller.exe"
$PythonInstallerPath = "C:\tools\$PythonInstaller.exe"
# Downloads installer
Write-Host "Downloading the Python installer: $PythonInstallerUrl => $PythonInstallerPath"
Invoke-WebRequest -Uri $PythonInstallerUrl -OutFile $PythonInstallerPath
# Validates checksum
$HashFromDownload = Get-FileHash -Path $PythonInstallerPath -Algorithm MD5
if ($HashFromDownload.Hash -ne $PythonInstallerHash) {
throw "Invalid Python installer: failed checksum!"
}
Write-Host "Python installer $PythonInstallerPath validated."
# Installs Python
& $PythonInstallerPath /passive InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir=$PythonInstallPath
if (-Not $?) {
throw "The Python installation exited with error!"
}
# NOTE(lidiz) Even if the install command finishes in the script, that
# doesn't mean the Python installation is finished. If using "ps" to check
# for running processes, you might see ongoing installers at this point.
# So, we needs this "hack" to reliably validate that the Python binary is
# functioning properly.
# Wait for the installer process
Wait-Process -Name $PythonInstaller -Timeout 300
Write-Host "Installation process exits normally."
# Validate Python binary
$PythonBinary = "$PythonInstallPath\python.exe"
& $PythonBinary -c 'print(42)'
Write-Host "Python binary works properly."
# Installs pip
& $PythonBinary -m ensurepip --user
Write-Host "Python $PythonVersion installed by $PythonInstaller at $PythonInstallPath."
}
# Python 3.8
$Python38x86Config = @{
PythonVersion = "3.8.0"
PythonInstaller = "python-3.8.0"
PythonInstallPath = "C:\python38_32bit"
PythonInstallerHash = "412a649d36626d33b8ca5593cf18318c"
}
Install-Python @Python38x86Config
$Python38x64Config = @{
PythonVersion = "3.8.0"
PythonInstaller = "python-3.8.0-amd64"
PythonInstallPath = "C:\python38"
PythonInstallerHash = "29ea87f24c32f5e924b7d63f8a08ee8d"
}
Install-Python @Python38x64Config
# Python 3.9
$Python39x86Config = @{
PythonVersion = "3.9.0"
PythonInstaller = "python-3.9.0"
PythonInstallPath = "C:\python39_32bit"
PythonInstallerHash = "4a2812db8ab9f2e522c96c7728cfcccb"
}
Install-Python @Python39x86Config
$Python39x64Config = @{
PythonVersion = "3.9.0"
PythonInstaller = "python-3.9.0-amd64"
PythonInstallPath = "C:\python39"
PythonInstallerHash = "b61a33dc28f13b561452f3089c87eb63"
}
Install-Python @Python39x64Config
# Python 3.10
$Python310x86Config = @{
PythonVersion = "3.10.0"
PythonInstaller = "python-3.10.0"
PythonInstallPath = "C:\python310_32bit"
PythonInstallerHash = "133aa48145032e341ad2a000cd3bff50"
}
Install-Python @Python310x86Config
$Python310x64Config = @{
PythonVersion = "3.10.0"
PythonInstaller = "python-3.10.0-amd64"
PythonInstallPath = "C:\python310"
PythonInstallerHash = "c3917c08a7fe85db7203da6dcaa99a70"
}
Install-Python @Python310x64Config

View File

@ -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/**"
}
}

View File

@ -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/**"
}
}