Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit faa8ec6

Browse files
author
Matthias Koeppe
committed
sage.misc.cython: Try using setuptools, fall back to distutils
1 parent 13b4090 commit faa8ec6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/sage/misc/cython.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,19 @@ def cython(filename, verbose=0, compile_message=False,
272272
from Cython.Build import cythonize
273273
from Cython.Compiler.Errors import CompileError
274274
import Cython.Compiler.Options
275-
from distutils.dist import Distribution
276-
from distutils.core import Extension
275+
276+
try:
277+
# Import setuptools before importing distutils, so that setuptools
278+
# can replace distutils by its own vendored copy.
279+
import setuptools
280+
from setuptools.dist import Distribution
281+
from setuptools.extension import Extension
282+
except ImportError:
283+
# Fall back to distutils (stdlib); note that it is deprecated
284+
# in Python 3.10, 3.11; https://www.python.org/dev/peps/pep-0632/
285+
from distutils.dist import Distribution
286+
from distutils.core import Extension
287+
277288
from distutils.log import set_verbosity
278289
set_verbosity(verbose)
279290

0 commit comments

Comments
 (0)