Skip to content

Instantly share code, notes, and snippets.

@dwoz
Last active September 21, 2018 19:03
Show Gist options
  • Save dwoz/03f156c78ca3634ee9a9140aa4617e22 to your computer and use it in GitHub Desktop.
Save dwoz/03f156c78ca3634ee9a9140aa4617e22 to your computer and use it in GitHub Desktop.
function Build-M2 {
Param(
[parameter(Mandatory=$true)]
[String]
$PythonExe
)
if ( -not (Get-Command choco -errorAction SilentlyContinue )) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
choco install -y curl
choco install -y swig
choco install -y git
$PyVersion = $( & $pythonExe --version 2>&1 ).ToString().Split('; Python')[-1].Split('.')
if ($PyVersion[0] -eq 2) {
choco install -y vcpython27
} else {
choco install -y vcbuildtools -ia "Full"
}
$opensslDir="C:\OpenSSL"
if ( $(& $pythonExe -c "import struct;print( 8 * struct.calcsize('P'))").tostring().trim() -eq 64) {
$opensslInstaller="Win64OpenSSL-1_1_0i.exe"
} else {
$opensslInstaller="Win32OpenSSL-1_1_0i.exe"
}
curl.exe -o c:\\$opensslInstaller -fsSL https://slproweb.com/download/$opensslInstaller
& c:\\$opensslInstaller /silent /verysilent /DIR=$opensslDir
$pyDir = Split-Path $pythonExe
$pipDir = Join-Path "$pyDir" Scripts
#cd $pipDir
$pipExe = Join-Path "$pipDir" pip.exe
& $pipExe install wheel
& $pipExe download M2crypto
& $pythonExe -c "import gzip, tarfile;tarfile.TarFile(fileobj=gzip.open('m2crypto-0.30.1.tar.gz')).extractall()"
cd m2crypto-*
& $pythonExe setup.py clean build --openssl=$opensslDir --bundledlls
& $pythonExe setup.py bdist_wheel bdist_wininst bdist_msi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment