如何配置setuptools_scm以始终生成时间戳和Git哈希

huangapple go评论56阅读模式
英文:

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&#39;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>



huangapple
  • 本文由 发表于 2023年3月7日 12:20:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75658016.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定