【问题标题】:Adding 'install_requires' to setup.py when making a python package制作 python 包时将“install_requires”添加到 setup.py
【发布时间】:2012-04-06 07:48:03
【问题描述】:

要制作一个python包,在setup.py,我有以下内容:

setup(
    name='TowelStuff',
    version='0.1.0',
    author='J. Random Hacker',
    author_email='jrh@example.com',
    packages=['towelstuff', 'towelstuff.test'],
    scripts=['bin/stowe-towels.py','bin/wash-towels.py'],
    url='http://pypi.python.org/pypi/TowelStuff/',
    license='LICENSE.txt',
    description='Useful towel-related stuff.',
    long_description=open('README.txt').read(),
    install_requires=[
    "Django >= 1.1.1",
    "caldav == 0.1.4",
],
)

所以我用我自己的包裹描述和信息重新制作了它。当我构建它时,我收到以下警告:

distutils/dist.py:267: UserWarning: Unknown distribution option:

install_requires 是否仅适用于某些版本?

【问题讨论】:

标签: python


【解决方案1】:

您需要使用 setuptools 而不是 distutils。

靠近脚本顶部,尝试替换

from distutils.core import setup

from setuptools import setup

【讨论】:

  • 更好的是,您可以从setuptools 导入,如果这样会引发ImportErrordistutils.core 导入。
【解决方案2】:
try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

【讨论】:

  • 我在为jython安装jip的时候试过这个,发现不行。你提到的这段代码正是 setup.py 顶部的代码,我得到了 Niek 的警告消息方法。
猜你喜欢
  • 1970-01-01
  • 2016-10-08
  • 2020-10-24
  • 2020-02-20
  • 2018-04-05
  • 2018-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多