我(試圖)使用setuptools來構建一個包。我試圖使用版本號major.minor.mercurial_revision
,但它抱怨說:如何在setuptools包中包含VCS信息
The version specified ('1.0.7ae7970a82c1') is an invalid version, this may
not work as expected with newer versions of setuptools, pip, and PyPI.
Please see PEP 440 for more details.`
好。所以我看看PEP440裏面說基本上說「不要那麼做」:
As hashes cannot be ordered reliably such versions are not permitted in the
public version field. As with semantic versioning, the public .devN
suffix may be used to uniquely identify such releases for publication,
while the original DVCS based label can be stored in the project metadata.
我理解這裏的邏輯。但如何可以我在項目元數據中包含hg修訂版?我無法找到setup.py:setup()
的參數可以包含的任何(最新)文檔,但是我發現的distutils之一here似乎沒有爲此提供一個字段。
因爲那麼你已經有了一個在你的源代碼中未跟蹤的文件,這不是很好,你的構建腳本必須做「回聲」位。這都是非標準的,上面的答案解決了它。 – lost
如果您在項目中包含修訂版本信息 - 通過'setup.py'或其他文件 - 您顯然會*生成*該文件作爲發佈過程的一部分。因此,無論是(a)未跟蹤,還是(b)您都會自動更新/提交它作爲發佈過程的一部分。 – larsks
嗯。你當然是對的。事實上,這些問題有點正交; Remco的答案解決了讓distutils接受我的版本號,但是從包內的「內部」獲取*版本號需要一個'__revision__'或者類似你的建議。 – lost