Skip to content

Commit

Permalink
Remove sphinx setuptools integration
Browse files Browse the repository at this point in the history
The Sphinx project removed the setuptools integration with version 7.
Call sphinx-build directly. We don't declare it as dependency because it
is not required during runtime.

Fixes BobBuildTool#513 and BobBuildTool#515.
  • Loading branch information
jkloetzke committed Jun 4, 2023
1 parent 05e05e6 commit 1346895
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions setup.py
Expand Up @@ -41,48 +41,40 @@ def run(self):
"-ffunction-sections", "-fdata-sections", "-Wl,--gc-sections"])
self.spawn(["strip", "bin/bob-namespace-sandbox"])

# Additional command to build manpages on POSIX systems
class BuildManpages(Command):
description = "Build manpages"
user_options = []

def enabled(self):
return sys.platform != "win32"

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
self.spawn(["sphinx-build", "-b", "man", "doc", "doc/_build/man"])

# Wrapper around build command to force automatic execution of the
# documentation and applet builds.
class build(build_orig):
sub_commands = [
('build_apps', BuildApps.enabled )
('build_apps', BuildApps.enabled ),
('build_man', BuildManpages.enabled ),
] + build_orig.sub_commands

cmdclass = {
'build' : build,
'build_apps': BuildApps,
'build_man' : BuildManpages,
}
data_files = []

# Installation time dependencies only needed by setup.py
setup_requires = [
'setuptools_scm<7', # automatically get package version
# TODO: remove constraint when Python 3.7 is required
]

# Stub class that acts as a proxy for the real sphinx.setup_command.BuildDoc
# class. We want to defer the import until it is really needed to give the
# setuptools a chance to fetch the build depencency first.
class BuildDocStub:
def __getattr__(self, attr):
from sphinx.setup_command import BuildDoc
return getattr(BuildDoc, attr)

def __setattr__(self, attr, value):
from sphinx.setup_command import BuildDoc
setattr(BuildDoc, attr, value)

def __call__(self, *args, **kwargs):
from sphinx.setup_command import BuildDoc
return BuildDoc(*args, **kwargs)

# Sphinx manpages and bash completion do not work on Windows
if sys.platform != 'win32':
cmdclass['build_sphinx'] = BuildDocStub()
build.sub_commands.append(('build_sphinx', None))
setup_requires.extend([
'sphinx',
])
data_files.extend([
('share/man/man1', [
'doc/_build/man/bob-archive.1',
Expand Down Expand Up @@ -151,7 +143,10 @@ def __call__(self, *args, **kwargs):
},

# Installation time dependencies only needed by setup.py
setup_requires = setup_requires,
setup_requires = [
'setuptools_scm<7', # automatically get package version
# TODO: remove constraint when Python 3.7 is required
],

# Provide executables
entry_points = {
Expand Down

0 comments on commit 1346895

Please sign in to comment.