Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3.9 Support #174

Merged
merged 15 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .azure-pipelines/client.test.live.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ variables:
PythonVersion36: '3.6'
PythonVersion37: '3.7'
PythonVersion38: '3.8'
PythonVersion39: '3.9.0'

jobs:
- job: 'Windows'
Expand Down Expand Up @@ -34,6 +35,9 @@ jobs:
x64 Python 3.8:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion38)'
x64 Python 3.9:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion39)'
x86 Python 2.7:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion27)'
Expand All @@ -49,11 +53,13 @@ jobs:
x86 Python 3.8:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion38)'
x86 Python 3.9:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion39)'

steps:
- task: UsePythonVersion@0
displayName: 'Use Python Version'
inputs:
- template: /.azure-pipelines/wrapped-use-python.yml
parameters:
architecture: '$(PythonArchitecture)'
versionSpec: '$(PythonVersion)'

Expand Down Expand Up @@ -139,6 +145,9 @@ jobs:
Python 3.8:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion38)'
Python 3.9:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion39)'

variables:
MacOSXDeploymentTarget: '10.9'
Expand All @@ -148,6 +157,7 @@ jobs:
PythonVersion36: '3.6.8'
PythonVersion37: '3.7.6'
PythonVersion38: '3.8.2'
PythonVersion39: '3.9.0'

steps:
- task: DownloadPipelineArtifact@1
Expand Down Expand Up @@ -249,11 +259,12 @@ jobs:
PythonVersion: '$(PythonVersion37)'
Python 3.8:
PythonVersion: '$(PythonVersion38)'
Python 3.9:
PythonVersion: '$(PythonVersion39)'

steps:
- task: UsePythonVersion@0
displayName: 'Use Python Version'
inputs:
- template: /.azure-pipelines/wrapped-use-python.yml
parameters:
versionSpec: '$(PythonVersion)'

- script: |
Expand Down
36 changes: 27 additions & 9 deletions .azure-pipelines/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ variables:
PythonVersion36: '3.6'
PythonVersion37: '3.7'
PythonVersion38: '3.8'
PythonVersion39: '3.9.0'

jobs:
- job: 'sdist'
Expand All @@ -16,9 +17,8 @@ jobs:
vmImage: 'ubuntu-18.04'

steps:
- task: UsePythonVersion@0
displayName: 'Use Python Version'
inputs:
- template: /.azure-pipelines/wrapped-use-python.yml
parameters:
versionSpec: '$(PythonVersion37)'

- script: |
Expand Down Expand Up @@ -65,6 +65,9 @@ jobs:
Python 3.8:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion38)'
Python 3.9:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion39)'

variables:
MacOSXDeploymentTarget: '10.9'
Expand All @@ -74,6 +77,7 @@ jobs:
PythonVersion36: '3.6.8'
PythonVersion37: '3.7.6'
PythonVersion38: '3.8.2'
PythonVersion39: '3.9.0'

steps:
- task: DownloadPipelineArtifact@1
Expand Down Expand Up @@ -164,6 +168,9 @@ jobs:
x64 Python 3.8:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion38)'
x64 Python 3.9:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion39)'
x86 Python 2.7:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion27)'
Expand All @@ -179,11 +186,13 @@ jobs:
x86 Python 3.8:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion38)'
x86 Python 3.9:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion39)'

steps:
- task: UsePythonVersion@0
displayName: 'Use Python Version'
inputs:
- template: /.azure-pipelines/wrapped-use-python.yml
parameters:
architecture: '$(PythonArchitecture)'
versionSpec: '$(PythonVersion)'

Expand Down Expand Up @@ -248,11 +257,12 @@ jobs:
PythonVersion: '$(PythonVersion37)'
Python 3.8:
PythonVersion: '$(PythonVersion38)'
Python 3.9:
PythonVersion: '$(PythonVersion39)'

steps:
- task: UsePythonVersion@0
displayName: 'Use Python Version'
inputs:
- template: /.azure-pipelines/wrapped-use-python.yml
parameters:
versionSpec: '$(PythonVersion)'

- script: |
Expand Down Expand Up @@ -327,6 +337,10 @@ jobs:
ContainerImage: 'manylinux_crypto_x64'
PythonVersion: 'cp38-cp38'
Platform: 'manylinux1_x86_64'
Python39-manylinux1:
ContainerImage: 'manylinux_crypto_x64'
PythonVersion: 'cp39-cp39'
Platform: 'manylinux1_x86_64'
Python27m-manylinux2010:
ContainerImage: 'manylinux2010_crypto_x64'
PythonVersion: 'cp27-cp27m'
Expand All @@ -351,6 +365,10 @@ jobs:
ContainerImage: 'manylinux2010_crypto_x64'
PythonVersion: 'cp38-cp38'
Platform: 'manylinux2010_x86_64'
Python39-manylinux2010:
ContainerImage: 'manylinux2010_crypto_x64'
PythonVersion: 'cp39-cp39'
Platform: 'manylinux2010_x86_64'

steps:
- task: Docker@1
Expand Down
158 changes: 158 additions & 0 deletions .azure-pipelines/resolve_installer_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import platform
import json
import argparse
import urllib
import urllib.request
from subprocess import check_call, CalledProcessError
import sys
import os
import zipfile
import tarfile
import time

from packaging.version import Version
from packaging.version import parse
from packaging.version import InvalidVersion

import pdb

# SOURCE OF THIS FILE: https://github.com/actions/python-versions
# this is the official mapping file for gh-actions to retrieve python installers
MANIFEST_LOCATION = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json"

