Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx, ReadTheDocs and package version

I maintain a package whose documentation I auto-generate with Sphinx on readthedocs.org. For Sphinx/readthedocs I use a conf.py and a properly defined .readthedocs.yaml.

Inside the conf.py I use the version:

import pybliometrics

version = pybliometrics.__version__
release = pybliometrics.__version__.replace("_", "")

The version is generated in pybliometrics/__init__.py. The package itself uses its own version somewhere in the code as well.

When I do the versioning with pbr (Python Build Reasonableness) like

from pbr.version import VersionInfo

_v = VersionInfo('pybliometrics').semantic_version()
__version__ = _v.release_string()

then the build process on readthedocs works without any problem (assuming I make it install pbr).

However, when it looks like

from importlib.metadata import version

__version__ = version("pybliometrics")

then the build process fails with importlib.metadata.PackageNotFoundError: No package metadata was found for pybliometrics. Same for importlib_metadata.

What's happening there? The reason I switched to importlib.metadata is that I can do the the entire build process with setuptools_scm and get rid of setup.py and setup.cfg.

like image 711
MERose Avatar asked Sep 16 '25 21:09

MERose


1 Answers

Likely you need to do pip install -e equivalent in your RTD requirements.txt build file.

See .readthedocs.yml example here and see requirements.txt here.

like image 99
Mikko Ohtamaa Avatar answered Sep 19 '25 13:09

Mikko Ohtamaa