英文:
How to configure setuptools_scm to always generate timestamp and git hash
问题
来自[`setuptools_scm`][1]包,默认情况下可以生成4种不同的版本消息。
```python
无距离和干净:{tag}
有距离和干净:{next_version}.dev{distance}+{scm letter}{revision hash}
无距离和不干净:{tag}+dYYYYMMDD
有距离和不干净:{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYYMMDD
在我的用例中,我不想使用其版本消息。相反,我想使用它并检索git哈希和时间戳信息。
from setuptools_scm import get_version
my_version = get_version()
根据其文档,有一个get_version()
函数。但是,如果当前仓库没有距离且干净,它只会生成不够的tag
。
我的问题是如何配置get_version()
函数,使其始终生成git哈希和时间戳。这样我就可以解析它并创建自己的版本消息。
<details>
<summary>英文:</summary>
The [`setuptools_scm`][1] package by default could generate 4 different version messages.
no distance and clean: {tag}
distance and clean: {next_version}.dev{distance}+{scm letter}{revision hash}
no distance and not clean: {tag}+dYYYYMMDD
distance and not clean: {next_version}.dev{distance}+{scm letter}{revision hash}.dYYYYMMDD
In my usecase, I don't want to use its version message. Instead, I want to use it and retrive git hash and timestamp information.
from setuptools_scm import get_version
my_version = get_version()
According to its documentation, there is a `get_version()` function. But if the current repo has no distance and clean, it only generates `tag` which is not enough.
My question is how to configure `get_version()` function to let it always generate git hash and timestamp. So I can parse it and create my own version message.
[1]: https://github.com/pypa/setuptools_scm
</details>
# 答案1
**得分**: 0
根据这个[问题][1],作者提出了一种方法来实现它。稍后将添加更多示例。
[1]: https://github.com/pypa/setuptools_scm/issues/809
<details>
<summary>英文:</summary>
Based on this [issue][1], the author suggests a way to do it. More examples would be added later.
[1]: https://github.com/pypa/setuptools_scm/issues/809
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论