Skip to content

Commit

Permalink
Close sphinx-doc#9820: Use setuptools.Command if available
Browse files Browse the repository at this point in the history
distutils was marked as deprecated since Python 3.10 (see PEP 632).
And it will be removed since Python 3.12.  To follow the deprecation,
this starts to use `setuptools.Command` if available.
  • Loading branch information
tk0miya committed May 29, 2022
1 parent 873d9f6 commit 84a90a1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sphinx/setup_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import os
import sys
import warnings
from distutils.cmd import Command
from distutils.errors import DistutilsExecError
from io import StringIO
from typing import Any, Dict

Expand All @@ -18,6 +16,13 @@
from sphinx.util.docutils import docutils_namespace, patch_docutils
from sphinx.util.osutil import abspath

try:
from setuptools import Command
from setuptools.errors import ExecError
except ImportError:
from distutils.cmd import Command
from distutils.errors import DistutilsExecError as ExecError


class BuildDoc(Command):
"""
Expand Down Expand Up @@ -171,8 +176,7 @@ def run(self) -> None:
verbosity=self.verbosity, keep_going=self.keep_going)
app.build(force_all=self.all_files)
if app.statuscode:
raise DistutilsExecError(
'caused by %s builder.' % app.builder.name)
raise ExecError('caused by %s builder.' % app.builder.name)
except Exception as exc:
handle_exception(app, self, exc, sys.stderr)
if not self.pdb:
Expand Down

0 comments on commit 84a90a1

Please sign in to comment.