From 91dfd3e8bdf95ca2992d675162619036345120d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Wed, 14 Jul 2021 10:25:57 +0100 Subject: [PATCH] Add Python3.10 to CI and handle distutils deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- azure-pipelines.yml | 6 +++++- src/tox/helper/get_site_package_dir.py | 18 ++++++++++++++++-- tox.ini | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bf87abb30..2c4b84359 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,6 +38,10 @@ jobs: key: pre-commit | .pre-commit-config.yaml path: $(PRE_COMMIT_HOME) docs: null + py310: + image: [ linux ] + py39: + image: [ linux, windows, macOs ] py38: image: [linux, windows, macOs] py27: @@ -56,7 +60,7 @@ jobs: package_description: null coverage: with_toxenv: 'coverage' # generate .tox/.coverage, .tox/coverage.xml after test run - for_envs: [py38, py37, py36, py35, py27, pypy3, pypy] + for_envs: [py310, py39, py38, py37, py36, py35, py27, pypy3, pypy] before: - task: UsePythonVersion@0 condition: and(succeeded(), in(variables['TOXENV'], 'pypy')) diff --git a/src/tox/helper/get_site_package_dir.py b/src/tox/helper/get_site_package_dir.py index 942c85754..adb6ca1d3 100644 --- a/src/tox/helper/get_site_package_dir.py +++ b/src/tox/helper/get_site_package_dir.py @@ -3,6 +3,20 @@ import json import sys import sysconfig +import warnings -data = json.dumps({"dir": sysconfig.get_path("purelib", vars={"base": sys.argv[1]})}) -print(data) +dest_prefix = sys.argv[1] +with warnings.catch_warnings(): # disable warning for PEP-632 + warnings.simplefilter("ignore") + try: + import distutils.sysconfig + + data = distutils.sysconfig.get_python_lib(prefix=dest_prefix) + except ImportError: # if removed or not installed ignore + config_vars = { + k: dest_prefix if any(v == p for p in (sys.prefix, sys.base_prefix)) else v + for k, v in sysconfig.get_config_vars().items() + } + data = sysconfig.get_path("purelib", vars=config_vars) + +print(json.dumps({"dir": data})) diff --git a/tox.ini b/tox.ini index f999c498b..f777dd539 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,8 @@ envlist = py27, py36, py37, py38, + py39, + py310, pypy, pypy3, coverage, @@ -93,7 +95,7 @@ commands = coverage combine coverage xml -o {toxworkdir}/coverage.xml coverage html -d {toxworkdir}/htmlcov diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml -depends = py27, py34, py35, py36, py37, py38, pypy, pypy3 +depends = py27, py35, py36, py37, py38, py39, py310, pypy, pypy3 parallel_show_output = True [testenv:exit_code]