Skip to content

Commit 0f6826c

Browse files
committed
Remove usage of deprecated distutils, fixes #2457
1 parent 18e19e3 commit 0f6826c

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

python/perspective/perspective/table/_accessor.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
1111
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

13-
from distutils.util import strtobool
1413
from math import isnan
1514

1615
import numpy
@@ -23,6 +22,22 @@
2322
from .libpsppy import t_dtype
2423

2524

25+
def strtobool(val):
26+
"""Convert a string representation of truth to true (1) or false (0).
27+
28+
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
29+
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
30+
'val' is anything else.
31+
"""
32+
val = val.lower()
33+
if val in ("y", "yes", "t", "true", "on", "1"):
34+
return 1
35+
elif val in ("n", "no", "f", "false", "off", "0"):
36+
return 0
37+
else:
38+
raise ValueError("invalid truth value {!r}".format(val))
39+
40+
2641
def _flatten_structure(array):
2742
"""Flatten numpy.recarray or structured arrays into a dict."""
2843
# recarrays/structured arrays do not have guaranteed bit offsets - make a

python/perspective/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
[build-system]
1414
requires = [
15-
"setuptools",
16-
"wheel",
17-
"numpy>=1.13.1,<2",
1815
"jupyter-packaging==0.12.3",
16+
"numpy>=1.13.1,<2",
17+
"setuptools==68.2.2",
18+
"wheel",
1919
]
2020
build-backend = "jupyter_packaging.build_api"
2121

python/perspective/setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import sys
2121
import sysconfig
2222
from codecs import open
23-
from distutils.version import LooseVersion
23+
from setuptools._distutils.version import LooseVersion
2424
from jupyter_packaging import get_data_files, wrap_installers, get_version
2525

2626
from setuptools import Extension, find_packages, setup
@@ -56,8 +56,8 @@
5656
########################
5757
# Get requirement info #
5858
requires = [
59-
"Jinja2>=2.0,<4",
6059
"ipywidgets>=7.5.1,<9",
60+
"Jinja2>=2.0,<4",
6161
"numpy>=1.21.6,<2",
6262
"pandas>=0.22.0,<3",
6363
"python-dateutil>=2.8.0,<3",
@@ -160,7 +160,7 @@ def build_extension_cmake(self, ext):
160160
env = os.environ.copy()
161161

162162
if platform.system() == "Windows":
163-
import distutils.msvccompiler as dm
163+
import setuptools._distutils.msvccompiler as dm
164164

165165
# https://wiki.python.org/moin/WindowsCompilers#Microsoft_Visual_C.2B-.2B-_14.0_with_Visual_Studio_2015_.28x86.2C_x64.2C_ARM.29
166166
msvc = {

tools/perspective-scripts/_requires_python.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
let PYTHON = sh(python_version());
2121

2222
if (process.env.PSP_OLD_SHITTY_INSTALL_METHOD) {
23-
const requires_script = `import distutils.core; setup = distutils.core.run_setup('python/perspective/setup.py'); print(' '.join(['"' + requirement + '"' for requirement in setup.extras_require['dev']]))`;
23+
const requires_script = `import setuptools._distutils.core; setup = setuptools._distutils.core.run_setup('python/perspective/setup.py'); print(' '.join(['"' + requirement + '"' for requirement in setup.extras_require['dev']]))`;
2424

2525
// copy build/config files into python folder
2626
copy_files_to_python_folder();

0 commit comments

Comments
 (0)