-
-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Description
Currently, I use setuptools_scm to determine the correct version number for my package, and write that version to a file in my module, after setting version to be dynamic.
e.g. in my pyproject.toml (irrelevant lines elided):
[build-system]
requires = [
"setuptools_scm[toml]>=5",
]
[project]
dynamic = [ "version" ]
[tool.setuptools_scm]
write_to = "src/pkgname/_version.py"
...and then some quick stub code in my package's __init__.py:
from ._version import version as __version__
Currently, no matter what exists in my documentation's conf.py, attempting to initialize things via SphinxConfig() gives an error about version being unset or marked as dynamic.
What I'd like to be able to do is something like this in my conf.py (which is basically what I'm doing currently, minus sphinx-pyproject):
module_dir = os.path.join(__location__, "../src/pkgname")
from pkgname import __version__ as version
from sphinx_pyproject import SphinxConfig
config = SphinxConfig("../pyproject.toml", globalns=globals())
...and have it work, because "version" is already set in the global namespace. There's lots of ways to accomplish the same thing, though, e.g. SphynxConfig could take an extra argument, something like defaults={"version": version} or similar. Or simply have a flag that can be passed to it to indicate that it couldn't fail just because one of the expected values isn't there. It doesn't matter too much which way the problem is solved, as long as it's still possible to use sphinx-pyproject without a version number hardcoded in the pyproject.toml.
Thanks!
Version
- Operating System: all
- Python: 3.10.2
- sphinx-pyproject: 0.1.0