mirror of
https://github.com/google/brotli.git
synced 2024-12-26 17:51:04 +00:00
[appveyor] properly support Python 3.5
This commit is contained in:
parent
d5f23833de
commit
e34949d1b9
@ -22,12 +22,10 @@ environment:
|
|||||||
- PYTHON: "C:\\Python27-x64"
|
- PYTHON: "C:\\Python27-x64"
|
||||||
PYTHON_VERSION: "2.7.x"
|
PYTHON_VERSION: "2.7.x"
|
||||||
PYTHON_ARCH: "64"
|
PYTHON_ARCH: "64"
|
||||||
WINDOWS_SDK_VERSION: "v7.0"
|
|
||||||
|
|
||||||
- PYTHON: "C:\\Python34-x64"
|
- PYTHON: "C:\\Python34-x64"
|
||||||
PYTHON_VERSION: "3.4.x"
|
PYTHON_VERSION: "3.4.x"
|
||||||
PYTHON_ARCH: "64"
|
PYTHON_ARCH: "64"
|
||||||
WINDOWS_SDK_VERSION: "v7.1"
|
|
||||||
|
|
||||||
- PYTHON: "C:\\Python35-x64"
|
- PYTHON: "C:\\Python35-x64"
|
||||||
PYTHON_VERSION: "3.5.0"
|
PYTHON_VERSION: "3.5.0"
|
||||||
|
@ -1,16 +1,26 @@
|
|||||||
# Sample script to install Python and pip under Windows
|
# Sample script to install Python and pip under Windows
|
||||||
# Authors: Olivier Grisel and Kyle Kastner
|
# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer
|
||||||
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
|
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
# Source: https://github.com/ogrisel/python-appveyor-demo/blob/master/appveyor/install.ps1
|
||||||
|
|
||||||
|
$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
|
||||||
$BASE_URL = "https://www.python.org/ftp/python/"
|
$BASE_URL = "https://www.python.org/ftp/python/"
|
||||||
$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
|
$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
|
||||||
$GET_PIP_PATH = "C:\get-pip.py"
|
$GET_PIP_PATH = "C:\get-pip.py"
|
||||||
|
|
||||||
|
$PYTHON_PRERELEASE_REGEX = @"
|
||||||
|
(?x)
|
||||||
|
(?<major>\d+)
|
||||||
|
\.
|
||||||
|
(?<minor>\d+)
|
||||||
|
\.
|
||||||
|
(?<micro>\d+)
|
||||||
|
(?<prerelease>[a-z]{1,2}\d+)
|
||||||
|
"@
|
||||||
|
|
||||||
function DownloadPython ($python_version, $platform_suffix) {
|
|
||||||
|
function Download ($filename, $url) {
|
||||||
$webclient = New-Object System.Net.WebClient
|
$webclient = New-Object System.Net.WebClient
|
||||||
$filename = "python-" + $python_version + $platform_suffix + ".msi"
|
|
||||||
$url = $BASE_URL + $python_version + "/" + $filename
|
|
||||||
|
|
||||||
$basedir = $pwd.Path + "\"
|
$basedir = $pwd.Path + "\"
|
||||||
$filepath = $basedir + $filename
|
$filepath = $basedir + $filename
|
||||||
@ -19,10 +29,10 @@ function DownloadPython ($python_version, $platform_suffix) {
|
|||||||
return $filepath
|
return $filepath
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download and retry up to 5 times in case of network transient errors.
|
# Download and retry up to 3 times in case of network transient errors.
|
||||||
Write-Host "Downloading" $filename "from" $url
|
Write-Host "Downloading" $filename "from" $url
|
||||||
$retry_attempts = 3
|
$retry_attempts = 2
|
||||||
for($i=0; $i -lt $retry_attempts; $i++){
|
for ($i = 0; $i -lt $retry_attempts; $i++) {
|
||||||
try {
|
try {
|
||||||
$webclient.DownloadFile($url, $filepath)
|
$webclient.DownloadFile($url, $filepath)
|
||||||
break
|
break
|
||||||
@ -30,9 +40,65 @@ function DownloadPython ($python_version, $platform_suffix) {
|
|||||||
Catch [Exception]{
|
Catch [Exception]{
|
||||||
Start-Sleep 1
|
Start-Sleep 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host "File saved at" $filepath
|
if (Test-Path $filepath) {
|
||||||
return $filepath
|
Write-Host "File saved at" $filepath
|
||||||
|
} else {
|
||||||
|
# Retry once to get the error message if any at the last try
|
||||||
|
$webclient.DownloadFile($url, $filepath)
|
||||||
|
}
|
||||||
|
return $filepath
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function ParsePythonVersion ($python_version) {
|
||||||
|
if ($python_version -match $PYTHON_PRERELEASE_REGEX) {
|
||||||
|
return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro,
|
||||||
|
$matches.prerelease)
|
||||||
|
}
|
||||||
|
$version_obj = [version]$python_version
|
||||||
|
return ($version_obj.major, $version_obj.minor, $version_obj.build, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function DownloadPython ($python_version, $platform_suffix) {
|
||||||
|
$major, $minor, $micro, $prerelease = ParsePythonVersion $python_version
|
||||||
|
|
||||||
|
if (($major -le 2 -and $micro -eq 0) `
|
||||||
|
-or ($major -eq 3 -and $minor -le 2 -and $micro -eq 0) `
|
||||||
|
) {
|
||||||
|
$dir = "$major.$minor"
|
||||||
|
$python_version = "$major.$minor$prerelease"
|
||||||
|
} else {
|
||||||
|
$dir = "$major.$minor.$micro"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($prerelease) {
|
||||||
|
if (($major -le 2) `
|
||||||
|
-or ($major -eq 3 -and $minor -eq 1) `
|
||||||
|
-or ($major -eq 3 -and $minor -eq 2) `
|
||||||
|
-or ($major -eq 3 -and $minor -eq 3) `
|
||||||
|
) {
|
||||||
|
$dir = "$dir/prev"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($major -le 2) -or ($major -le 3 -and $minor -le 4)) {
|
||||||
|
$ext = "msi"
|
||||||
|
if ($platform_suffix) {
|
||||||
|
$platform_suffix = ".$platform_suffix"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$ext = "exe"
|
||||||
|
if ($platform_suffix) {
|
||||||
|
$platform_suffix = "-$platform_suffix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = "python-$python_version$platform_suffix.$ext"
|
||||||
|
$url = "$BASE_URL$dir/$filename"
|
||||||
|
$filepath = Download $filename $url
|
||||||
|
return $filepath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,41 +111,120 @@ function InstallPython ($python_version, $architecture, $python_home) {
|
|||||||
if ($architecture -eq "32") {
|
if ($architecture -eq "32") {
|
||||||
$platform_suffix = ""
|
$platform_suffix = ""
|
||||||
} else {
|
} else {
|
||||||
$platform_suffix = ".amd64"
|
$platform_suffix = "amd64"
|
||||||
}
|
}
|
||||||
$filepath = DownloadPython $python_version $platform_suffix
|
$installer_path = DownloadPython $python_version $platform_suffix
|
||||||
Write-Host "Installing" $filepath "to" $python_home
|
$installer_ext = [System.IO.Path]::GetExtension($installer_path)
|
||||||
$args = "/qn /i $filepath TARGETDIR=$python_home"
|
Write-Host "Installing $installer_path to $python_home"
|
||||||
Write-Host "msiexec.exe" $args
|
$install_log = $python_home + ".log"
|
||||||
Start-Process -FilePath "msiexec.exe" -ArgumentList $args -Wait -Passthru
|
if ($installer_ext -eq '.msi') {
|
||||||
Write-Host "Python $python_version ($architecture) installation complete"
|
InstallPythonMSI $installer_path $python_home $install_log
|
||||||
return $true
|
} else {
|
||||||
|
InstallPythonEXE $installer_path $python_home $install_log
|
||||||
|
}
|
||||||
|
if (Test-Path $python_home) {
|
||||||
|
Write-Host "Python $python_version ($architecture) installation complete"
|
||||||
|
} else {
|
||||||
|
Write-Host "Failed to install Python in $python_home"
|
||||||
|
Get-Content -Path $install_log
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function InstallPythonEXE ($exepath, $python_home, $install_log) {
|
||||||
|
$install_args = "/quiet InstallAllUsers=1 TargetDir=$python_home"
|
||||||
|
RunCommand $exepath $install_args
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function InstallPythonMSI ($msipath, $python_home, $install_log) {
|
||||||
|
$install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home"
|
||||||
|
$uninstall_args = "/qn /x $msipath"
|
||||||
|
RunCommand "msiexec.exe" $install_args
|
||||||
|
if (-not(Test-Path $python_home)) {
|
||||||
|
Write-Host "Python seems to be installed else-where, reinstalling."
|
||||||
|
RunCommand "msiexec.exe" $uninstall_args
|
||||||
|
RunCommand "msiexec.exe" $install_args
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function RunCommand ($command, $command_args) {
|
||||||
|
Write-Host $command $command_args
|
||||||
|
Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function InstallPip ($python_home) {
|
function InstallPip ($python_home) {
|
||||||
$pip_path = $python_home + "/Scripts/pip.exe"
|
$pip_path = $python_home + "\Scripts\pip.exe"
|
||||||
$python_path = $python_home + "/python.exe"
|
$python_path = $python_home + "\python.exe"
|
||||||
if (-not(Test-Path $pip_path)) {
|
if (-not(Test-Path $pip_path)) {
|
||||||
Write-Host "Installing pip..."
|
Write-Host "Installing pip..."
|
||||||
$webclient = New-Object System.Net.WebClient
|
$webclient = New-Object System.Net.WebClient
|
||||||
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
|
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
|
||||||
Write-Host "Executing:" $python_path $GET_PIP_PATH
|
Write-Host "Executing:" $python_path $GET_PIP_PATH
|
||||||
Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru
|
& $python_path $GET_PIP_PATH
|
||||||
} else {
|
} else {
|
||||||
Write-Host "pip already installed."
|
Write-Host "pip already installed."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallPackage ($python_home, $pkg) {
|
|
||||||
$pip_path = $python_home + "/Scripts/pip.exe"
|
function DownloadMiniconda ($python_version, $platform_suffix) {
|
||||||
& $pip_path install $pkg
|
if ($python_version -eq "3.4") {
|
||||||
|
$filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe"
|
||||||
|
} else {
|
||||||
|
$filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe"
|
||||||
|
}
|
||||||
|
$url = $MINICONDA_URL + $filename
|
||||||
|
$filepath = Download $filename $url
|
||||||
|
return $filepath
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function InstallMiniconda ($python_version, $architecture, $python_home) {
|
||||||
|
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
|
||||||
|
if (Test-Path $python_home) {
|
||||||
|
Write-Host $python_home "already exists, skipping."
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
if ($architecture -eq "32") {
|
||||||
|
$platform_suffix = "x86"
|
||||||
|
} else {
|
||||||
|
$platform_suffix = "x86_64"
|
||||||
|
}
|
||||||
|
$filepath = DownloadMiniconda $python_version $platform_suffix
|
||||||
|
Write-Host "Installing" $filepath "to" $python_home
|
||||||
|
$install_log = $python_home + ".log"
|
||||||
|
$args = "/S /D=$python_home"
|
||||||
|
Write-Host $filepath $args
|
||||||
|
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
|
||||||
|
if (Test-Path $python_home) {
|
||||||
|
Write-Host "Python $python_version ($architecture) installation complete"
|
||||||
|
} else {
|
||||||
|
Write-Host "Failed to install Python in $python_home"
|
||||||
|
Get-Content -Path $install_log
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function InstallMinicondaPip ($python_home) {
|
||||||
|
$pip_path = $python_home + "\Scripts\pip.exe"
|
||||||
|
$conda_path = $python_home + "\Scripts\conda.exe"
|
||||||
|
if (-not(Test-Path $pip_path)) {
|
||||||
|
Write-Host "Installing pip..."
|
||||||
|
$args = "install --yes pip"
|
||||||
|
Write-Host $conda_path $args
|
||||||
|
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
|
||||||
|
} else {
|
||||||
|
Write-Host "pip already installed."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function main () {
|
function main () {
|
||||||
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
|
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
|
||||||
InstallPip $env:PYTHON
|
InstallPip $env:PYTHON
|
||||||
InstallPackage $env:PYTHON wheel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
@ -6,7 +6,8 @@
|
|||||||
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
|
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
|
||||||
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
|
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
|
||||||
::
|
::
|
||||||
:: 32 bit builds do not require specific environment configurations.
|
:: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific
|
||||||
|
:: environment configurations.
|
||||||
::
|
::
|
||||||
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
|
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
|
||||||
:: cmd interpreter, at least for (SDK v7.0)
|
:: cmd interpreter, at least for (SDK v7.0)
|
||||||
@ -15,31 +16,63 @@
|
|||||||
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
|
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
|
||||||
:: http://stackoverflow.com/a/13751649/163740
|
:: http://stackoverflow.com/a/13751649/163740
|
||||||
::
|
::
|
||||||
|
:: Original source:
|
||||||
|
:: https://github.com/ogrisel/python-appveyor-demo/blob/master/appveyor/run_with_env.cmd
|
||||||
|
::
|
||||||
:: Author: Olivier Grisel
|
:: Author: Olivier Grisel
|
||||||
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
|
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
|
|
||||||
SET COMMAND_TO_RUN=%*
|
SET COMMAND_TO_RUN=%*
|
||||||
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
|
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
|
||||||
|
SET WIN_WDK=c:\Program Files (x86)\Windows Kits\10\Include\wdf
|
||||||
|
|
||||||
SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
|
:: Extract the major and minor versions, and allow for the minor version to be
|
||||||
IF %MAJOR_PYTHON_VERSION% == "2" (
|
:: more than 9. This requires the version number to have two dots in it.
|
||||||
SET WINDOWS_SDK_VERSION="v7.1"
|
SET MAJOR_PYTHON_VERSION=%PYTHON_VERSION:~0,1%
|
||||||
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
|
IF "%PYTHON_VERSION:~3,1%" == "." (
|
||||||
SET WINDOWS_SDK_VERSION="v7.1"
|
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1%
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
|
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,2%
|
||||||
EXIT 1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
IF "%PYTHON_ARCH%"=="64" (
|
:: Based on the Python version, determine what SDK version to use, and whether
|
||||||
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
|
:: to set the SDK for 64-bit.
|
||||||
SET DISTUTILS_USE_SDK=1
|
IF %MAJOR_PYTHON_VERSION% == 2 (
|
||||||
SET MSSdk=1
|
SET WINDOWS_SDK_VERSION="v7.0"
|
||||||
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
|
SET SET_SDK_64=Y
|
||||||
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
|
) ELSE (
|
||||||
ECHO Executing: %COMMAND_TO_RUN%
|
IF %MAJOR_PYTHON_VERSION% == 3 (
|
||||||
call %COMMAND_TO_RUN% || EXIT 1
|
SET WINDOWS_SDK_VERSION="v7.1"
|
||||||
|
IF %MINOR_PYTHON_VERSION% LEQ 4 (
|
||||||
|
SET SET_SDK_64=Y
|
||||||
|
) ELSE (
|
||||||
|
SET SET_SDK_64=N
|
||||||
|
IF EXIST "%WIN_WDK%" (
|
||||||
|
:: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/
|
||||||
|
REN "%WIN_WDK%" 0wdf
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) ELSE (
|
||||||
|
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
|
||||||
|
EXIT 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
IF %PYTHON_ARCH% == 64 (
|
||||||
|
IF %SET_SDK_64% == Y (
|
||||||
|
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
|
||||||
|
SET DISTUTILS_USE_SDK=1
|
||||||
|
SET MSSdk=1
|
||||||
|
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
|
||||||
|
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
|
||||||
|
ECHO Executing: %COMMAND_TO_RUN%
|
||||||
|
call %COMMAND_TO_RUN% || EXIT 1
|
||||||
|
) ELSE (
|
||||||
|
ECHO Using default MSVC build environment for 64 bit architecture
|
||||||
|
ECHO Executing: %COMMAND_TO_RUN%
|
||||||
|
call %COMMAND_TO_RUN% || EXIT 1
|
||||||
|
)
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO Using default MSVC build environment for 32 bit architecture
|
ECHO Using default MSVC build environment for 32 bit architecture
|
||||||
ECHO Executing: %COMMAND_TO_RUN%
|
ECHO Executing: %COMMAND_TO_RUN%
|
||||||
|
Loading…
Reference in New Issue
Block a user