Unverified Commit 064ca1d0 authored by Hongtao Zhang's avatar Hongtao Zhang Committed by GitHub
Browse files

Init latest python support. (#687)

Added support for Python 3.11, 3.12 and 3.13.

yapf is not compatiable with python3.12+, so we disable yapf in py3.12
for now.
https://github.com/google/yapf/issues/1258
https://github.com/google/yapf/issues/1266



---------
Co-authored-by: default avatarhongtaozhang <hongtaozhang@microsoft.com>
parent 41a484fa
...@@ -9,13 +9,10 @@ strategy: ...@@ -9,13 +9,10 @@ strategy:
matrix: matrix:
python-3.7: python-3.7:
imageTag: '3.7' imageTag: '3.7'
python-3.8:
imageTag: '3.8'
python-3.10: python-3.10:
imageTag: '3.10' imageTag: '3.10'
# TODO python-3.12:
#python-latest: imageTag: '3.12'
# imageTag: '3'
maxParallel: 3 maxParallel: 3
pool: pool:
...@@ -29,7 +26,11 @@ steps: ...@@ -29,7 +26,11 @@ steps:
echo "##vso[task.prependpath]$HOME/.local/bin" echo "##vso[task.prependpath]$HOME/.local/bin"
displayName: Export path displayName: Export path
- script: | - script: |
python3 -m pip install --upgrade pip setuptools==65.7 if [[ "$(echo $(imageTag) '< 3.11' | bc -l)" == 1 ]]; then
python3 -m pip install --upgrade pip setuptools==65.7
else
python3 -m pip install --upgrade pip
fi
python3 -m pip install .[test,cpuworker] python3 -m pip install .[test,cpuworker]
make postinstall make postinstall
displayName: Install dependencies displayName: Install dependencies
......
...@@ -6,3 +6,4 @@ inline-quotes = single ...@@ -6,3 +6,4 @@ inline-quotes = single
multiline-quotes = double multiline-quotes = double
docstring-quotes = double docstring-quotes = double
docstring-convention = google docstring-convention = google
extend-exclude = .*,build
...@@ -12,19 +12,21 @@ ...@@ -12,19 +12,21 @@
import pathlib import pathlib
from typing import List, Tuple, ClassVar from typing import List, Tuple, ClassVar
import pkg_resources
from setuptools import setup, find_packages, Command from setuptools import setup, find_packages, Command
import superbench import superbench
try: print(f'Python {sys.version_info.major}.{sys.version_info.minor} detected.')
pkg_resources.require(['pip>=18', 'setuptools>=45, <66']) if sys.version_info[:2] < (3, 11):
except (pkg_resources.VersionConflict, pkg_resources.DistributionNotFound): import pkg_resources
print( try:
'\033[93mTry update pip/setuptools versions, for example, ' pkg_resources.require(['pip>=18', 'setuptools>=45, <66'])
'python3 -m pip install --upgrade pip wheel setuptools==65.7\033[0m' except (pkg_resources.VersionConflict, pkg_resources.DistributionNotFound):
) print(
raise '\033[93mTry update pip/setuptools versions, for example, '
'python3 -m pip install --upgrade pip wheel setuptools==65.7\033[0m'
)
raise
here = pathlib.Path(__file__).parent.resolve() here = pathlib.Path(__file__).parent.resolve()
long_description = (here / 'README.md').read_text(encoding='utf-8') long_description = (here / 'README.md').read_text(encoding='utf-8')
...@@ -50,9 +52,13 @@ def finalize_options(self): ...@@ -50,9 +52,13 @@ def finalize_options(self):
pass pass
def run(self): def run(self):
"""Fromat the code using yapf.""" """Format the code using yapf."""
errno = os.system('python3 -m yapf --in-place --recursive --exclude .git --exclude .eggs .') if sys.version_info[:2] >= (3, 12):
sys.exit(0 if errno == 0 else 1) # TODO: Remove this block when yapf is compatible with Python 3.12+.
print('Disable yapf for Python 3.12+ due to the compatibility issue.')
else:
errno = os.system('python3 -m yapf --in-place --recursive --exclude .git --exclude .eggs .')
sys.exit(0 if errno == 0 else 1)
class Linter(Command): class Linter(Command):
...@@ -76,10 +82,14 @@ def finalize_options(self): ...@@ -76,10 +82,14 @@ def finalize_options(self):
def run(self): def run(self):
"""Lint the code with yapf, mypy, and flake8.""" """Lint the code with yapf, mypy, and flake8."""
if sys.version_info[:2] >= (3, 12):
# TODO: Remove this block when yapf is compatible with Python 3.12+.
print('Disable lint for Python 3.12+ due to the compatibility issue.')
errno = os.system( errno = os.system(
' && '.join( ' && '.join(
[ [
'python3 -m yapf --diff --recursive --exclude .git --exclude .eggs .', 'python3 -m yapf --diff --recursive --exclude .git --exclude .eggs .' if sys.version_info[:2] <
(3, 12) else ':',
'python3 -m mypy .', 'python3 -m mypy .',
'python3 -m flake8', 'python3 -m flake8',
] ]
...@@ -135,6 +145,9 @@ def run(self): ...@@ -135,6 +145,9 @@ def run(self):
'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Topic :: System :: Benchmark', 'Topic :: System :: Benchmark',
'Topic :: System :: Clustering', 'Topic :: System :: Clustering',
'Topic :: System :: Hardware', 'Topic :: System :: Hardware',
...@@ -151,8 +164,10 @@ def run(self): ...@@ -151,8 +164,10 @@ def run(self):
'setuptools_scm', 'setuptools_scm',
], ],
install_requires=[ install_requires=[
'ansible_base>=2.10.9;os_name=="posix"', 'ansible;os_name=="posix" and python_version>"3.10"',
'ansible_runner>=2.0.0rc1, <2.3.2', 'ansible_base>=2.10.9;os_name=="posix" and python_version<="3.10"',
'ansible_runner>=2.0.0rc1, <2.3.2;python_version<="3.10"',
'ansible_runner;python_version>"3.10"',
'colorlog>=6.7.0', 'colorlog>=6.7.0',
'importlib_metadata', 'importlib_metadata',
'jinja2>=2.10.1', 'jinja2>=2.10.1',
...@@ -194,7 +209,7 @@ def run(self): ...@@ -194,7 +209,7 @@ def run(self):
'test': [ 'test': [
'flake8-docstrings>=1.5.0', 'flake8-docstrings>=1.5.0',
'flake8-quotes>=3.2.0', 'flake8-quotes>=3.2.0',
'flake8>=3.8.4, <6.0.0', 'flake8>=3.8.4',
'mypy>=0.800', 'mypy>=0.800',
'pydocstyle>=5.1.1', 'pydocstyle>=5.1.1',
'pytest-cov>=2.11.1', 'pytest-cov>=2.11.1',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment