Commit 8e63fe47 authored by Pierre Augier's avatar Pierre Augier
Browse files

Avoid DeprecationWarning distutils

parent 9ff9d14247c4
Pipeline #26735 passed with stage
in 10 minutes and 56 seconds
......@@ -42,11 +42,27 @@ User API
import os
from pathlib import Path
from distutils.util import strtobool
from warnings import warn
path_root = Path(os.environ.get("TRANSONIC_DIR", Path.home() / ".transonic"))
def strtobool(value):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
value = value.lower()
if value in ("y", "yes", "t", "true", "on", "1"):
return 1
elif value in ("n", "no", "f", "false", "off", "0"):
return 0
raise ValueError(f"invalid truth value {value}")
has_to_replace = not strtobool(os.environ.get("TRANSONIC_NO_REPLACE", "0"))
backend_default = "pythran"
......@@ -16,18 +16,18 @@
import os
import sys
from pathlib import Path
from distutils.sysconfig import get_config_var
from sysconfig import get_config_var
from typing import Iterable
from concurrent.futures import ThreadPoolExecutor as Pool
import re
from distutils.command.build_ext import build_ext as DistutilsBuildExt
from setuptools.command.build_ext import build_ext as SetuptoolsBuildExt
from Cython.Distutils.build_ext import build_ext as CythonBuildExt
from Cython.Build import cythonize
except ImportError:
build_ext_classes = [DistutilsBuildExt]
build_ext_classes = [SetuptoolsBuildExt]
can_import_cython = False
build_ext_classes = [CythonBuildExt]
......@@ -277,11 +277,11 @@ class ParallelBuildExt(*build_ext_classes):
# Invoke Distutils build_extensions method which respects
# parallel building. Cython's build_ext ignores this
def _build_extensions_parallel(self):
"""A slightly modified version
- filters out some problematic compiler flags
......@@ -51,7 +51,6 @@ import itertools
import os
import sys
import time
from distutils.util import strtobool
from functools import wraps
from transonic.analyses.justintime import analysis_jit
......@@ -72,6 +71,7 @@ from transonic.util import (
modules_backends = {backend_name: {} for backend_name in backends.keys()}
import shutil
from distutils.core import Distribution
from setuptools import Distribution
from pprint import pformat
import pytest
......@@ -51,7 +51,6 @@ import inspect
import re
from pathlib import Path
import importlib.util
from distutils.util import strtobool
import shutil
from textwrap import dedent
from typing import Callable
......@@ -107,10 +106,10 @@ from transonic.compiler import (
from transonic.config import path_root
from transonic.config import path_root, strtobool
__all__ = ["modification_date", "has_to_build"]
__all__ = ["modification_date", "has_to_build", "path_root"]
def can_import_accelerator(backend: str = backend_default):
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