我想用它setuptools-scm来控制我的包版本。我的setup.py:
setuptools.setup(
...
use_scm_version={'write_to': 'my-package/version.py'},
...
)
Run Code Online (Sandbox Code Playgroud)
v0.2目前我的仓库中有标签。我创建了新分支并添加了一些提交。当我运行python setup.py --version创建my-package/version.py文件时,我得到下一个标签v0.3而不是当前标签v0.2:
$ SETUPTOOLS_SCM_DEBUG=1 python3 setup.py --version
...
cmd 'git describe --dirty --tags --long --match *.*'
out b'v0.2-1-gb13420a\n'
cmd 'git rev-parse --abbrev-ref HEAD'
out b'feature-version-system\n'
tag v0.2
tag 'v0.2' parsed to {'version': 'v0.2', 'prefix': '', 'suffix': ''}
version pre parse v0.2
version <Version('0.2')>
version v0.2 -> 0.2
scm version <ScmVersion 0.2 d=1 n=gb13420a d=False b=feature-version-system>
config {'version_scheme': 'guess-next-dev', 'local_scheme': …Run Code Online (Sandbox Code Playgroud) 我正在使用project.toml 文件来打包我的模块,我想使用模块从git 标记中提取版本setuptools_scm。
当我运行python setup.p y --version命令时,它给出了这个输出0.0.1.post1.dev0。我如何只获取0.0.1值并忽略该.post.dev0值?
这是project.toml 文件设置:
[build-system]
requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5"]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
version_scheme = "no-guess-dev"
local_scheme="no-local-version"
write_to = "src/showme/version.py"
git_describe_command = "git describe --dirty --tags --long --match v* --first-parent"
[tool.setuptools.dynamic]
version = {attr = "showme.__version__"}
Run Code Online (Sandbox Code Playgroud)
输出:
python setup.py --version
setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
warnings.warn(msg, _BetaConfiguration)
0.0.1.post1.dev0
Run Code Online (Sandbox Code Playgroud)
谢谢
I\xe2\x80\ x99m尝试在python虚拟环境 3.7(名为\xe2\x80\x9cpy37\xe2\x80\x9d)。
\n我输入:
\n但是,我收到错误:
\nC:\\Users\\86134>activate py37\n(py37) C:\\Users\\86134>cd ipbes-analysis\\ipbes-ndr\n(py37) C:\\Users\\86134\\ipbes-analysis\\ipbes-ndr>python setup.py install\nTraceback (most recent call last):\n File "setup.py", line 26, in <module>\n language="c++",\n File "F:\\Anaconda3\\envs\\py37\\lib\\site-packages\\setuptools\\__init__.py", line 153, in setup\n return distutils.core.setup(**attrs)\n File "F:\\Anaconda3\\envs\\py37\\lib\\distutils\\core.py", line 108, in setup\n _setup_distribution = dist = klass(attrs)\n File "F:\\Anaconda3\\envs\\py37\\lib\\site-packages\\setuptools\\dist.py", line 433, in __init__\n k: v for k, v in attrs.items()\n File "F:\\Anaconda3\\envs\\py37\\lib\\distutils\\dist.py", line 292, in __init__\n …Run Code Online (Sandbox Code Playgroud) 我正在查看https://github.com/pypa/setuptools_scm
\n我读了这部分https://github.com/pypa/setuptools_scm#version-number-construction
\n我引用
\n\n\n具有发布分支的项目的语义版本控制。如果在发布分支上,则与guess-next-dev(增加预发布或微段)相同:分支的名称(忽略命名空间)解析为与最新标签匹配的版本,直至次要段。否则,如果在非发布分支上,则增加次要段并将微段设置为零,然后附加 .devN。
\n
这是如何运作的?
\n假设我的设置在此提交https://github.com/simkimsia/test-setup-py/commit/5ebab14b16b63090ad0554ad8f9a77a28b047323
\n和相同的存储库,我如何通过分支来增加版本?
\n我更新了主分支上的一些文件。
\n然后我做了以下事情
\npython -m pip install --upgrade "pip ~= 21.3"\n\npip install pip-tools "pip-tools ~= 6.5"\n\ngit init .\n\ngit add .\ngit commit -m \'\xe2\x99\xbb\xef\xb8\x8f REFACTOR\'\ngit tag -a v0.0.0 -m \' First tag v0.0.0\'\n\npip-compile\n\npip-sync\n\npip install -e .\nRun Code Online (Sandbox Code Playgroud)\n然后我推送我的更改,包括标签
\n所以这个提交是https://github.com/simkimsia/test-setup-py/commit/75838db70747fd06cc190218562d0548baa16e9d
\n当我运行时python -m demopublicpythonproject显示的版本是正确的
然后我分支
\ngit checkout …Run Code Online (Sandbox Code Playgroud) 我有一个刚刚更新为使用 setuptools_scm 的包,发现 readthedocs 中的版本号是错误的。
http://sshuttle.readthedocs.org/en/v0.77/显示:
Version: 0.78.dev0+ng083293e.d20160304
Run Code Online (Sandbox Code Playgroud)
然而,由于版本 083293e 具有 0.77 标签,因此版本字符串应该只是 0.77
看起来 readthedocs 可能会在构建之前对我的源代码进行更改。
我查看了 readthedocs 构建日志,似乎在某个阶段具有正确的版本(0.77),但这是在构建文档之前。
Processing dependencies for sshuttle==0.77
Finished processing dependencies for sshuttle==0.77
Run Code Online (Sandbox Code Playgroud)
构建文档时构建日志不会提及版本。
有可能解决这个问题吗?
谢谢
我有一个项目,我通过标签管理版本git。然后,我使用setuptools_scm在 my 中获取此信息setup.py,并生成一个文件 ( _version.py),该文件在生成 的轮子时包含在内pip。
此文件未被跟踪,git因为:
git现在,当我构建文档时,从中获取此版本变得很自然_version.py,并且这一切在本地运行良好。
但是,当我尝试在 ReadTheDocs 中执行此操作时,文档的构建失败,因为_version.py未由 跟踪git,因此 ReadTheDocs 在从存储库获取源代码时找不到它。
编辑:我尝试使用重复中提出的方法,该方法与文档中指示的方法相同setuptools_scm,即使用docs/conf.py:
from pkg_resources import get_distribution
__version__ = get_distribution('numeral').version
... # I use __version__ to define Sphinx variables
Run Code Online (Sandbox Code Playgroud)
但我得到:
pkg_resources.DistributionNotFound:未找到“数字”分布,并且是应用程序所需的
(同样,在本地构建文档可以正常工作。)
如何解决这个问题而不需要在两个地方维护版本号?
python setuptools python-sphinx read-the-docs setuptools-scm
如果我有一个项目:
$ cat pyproject.toml
[build-system]
requires = ["setuptools>=41.0", "setuptools-scm", "wheel"]
build-backend = "setuptools.build_meta"
$ git tag
0.1.0
$ git log
commit df40f0c6a207a0fa0fc03f8af01fbac939d6a5fa (HEAD -> master)
Author: [censored]
Date: Thu Aug 12 14:27:24 2021 +0100
foo
commit fe2f90978d1a02583841854f2c1433c4b1b8258a (tag: 0.1.0)
Author: [censored]
Date: Thu Aug 12 14:26:57 2021 +0100
init
Run Code Online (Sandbox Code Playgroud)
然后,尝试从 获取版本setuptools_scm,我得到:
$ cat pyproject.toml
[build-system]
requires = ["setuptools>=41.0", "setuptools-scm", "wheel"]
build-backend = "setuptools.build_meta"
$ git tag
0.1.0
$ git log
commit df40f0c6a207a0fa0fc03f8af01fbac939d6a5fa (HEAD -> master)
Author: [censored]
Date: …Run Code Online (Sandbox Code Playgroud)