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
. I modified the setup.cfg
file adding a line under the metadata section with 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
. 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. How to tell whether python.cfg
is read at all?
The pyscaffold generated setup.py
looks like this:
# -*- 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.
PyScaffold configures setuptools
to use the version given by setuptools_scm
. It means that, in order to change the version of your project you need to use git to tag your project . This is briefly described in 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. A priori setuptools
should always read setup.cfg
.
To make sure setuptools
is reading setup.cfg
one experiment you can do is:
*.egg-info
folder insude the root of your project or inside the src
folder (to ensure you don't see a cached version).setup.cfg
filepython setup.py bdist_wheel
for example)<your-project>.egg-info
folder generated either in the root of your project or inside the src
directory. Read the PKG-INFO
there. 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
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.