install-pip.ps1 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # The code lines below are derived from -
  17. # https://github.com/docker-library/python/blob/105d6f34e7d70aad6f8c3e249b8208efa591916a/3.11/windows/windowsservercore-ltsc2022/Dockerfile
  18. Write-Host ('Downloading get-pip.py ({0}) ...' -f $Env:PYTHON_GET_PIP_URL)
  19. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  20. Invoke-WebRequest -Uri $Env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'
  21. Write-Host ('Verifying sha256 ({0}) ...' -f $Env:PYTHON_GET_PIP_SHA256)
  22. if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $Env:PYTHON_GET_PIP_SHA256) {
  23. Write-Host 'FAILED!'
  24. exit 1
  25. }
  26. $Env:PYTHONDONTWRITEBYTECODE = '1'
  27. Write-Host ('Installing pip=={0} ...' -f $Env:PYTHON_PIP_VERSION)
  28. python get-pip.py `
  29. --disable-pip-version-check `
  30. --no-cache-dir `
  31. --no-compile `
  32. ('pip=={0}' -f $Env:PYTHON_PIP_VERSION) `
  33. ('setuptools=={0}' -f $Env:PYTHON_SETUPTOOLS_VERSION)
  34. Remove-Item get-pip.py -Force
  35. Write-Host 'Verifying pip install ...'
  36. pip --version
  37. Write-Host 'Complete.'