Description
First of all currently it is not possible to use straight sphinx-build
command to build documentation out of source tree
+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v4.5.0
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 332, in eval_config_file
exec(code, namespace)
File "/home/tkloczko/rpmbuild/BUILD/structlog-21.5.0/docs/conf.py", line 43, in <module>
release = metadata.version("structlog")
File "/usr/lib64/python3.8/importlib/metadata.py", line 530, in version
return distribution(distribution_name).version
File "/usr/lib64/python3.8/importlib/metadata.py", line 503, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib64/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: structlog
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 272, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 202, in __init__
self.config = Config.read(self.confdir, confoverrides or {}, self.tags)
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 165, in read
namespace = eval_config_file(filename, tags)
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 345, in eval_config_file
raise ConfigError(msg % traceback.format_exc()) from exc
sphinx.errors.ConfigError: There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 332, in eval_config_file
exec(code, namespace)
File "/home/tkloczko/rpmbuild/BUILD/structlog-21.5.0/docs/conf.py", line 43, in <module>
release = metadata.version("structlog")
File "/usr/lib64/python3.8/importlib/metadata.py", line 530, in version
return distribution(distribution_name).version
File "/usr/lib64/python3.8/importlib/metadata.py", line 503, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib64/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: structlog
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 332, in eval_config_file
exec(code, namespace)
File "/home/tkloczko/rpmbuild/BUILD/structlog-21.5.0/docs/conf.py", line 43, in <module>
release = metadata.version("structlog")
File "/usr/lib64/python3.8/importlib/metadata.py", line 530, in version
return distribution(distribution_name).version
File "/usr/lib64/python3.8/importlib/metadata.py", line 503, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib64/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: structlog
This can be fixed by patch like below:
--- a/docs/conf.py~ 2022-05-20 10:06:46.107190599 +0000
+++ b/docs/conf.py 2022-05-20 10:12:32.737264031 +0000
@@ -3,13 +3,15 @@
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
-from importlib import metadata
+import sys
+import os
+sys.path.insert(0, os.path.abspath('../src'))
+import structlog
# We want an image in the README and include the README in the docs.
suppress_warnings = ["image.nonlocal_uri"]
-
# -- General configuration ----------------------------------------------------
extensions = [
@@ -40,7 +42,7 @@
# built documents.
# The full version, including alpha/beta/rc tags.
-release = metadata.version("structlog")
+release = structlog.__version__
# The short X.Y version.
version = release.rsplit(".", 1)[0]
This patch fixes what is in the comment and that can of fix is suggested in sphinx example copy.py https://www.sphinx-doc.org/en/master/usage/configuration.html#example-of-configuration-file
That patch as well removes importlib
module from build dependencies and obtains curent structlog
version straight from module.
Than .. on building my packages I'm using sphinx-build
command with -n
switch which shows warmings about missing references. These are not critical issues.
Here is the output with warnings:
+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v4.5.0
making output directory... done
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: [new config] 20 added, 0 changed, 0 removed
reading sources... [100%] why
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... python-structlog.3 { why getting-started loggers configuration testing thread-local contextvars processors examples development types standard-library twisted logging-best-practices custom-wrappers performance api license changelog } /home/tkloczko/rpmbuild/BUILD/structlog-21.5.0/docs/api.rst:: WARNING: py:class reference target not found: WrappedLogger
/home/tkloczko/rpmbuild/BUILD/structlog-21.5.0/docs/api.rst:: WARNING: py:class reference target not found: Processor
/home/tkloczko/rpmbuild/BUILD/structlog-21.5.0/docs/api.rst:: WARNING: py:class reference target not found: Context
done
build succeeded, 3 warnings.
You can peak on fixes that kind of issues in other projects
latchset/jwcrypto#289
click-contrib/sphinx-click@abc31069