[英]How to tell whether setup() is reading the setup.cfg?
I got a Python project generated using pyscaffold and I see the two standard main project files at the root setup.py
and setup.cfg
.我得到了一个使用pyscaffold生成的 Python 项目,我在根
setup.py
和setup.cfg
看到了两个标准的主项目文件。 I modified the setup.cfg
file adding a line under the metadata section with version=1.0.0
.我修改了
setup.cfg
文件,在元数据部分下添加了一行version=1.0.0
。
However, running python setup.py develop
or python setup.py sdist
I see in the outputs that the artifact name doesn't have the version I specified in the setup.cfg
.但是,运行
python setup.py develop
或python setup.py sdist
我在输出中看到工件名称没有我在setup.cfg
指定的版本。 I see the following:我看到以下内容:
Installed c:\users\SkyWalker\code\my_project\src
Processing dependencies for my_project==0.0.post0.dev1+g8386a10.dirty
Finished processing dependencies for my_project==0.0.post0.dev1+g8386a10.dirty
The distribution artifact has this 0.0.post0.dev1+g8386a10.dirty
version and I don't know where it's getting it from.分发工件有这个
0.0.post0.dev1+g8386a10.dirty
版本,我不知道它是从哪里得到的。 How to tell whether python.cfg
is read at all?如何判断
python.cfg
是否被读取?
The pyscaffold generated setup.py
looks like this: pyscaffold 生成的
setup.py
如下所示:
# -*- coding: utf-8 -*-
"""
Setup file for aqm_database_api.
Use setup.cfg to configure your project.
This file was generated with PyScaffold 3.2.3.
PyScaffold helps you to put up the scaffold of your new Python project.
Learn more under: https://pyscaffold.org/
"""
import sys
from pkg_resources import VersionConflict, require
from setuptools import setup
try:
require('setuptools>=37.0')
except VersionConflict:
print("Error: version of setuptools is too old (<37.0)!")
sys.exit(1)
if __name__ == "__main__":
setup(use_pyscaffold=True)
so it's not loading setup.cfg
explicitly, also the line require('setuptools>=37.0')
fails every time, no matter what the version value there is.所以它没有显式加载
setup.cfg
,无论版本值是什么, require('setuptools>=37.0')
每次都会失败。
PyScaffold configures setuptools
to use the version given by setuptools_scm
. PyScaffold提供配置
setuptools
使用给出的版本setuptools_scm
。 It means that, in order to change the version of your project you need to use git to tag your project .这意味着,为了更改项目的版本,您需要使用 git 来标记您的项目。 This is briefly described in https://pyscaffold.org/en/v3.3.x/features.html#versioning-and-git-integration .
这在https://pyscaffold.org/en/v3.3.x/features.html#versioning-and-git-integration 中有简要描述。
I suppose that is the reason why changing setup.cfg
will not change the version of the distribution created.我想这就是为什么更改
setup.cfg
不会更改创建的分发版本的原因。 A priori setuptools
should always read setup.cfg
.先验设置
setuptools
应始终读取setup.cfg
。
To make sure setuptools
is reading setup.cfg
one experiment you can do is:为了确保
setuptools
正在读取setup.cfg
您可以做的一项实验是:
*.egg-info
folder insude the root of your project or inside the src
folder (to ensure you don't see a cached version).src
文件夹内的任何*.egg-info
文件夹(以确保您看不到缓存版本)。setup.cfg
filesetup.cfg
文件中更改诸如 author 之类的setup.cfg
内容python setup.py bdist_wheel
for example)python setup.py bdist_wheel
)<your-project>.egg-info
folder generated either in the root of your project or inside the src
directory.<your-project>.egg-info
根目录或src
目录中生成的新<your-project>.egg-info
文件夹。 Read the PKG-INFO
there.PKG-INFO
。 You should be able to see your changes which proves setuptools
is reading setup.cfg
(otherwise the best option should be opening a ticket/issue with setuptools
)setuptools
正在读取setup.cfg
(否则最好的选择应该是使用setuptools
开票/问题)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.