MAX_INSTALLER_RETRY = 3
CURRENT_UBUNTU_VERSION = "18.04" # full title is ubuntu-18.04

UNIX_INSTALL_ARRAY = ["sh", "setup.sh"]
WIN_INSTALL_ARRAY = ["pwsh", "setup.ps1"]


def download_installer(remote_path, local_path):
retries = 0

while True:
try:
urllib.request.urlretrieve(remote_path, local_path)
break
except Exception as e:
print(e)
retries += 1

if retries >= MAX_INSTALLER_RETRY:
print(
"Unable to recover after attempting to download {} {} times".format(
remote_path, retries
)
)
exit(1)
time.sleep(10)


def install_selected_python_version(installer_url, installer_folder):
current_plat = platform.system().lower()

installer_folder = os.path.normpath(os.path.abspath(installer_folder))
if not os.path.exists(installer_folder):
os.mkdir(installer_folder)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to handle any permissions issues on the installation directory? Or just let them raise?

Copy link
Contributor Author

@yunhaoling yunhaoling Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the answer, the scripts are provided by Scott. (to be more precise, scripts are here in our mono repo: Azure/azure-sdk-for-python#14160)
but I think he should have already taken it into account :P cc @scbedd

local_installer_ref = os.path.join(
installer_folder,
"local" + (".zip" if installer_folder.endswith("zip") else ".tar.gz"),
)

download_installer(installer_url, local_installer_ref)

if current_plat == "windows":
with zipfile.ZipFile(local_installer_ref, "r") as zip_file:
zip_file.extractall(installer_folder)
try:
check_call(WIN_INSTALL_ARRAY, cwd=installer_folder)
except CalledProcessError as err:
print(err)
exit(1)

else:
with tarfile.open(local_installer_ref) as tar_file:
tar_file.extractall(installer_folder)
try:
check_call(UNIX_INSTALL_ARRAY, cwd=installer_folder)
except CalledProcessError as err:
print(err)
exit(1)


def get_installer_url(requested_version, version_manifest):
current_plat = platform.system().lower()

print("Current Platform Is {}".format(platform.platform()))

if version_manifest[requested_version]:
found_installers = version_manifest[requested_version]["files"]

# filter anything that's not x64. we don't care.
x64_installers = [
file_def for file_def in found_installers if file_def["arch"] == "x64"
]

if current_plat == "windows":
return [
installer
for installer in x64_installers
if installer["platform"] == "win32"
][0]
elif current_plat == "darwin":
return [
installer
for installer in x64_installers
if installer["platform"] == current_plat
][0]
else:
return [
installer
for installer in x64_installers
if installer["platform"] == "linux"
and installer["platform_version"] == CURRENT_UBUNTU_VERSION
][0]


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Takes the incoming request and attempts to resolve the version spec."
)

parser.add_argument(
"version_spec",
nargs="?",
help=("The version specifier passed in to the UsePythonVersion extended task."),
)

parser.add_argument(
"--installer_folder",
dest="installer_folder",
help=(
"The folder where the found installer will be extracted into and run from."
),
)

args = parser.parse_args()
max_precached_version = Version("3.8.6")
try:
version_from_spec = Version(args.version_spec)
except InvalidVersion:
print("Invalid Version Spec. Skipping custom install.")
exit(0)

with urllib.request.urlopen(MANIFEST_LOCATION) as url:
version_manifest = json.load(url)

version_dict = {i["version"]: i for i in version_manifest}

if version_from_spec > max_precached_version:
print(
"Requested version {} is newer than versions pre-cached on agent. Invoking.".format(
args.version_spec
)
)
install_file_details = get_installer_url(args.version_spec, version_dict)
install_selected_python_version(
install_file_details["download_url"], args.installer_folder
)
25 changes: 25 additions & 0 deletions .azure-pipelines/wrapped-use-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
parameters:
versionSpec: ''

steps:
# use python 3.8 for tooling. packaging. platform.
- task: UsePythonVersion@0
displayName: "Use Python 3.8"
inputs:
versionSpec: 3.8

- pwsh: |
pip install packaging
displayName: Prep Environment
# select the appropriate version from manifest if present
- task: PythonScript@0
displayName: 'Check Version Spec Against Known Versions'
inputs:
scriptPath: '.azure-pipelines/resolve_installer_location.py'
arguments: '${{ parameters.versionSpec }} --installer_folder="../_pyinstaller'

# use
- task: UsePythonVersion@0
displayName: "Use Python $(PythonVersion)"
inputs:
versionSpec: ${{ parameters.versionSpec }}
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ matrix:
- pytest
- python ./setup.py check -r -s
- pylint --extension-pkg-whitelist=uamqp.c_uamqp uamqp
- os: linux
python: "3.9-dev"
env: UAMQP_ENV=LINUX39
script:
- pytest
- python ./setup.py check -r -s
- pylint --extension-pkg-whitelist=uamqp.c_uamqp uamqp
sudo: required
services:
- docker
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

1.2.12 (Unreleased)
+++++++++++++++++++

- Updated cython dependency to 0.29.21.
- Added support for Python 3.9.

1.2.11 (2020-10-01)
+++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion build_linux_sdist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ apt-get update
apt-get install -y build-essential libssl-dev uuid-dev cmake libcurl4-openssl-dev pkg-config

cd /data
pip3 install cython==0.28.5 wheel
pip3 install cython==0.29.21 wheel
python3 setup.py sdist
Loading