Skip to content

README suggestion for getting version in Sphinx seems incorrect #88

@mr-rodgers

Description

@mr-rodgers

The readme suggests this for getting the version from conf.py in Sphinx:

from setuptools_scm import get_version
get_version()

However, on the latest PyPI versions of Sphinx and setuptools_scm, I get:

Exception occurred:
  File "c:\dev\py\scopelist\.tox\doc\lib\site-packages\setuptools_scm\__init__.py", line 82, in _do_parse
    "use git+https://github.com/user/proj.git#egg=proj" % root)
LookupError: setuptools-scm was unable to detect version for 'C:\\Dev\\py\\scopelist\\doc'.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
The full traceback has been saved in C:\Users\TE-J~1\AppData\Local\Temp\sphinx-err-z9asrxod.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

It's looking for the version info in the docs folder where conf.py resides! (Maybe sphinx sets the working dir to this; I'm not sure of that though).

An easy fix would be to use this instead:

from setuptools_scm import get_version
get_version(root='../')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions