From f0b74146dac67c85d487a316b003bc51e3a8bc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Rast?= Date: Sat, 7 Sep 2019 00:02:23 +0200 Subject: [PATCH] Created new scripts for preparing and building borg --- .gitignore | 1 + scripts/buildwin.bat | 20 -------------------- scripts/win-build.ps1 | 18 ++++++++++++++++++ scripts/win-download-openssl.ps1 | 15 +++++++++++++++ scripts/win-setup-build-env.ps1 | 18 ++++++++++++++++++ 5 files changed, 52 insertions(+), 20 deletions(-) delete mode 100644 scripts/buildwin.bat create mode 100644 scripts/win-build.ps1 create mode 100644 scripts/win-download-openssl.ps1 create mode 100644 scripts/win-setup-build-env.ps1 diff --git a/.gitignore b/.gitignore index 91ee405fd..50ac24ed8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ MANIFEST docs/_build build dist +external borg-env .tox src/borg/compress.c diff --git a/scripts/buildwin.bat b/scripts/buildwin.bat deleted file mode 100644 index 33d745671..000000000 --- a/scripts/buildwin.bat +++ /dev/null @@ -1,20 +0,0 @@ - -REM Use the downloaded OpenSSL, for all other libraries the bundled version is used. -REM On Appveyor different OpenSSL versions are available, therefore the directory contains the version information. -set BORG_OPENSSL_PREFIX=C:\OpenSSL-v111-Win64 -set BORG_USE_BUNDLED_B2=YES -set BORG_USE_BUNDLED_LZ4=YES -set BORG_USE_BUNDLED_ZSTD=YES -set BORG_USE_BUNDLED_XXHASH=YES - -REM Somehow on my machine rc.exe was not found. Adding the Windows Kit to the path worked. -set PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64 - -REM Run the build in the project directory. -SET WORKPATH=%~dp0\.. -pushd %WORKPATH% - -python setup.py clean -pip install -v -e . - -popd diff --git a/scripts/win-build.ps1 b/scripts/win-build.ps1 new file mode 100644 index 000000000..79090c8b4 --- /dev/null +++ b/scripts/win-build.ps1 @@ -0,0 +1,18 @@ +# Build a wheel and single file executable + +# Configure the build environment +& $PSScriptRoot\win-setup-build-env.ps1 + +# Clean the old build +python setup.py clean + +# Build the extension inplace +python setup.py build_ext --inplace + +# Run pip install to install install_requires of borg. +pip install -v -e . + +# Build the wheel +python setup.py bdist_wheel + +pyinstaller -y scripts/borg.exe.spec diff --git a/scripts/win-download-openssl.ps1 b/scripts/win-download-openssl.ps1 new file mode 100644 index 000000000..8040d0d1f --- /dev/null +++ b/scripts/win-download-openssl.ps1 @@ -0,0 +1,15 @@ +# Download and extract the prebuilt openssl libraries provided by the python developers. +# The file is extracted to the .\external directory. + +$url = "https://github.com/python/cpython-bin-deps/archive/openssl-bin-1.1.1c.zip" +$dest = "external" + +$ErrorActionPreference = "Stop" + +Write-Output "Downloading OpenSSL from cpython-bin-deps repository ..." +Invoke-WebRequest $url -OutFile openssl.zip + +Write-Output "Extracting OpenSSL" +Expand-Archive -Path openssl.zip -DestinationPath $dest -Force + +Remove-Item -Path openssl.zip diff --git a/scripts/win-setup-build-env.ps1 b/scripts/win-setup-build-env.ps1 new file mode 100644 index 000000000..19aaa21df --- /dev/null +++ b/scripts/win-setup-build-env.ps1 @@ -0,0 +1,18 @@ +# Configure the environment such that borg can be built and run. +# Note that building borg requires OpenSSL which is not available by default. +# Use the win-download-openssl.ps1 script to get correct OpenSSL version. + +$opensslPath = Resolve-Path "$PSScriptRoot\..\external\cpython-bin-deps-openssl-bin-1.1.1c\$env:PROCESSOR_ARCHITECTURE" +if(!(Test-Path $opensslPath)) { + Write-Host "OpenSSL not found! Please run win-download-openssl.ps1 and check if your platform is supported." + exit +} + +$env:BORG_OPENSSL_PREFIX = $opensslPath +$env:BORG_USE_BUNDLED_B2 = "YES" +$env:BORG_USE_BUNDLED_LZ4 = "YES" +$env:BORG_USE_BUNDLED_ZSTD = "YES" +$env:BORG_USE_BUNDLED_XXHASH = "YES" + +Write-Host "Environment configured for borg. The following variables where set:" +Write-Host ( Get-ChildItem Env: | Where-Object { $_.Name.StartsWith("BORG_") } | Out-String )