运行setup.py将创建没有版本的version.py文件

2024-04-25 16:57:01 发布

您现在位置:Python中文网/ 问答频道 /正文

运行my setup.py时,将创建一个version.py文件,但不使用该文件中指定的版本。如何修复它以指定版本

这是我的设置.py:

from setuptools import setup, find_packages
from codecs import open
from os import path


here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()


def parse_requirements(filename):
    lineiter = (line.strip() for line in open(filename))
    return [line for line in lineiter if line and not line.startswith("#")]


install_reqs = parse_requirements(filename='requirements.txt')

setup(

    name='eagle-py-framework',  # Required

    version=1.0,  # Required

    description='Eagle Python Framework',  # Required

    long_description=long_description,  # Optional

    author='asdf',  # Optional

    author_email='asdf',

    url='asdf',

    classifiers=[  # Optional
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'Topic :: Software Development :: Build Tools',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
    ],
    packages=find_packages(exclude=['contrib', 'docs', 'tests']),  # Required
    install_requires=install_reqs,  # Optional
)

我用来运行它的命令是:

python setup.py sdist

它创建的version.py文件仅包含以下内容:

__version__=

Tags: 文件pathfrompyimportversionpackagessetup
1条回答
网友
1楼 · 发布于 2024-04-25 16:57:01

使用版本作为字符串

setup(

        name='eagle-py-framework',  # Required

        version = "1.0",  # Required #string
    )

从这里开始->https://www.python.org/dev/peps/pep-0396/

3) When a module (or package) includes a version number, the version SHOULD be available in the version attribute.

4) For modules which live inside a namespace package, the module SHOULD include the version attribute. The namespace package itself SHOULD NOT include its own version attribute.

5) The version attribute's value SHOULD be a string.

https://docs.python.org/2/distutils/setupscript.html

相关问题 更多 >