readthedocs and setuptools scm version wrong

落花浮王杯 提交于 2021-02-07 08:38:57

问题


I have a package I just updated to use setuptools_scm and found the version number is wrong in readthedocs.

http://sshuttle.readthedocs.org/en/v0.77/ shows:

Version: 0.78.dev0+ng083293e.d20160304

however as version 083293e has the 0.77 tag, the version string should be just 0.77

It looks like readthedocs might be making changes to my source code before building.

I have looked at the readthedocs build logs, and it seems to have the correct version at one stage (0.77), however this is before it builds the documentation.

Processing dependencies for sshuttle==0.77
Finished processing dependencies for sshuttle==0.77

The build logs don't mention the version while building the documentation.

Is it possible to solve this?

Thanks


回答1:


I see that you're building this project.

Clearly, something is mutating the repository state before the version is determined. You can replicate similar behavior by mutating one of the files prior to building the docs yourself:

(sshuttle) $ python setup.py --version
0.77
(sshuttle) $ cat >> setup.py
# a comment
(sshuttle) $ python setup.py --version
0.78.dev0+ng083293e.d20160403

In the read the docs docs, there's a description of the process.

There, you can see the steps RTD does, namely, (a) run setup.py install then (b) install requirements in requirements.txt.

I've confirmed that neither of those steps should be mutating the repo state.

What it doesn't explain, however, is where that 'version' comes from, or what update_imported_docs does. I suspect the issue lies in something subtle that read the docs is doing that modifies the repo.

Here's one place where the conf.py file gets modified.

Perhaps adding docs/conf.py to your .gitignore will allow those changes to be ignored and thus not dirty your working state when calculating the project version.




回答2:


https://github.com/pypa/setuptools_scm/issues/84 has been updated to record this

we will be working with the sphinx team to provide a automated/painless version of this process




回答3:


The documentation for setuptools_scm now has instructions on how to use with readthedocs:

It is discouraged to use setuptools_scm from sphinx itself, instead use pkg_resources after editable/real installation:

from pkg_resources import get_distribution
release = get_distribution('myproject').version
# for example take major/minor
version = '.'.join(release.split('.')[:2])

The underlying reason is, that services like readthedocs sometimes change the workingdirectory for good reasons and using the installed metadata prevents using needless volatile data there.

This avoids the need to use kluges as per the other answer.



来源:https://stackoverflow.com/questions/35811267/readthedocs-and-setuptools-scm-version-wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!