Skip to content

Commit 126cf6d

Browse files
Handle removal of distutils from stdlib in Python 3.12 (#508)
Use setuptools as a replacement for now.
1 parent a76f081 commit 126cf6d

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

ci/install_coverage_subprocess_pth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
# http://coverage.readthedocs.io/en/latest/subprocess.html
44

55
import os.path as op
6-
from distutils.sysconfig import get_python_lib
6+
from sysconfig import get_path
77

88
FILE_CONTENT = u"""\
99
import coverage; coverage.process_startup()
1010
"""
1111

12-
filename = op.join(get_python_lib(), 'coverage_subprocess.pth')
12+
filename = op.join(get_path('purelib'), 'coverage_subprocess.pth')
1313
with open(filename, 'wb') as f:
1414
f.write(FILE_CONTENT.encode('ascii'))
1515

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ codecov
1515
coverage
1616
# Utility package used when running the cloudpickle test suite
1717
./tests/cloudpickle_testpkg
18+
# Required for setup of the above utility package:
19+
setuptools; python_version >= '3.12'

tests/cloudpickle_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,13 @@ def my_small_function(x, y):
740740
def test_module_importability(self):
741741
from cloudpickle.compat import pickle
742742
import os.path
743-
import distutils
744-
import distutils.ccompiler
743+
import collections
744+
import collections.abc
745745

746746
assert _should_pickle_by_reference(pickle)
747747
assert _should_pickle_by_reference(os.path) # fake (aliased) module
748-
assert _should_pickle_by_reference(distutils) # package
749-
assert _should_pickle_by_reference(distutils.ccompiler) # module in package
748+
assert _should_pickle_by_reference(collections) # package
749+
assert _should_pickle_by_reference(collections.abc) # module in package
750750

751751
dynamic_module = types.ModuleType('dynamic_module')
752752
assert not _should_pickle_by_reference(dynamic_module)

tests/cloudpickle_testpkg/setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from distutils.core import setup
1+
try:
2+
from setuptools import setup
3+
except ImportError:
4+
from distutils.core import setup
25

36

47
dist = setup(

0 commit comments

Comments
 (0)