运行setup.py会创建没有设置版本的version.py文件

时间:2018-04-13 15:35:38

标签: python

运行我的setup.py时,会创建一个没有在文件中指定版本的version.py文件。如何修复它以便指定版本?

这是我的setup.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__=

1 个答案:

答案 0 :(得分:1)

将版本用作字符串

setup(

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

        version = "1.0",  # Required #string
    )

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

  

3)当模块(或包)包含版本号时,版本   应该在版本属性中提供。

     

4)对于存在于命名空间包内的模块,模块   应该包含版本属性。命名空间包本身   不应包含自己的版本属性。

     

5)版本属性的值应该是一个字符串。

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