Skip to content

Commit a5c60df

Browse files
committed
Handle case when distutils is no more
Python 3.12 has officially removed distutils from the python standard library. While in practice it still seems to work somehow in local tests, we should be prepared to use setuptool's copy instead. Signed-off-by: Rodrigo Tobar <[email protected]>
1 parent afa0238 commit a5c60df

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

setup.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import distutils.ccompiler
2-
import distutils.sysconfig
1+
try:
2+
from distutils import ccompiler
3+
from distutils import sysconfig
4+
except ImportError:
5+
from setuptools._distutils import ccompiler
6+
from setuptools._distutils import sysconfig
7+
38
import glob
49
import os
510
import platform
@@ -52,8 +57,8 @@ def get_ijson_version():
5257
# without properly cleaning up
5358
def yajl_present():
5459

55-
compiler = distutils.ccompiler.new_compiler(verbose=1)
56-
distutils.sysconfig.customize_compiler(compiler) # CC, CFLAGS, LDFLAGS, etc
60+
compiler = ccompiler.new_compiler(verbose=1)
61+
sysconfig.customize_compiler(compiler) # CC, CFLAGS, LDFLAGS, etc
5762

5863
fname = tempfile.mktemp(".c", "yajl_version")
5964
try:

0 commit comments

Comments
 (0)