Merge pull request #4898 from requests/revert_azure
Before adoption: this commit came in with the history the project adopted, so no landing records it.
revert azure pipeline changes
authored by Nate Prewitt · committed by GitHub · parents 57d7284, 0dd4752 · Browse files · 8 files·+399 added−50 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+399 added−50 removed
- other:+399 added−50 removed
Provenance
- Commit
c35f342- Tree
6fb8853- Author
Nate Prewitt <nate.prewitt@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
57d7284- Parent 2
0dd4752
8 files changed+399 added−50 removed
added:_appveyor/install.ps1+229 added
1+# Sample script to install Python and pip under Windows2+# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer3+# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/4+5+$MINICONDA_URL = "http://repo.continuum.io/miniconda/"6+$BASE_URL = "https://www.python.org/ftp/python/"7+$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"8+$GET_PIP_PATH = "C:\get-pip.py"9+10+$PYTHON_PRERELEASE_REGEX = @"11+(?x)12+(?<major>\d+)13+\.14+(?<minor>\d+)15+\.16+(?<micro>\d+)17+(?<prerelease>[a-z]{1,2}\d+)18+"@19+20+21+function Download ($filename, $url) {22+ $webclient = New-Object System.Net.WebClient23+24+ $basedir = $pwd.Path + "\"25+ $filepath = $basedir + $filename26+ if (Test-Path $filename) {27+ Write-Host "Reusing" $filepath28+ return $filepath29+ }30+31+ # Download and retry up to 3 times in case of network transient errors.32+ Write-Host "Downloading" $filename "from" $url33+ $retry_attempts = 234+ for ($i = 0; $i -lt $retry_attempts; $i++) {35+ try {36+ $webclient.DownloadFile($url, $filepath)37+ break38+ }39+ Catch [Exception]{40+ Start-Sleep 141+ }42+ }43+ if (Test-Path $filepath) {44+ Write-Host "File saved at" $filepath45+ } else {46+ # Retry once to get the error message if any at the last try47+ $webclient.DownloadFile($url, $filepath)48+ }49+ return $filepath50+}51+52+53+function ParsePythonVersion ($python_version) {54+ if ($python_version -match $PYTHON_PRERELEASE_REGEX) {55+ return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro,56+ $matches.prerelease)57+ }58+ $version_obj = [version]$python_version59+ return ($version_obj.major, $version_obj.minor, $version_obj.build, "")60+}61+62+63+function DownloadPython ($python_version, $platform_suffix) {64+ $major, $minor, $micro, $prerelease = ParsePythonVersion $python_version65+66+ if (($major -le 2 -and $micro -eq 0) `67+ -or ($major -eq 3 -and $minor -le 2 -and $micro -eq 0) `68+ ) {69+ $dir = "$major.$minor"70+ $python_version = "$major.$minor$prerelease"71+ } else {72+ $dir = "$major.$minor.$micro"73+ }74+75+ if ($prerelease) {76+ if (($major -le 2) `77+ -or ($major -eq 3 -and $minor -eq 1) `78+ -or ($major -eq 3 -and $minor -eq 2) `79+ -or ($major -eq 3 -and $minor -eq 3) `80+ ) {81+ $dir = "$dir/prev"82+ }83+ }84+85+ if (($major -le 2) -or ($major -le 3 -and $minor -le 4)) {86+ $ext = "msi"87+ if ($platform_suffix) {88+ $platform_suffix = ".$platform_suffix"89+ }90+ } else {91+ $ext = "exe"92+ if ($platform_suffix) {93+ $platform_suffix = "-$platform_suffix"94+ }95+ }96+97+ $filename = "python-$python_version$platform_suffix.$ext"98+ $url = "$BASE_URL$dir/$filename"99+ $filepath = Download $filename $url100+ return $filepath101+}102+103+104+function InstallPython ($python_version, $architecture, $python_home) {105+ Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home106+ if (Test-Path $python_home) {107+ Write-Host $python_home "already exists, skipping."108+ return $false109+ }110+ if ($architecture -eq "32") {111+ $platform_suffix = ""112+ } else {113+ $platform_suffix = "amd64"114+ }115+ $installer_path = DownloadPython $python_version $platform_suffix116+ $installer_ext = [System.IO.Path]::GetExtension($installer_path)117+ Write-Host "Installing $installer_path to $python_home"118+ $install_log = $python_home + ".log"119+ if ($installer_ext -eq '.msi') {120+ InstallPythonMSI $installer_path $python_home $install_log121+ } else {122+ InstallPythonEXE $installer_path $python_home $install_log123+ }124+ if (Test-Path $python_home) {125+ Write-Host "Python $python_version ($architecture) installation complete"126+ } else {127+ Write-Host "Failed to install Python in $python_home"128+ Get-Content -Path $install_log129+ Exit 1130+ }131+}132+133+134+function InstallPythonEXE ($exepath, $python_home, $install_log) {135+ $install_args = "/quiet InstallAllUsers=1 TargetDir=$python_home"136+ RunCommand $exepath $install_args137+}138+139+140+function InstallPythonMSI ($msipath, $python_home, $install_log) {141+ $install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home"142+ $uninstall_args = "/qn /x $msipath"143+ RunCommand "msiexec.exe" $install_args144+ if (-not(Test-Path $python_home)) {145+ Write-Host "Python seems to be installed else-where, reinstalling."146+ RunCommand "msiexec.exe" $uninstall_args147+ RunCommand "msiexec.exe" $install_args148+ }149+}150+151+function RunCommand ($command, $command_args) {152+ Write-Host $command $command_args153+ Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru154+}155+156+157+function InstallPip ($python_home) {158+ $pip_path = $python_home + "\Scripts\pip.exe"159+ $python_path = $python_home + "\python.exe"160+ if (-not(Test-Path $pip_path)) {161+ Write-Host "Installing pip..."162+ $webclient = New-Object System.Net.WebClient163+ $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)164+ Write-Host "Executing:" $python_path $GET_PIP_PATH165+ & $python_path $GET_PIP_PATH166+ } else {167+ Write-Host "pip already installed."168+ }169+}170+171+172+function DownloadMiniconda ($python_version, $platform_suffix) {173+ if ($python_version -eq "3.4") {174+ $filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe"175+ } else {176+ $filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe"177+ }178+ $url = $MINICONDA_URL + $filename179+ $filepath = Download $filename $url180+ return $filepath181+}182+183+184+function InstallMiniconda ($python_version, $architecture, $python_home) {185+ Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home186+ if (Test-Path $python_home) {187+ Write-Host $python_home "already exists, skipping."188+ return $false189+ }190+ if ($architecture -eq "32") {191+ $platform_suffix = "x86"192+ } else {193+ $platform_suffix = "x86_64"194+ }195+ $filepath = DownloadMiniconda $python_version $platform_suffix196+ Write-Host "Installing" $filepath "to" $python_home197+ $install_log = $python_home + ".log"198+ $args = "/S /D=$python_home"199+ Write-Host $filepath $args200+ Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru201+ if (Test-Path $python_home) {202+ Write-Host "Python $python_version ($architecture) installation complete"203+ } else {204+ Write-Host "Failed to install Python in $python_home"205+ Get-Content -Path $install_log206+ Exit 1207+ }208+}209+210+211+function InstallMinicondaPip ($python_home) {212+ $pip_path = $python_home + "\Scripts\pip.exe"213+ $conda_path = $python_home + "\Scripts\conda.exe"214+ if (-not(Test-Path $pip_path)) {215+ Write-Host "Installing pip..."216+ $args = "install --yes pip"217+ Write-Host $conda_path $args218+ Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru219+ } else {220+ Write-Host "pip already installed."221+ }222+}223+224+function main () {225+ InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON226+ InstallPip $env:PYTHON227+}228+229+mainadded:_azure-pipelines/template-linux.yml+33 added
123456789101112131415161718192021222324252627282930313233jobs:- job: Linux pool: vmImage: 'Ubuntu-16.04' strategy: matrix: Python27: PYTHON_VERSION: '2.7' Python34: PYTHON_VERSION: '3.4' Python35: PYTHON_VERSION: '3.5' Python36: PYTHON_VERSION: '3.6' Python37: PYTHON_VERSION: '3.7' steps: - task: UsePythonVersion@0 inputs: versionSpec: $(PYTHON_VERSION) displayName: 'Install Python' - script: | make make test-readme make ci - script: | pipenv run codecov displayName: 'Coverage' - task: PublishTestResults@2 displayName: 'Publish test results' inputs: testResultsFiles: 'report.xml' testRunTitle: Python $(PYTHON_VERSION) added:_azure-pipelines/template-windows.yml+36 added
123456789101112131415161718192021222324252627282930313233343536jobs:- job: Windows pool: vmImage: 'vs2017-win2016' strategy: matrix: Python27: PYTHON_VERSION: '2.7' Python34: PYTHON_VERSION: '3.4' Python35: PYTHON_VERSION: '3.5' Python36: PYTHON_VERSION: '3.6' Python37: PYTHON_VERSION: '3.7' steps: - task: UsePythonVersion@0 inputs: versionSpec: $(PYTHON_VERSION) architecture: 'x64' displayName: 'Install Python' - script: | make init python -m pip install --upgrade pip wheel displayName: 'Ensure latest' - script: | make pipenv install -e .[socks] --skip-lock - script: | make coverage displayName: 'Test script' - script: | pipenv run codecov -f coverage.xml displayName: 'Coverage'
deleted:_azure-pipelines/template.yml-41 removed
1234567891011121314151617181920212223242526272829303132333435363738394041jobs:- job: ${{ parameters.name }} pool: vmImage: ${{ parameters.vmImage }} strategy: matrix: Python27: PYTHON_VERSION: '2.7' Python34: PYTHON_VERSION: '3.4' Python35: PYTHON_VERSION: '3.5' Python36: PYTHON_VERSION: '3.6' Python37: PYTHON_VERSION: '3.7' steps: - task: UsePythonVersion@0 inputs: versionSpec: $(PYTHON_VERSION) architecture: 'x64' displayName: 'Install Python' - script: | make pipenv install -e .[socks] --skip-lock displayName: 'Set up'
- ${{ if eq(parameters.name, 'Linux') }}: - script: | make test-readme make ci displayName: 'Test and CI' - task: PublishTestResults@2 displayName: 'Publish test results' inputs: testResultsFiles: 'report.xml' testRunTitle: Python $(PYTHON_VERSION)
- script: | pipenv run codecov -f coverage.xml displayName: 'Run codecov'added:.travis.yml+42 added
123456789101112131415161718192021222324252627282930313233343536373839404142sudo: falselanguage: python# command to install dependenciesinstall: "make"# command to run testsscript: - | if [[ "$TRAVIS_PYTHON_VERSION" != "2.6" ]] ; then make test-readme; fi - make cicache: pipjobs: include: - stage: test script: - make test-readme - make ci python: '2.7' - stage: test script: - make test-readme - make ci python: '3.4' - stage: test script: - make test-readme - make ci python: '3.5' - stage: test script: - make test-readme - make ci python: '3.6' - stage: test script: - make test-readme - make ci python: '3.7' dist: xenial sudo: true - stage: coverage python: 3.6 script: codecovadded:appveyor.yml+57 added
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657# AppVeyor.yml from https://github.com/ogrisel/python-appveyor-demo# License: CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/
build: off
environment: matrix: - PYTHON: "C:\\Python27-x64" PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "64" TOXENV: "py27"
- PYTHON: "C:\\Python34-x64" PYTHON_VERSION: "3.4.x" PYTHON_ARCH: "64" TOXENV: "py34"
- PYTHON: "C:\\Python35-x64" PYTHON_VERSION: "3.5.x" PYTHON_ARCH: "64" TOXENV: "py35"
- PYTHON: "C:\\Python36-x64" PYTHON_VERSION: "3.6.x" PYTHON_ARCH: "64" TOXENV: "py36"
- PYTHON: "C:\\Python37-x64" PYTHON_VERSION: "3.7.x" PYTHON_ARCH: "64" TOXENV: "py37"
install: # Install Python (from the official .msi of https://www.python.org/) and pip when # not already installed. - ps: if (-not(Test-Path($env:PYTHON))) { & _appveyor\install.ps1 }
# Prepend newly installed Python to the PATH of this build (this cannot be # done from inside the powershell script as it would require to restart # the parent CMD process). - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
# Check that we have the expected version and architecture for Python - "python --version" - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
# Upgrade to the latest version of pip to avoid it displaying warnings # about it being out of date. - "python -m pip install --upgrade pip wheel" - "C:\\MinGW\\bin\\mingw32-make" - "pipenv install -e .[socks] --skip-lock"
test_script: - "C:\\MinGW\\bin\\mingw32-make coverage"
on_success: - "pipenv run codecov -f coverage.xml"modified:azure-pipelines.yml+2 added-8 removed
1234523789104jobs:- template: _azure-pipelines/template.yml parameters: name: Linux vmImage: Ubuntu-16.04- template: _azure-pipelines/template-linux.yml
- template: _azure-pipelines/template.yml parameters: name: Windows vmImage: vs2017-win2016No newline at end of file- template: _azure-pipelines/template-windows.ymlmodified:README.md-1 removed
5 unmodified lines6 [](https://pypi.org/project/requests/)7 [](https://codecov.io/github/requests/requests)8 [](https://github.com/requests/requests/graphs/contributors)9 [](https://saythanks.io/to/kennethreitz)10-[](https://kennethreitz.visualstudio.com/requests/_build/latest?definitionId=1)10 11 **If you're interested in financially supporting Kenneth Reitz open source, consider [visiting this link](https://cash.me/$KennethReitz). Your support helps tremendously with sustainability of motivation, as Open Source is no longer part of my day job.**12 13 Requests is the only *Non-GMO* HTTP library for Python, safe for human94 unmodified lines