[英]setup.py build doesn't work but develop does
发布这个因为它影响了我。 重要的是要知道构建包的distutils构建它, 即使它已经破坏了依赖关系 ,请参见此处 。 如果你在运行python setup.py install
时观察输出,你可能会发现问题的根源。
对我来说,我有一个名为“what”的软件包,其全名非常清楚它是什么,但输入很烦人。 所以我希望命令本身是一个缩写,就像“我们”。
或者,我的setup.py看起来像这样:
from setuptools import setup
setup(
name='we',
version='3.0.3',
py_modules=['we'],
install_requires=[
...
],
scripts=['whatever/bin/we']
)
我的文件夹结构是这样的:
├── setup.py
├── whatever
│ ├── bin/
│ │ ├── we
│ ├── __init__.py
│ ├── other_stuff/
在we
内部,我导入完整的包(具有点击界面):
#!/usr/bin/env python
from whatever.cli import cli
cli()
当我运行安装时,我看到了这个:
$ python setup.py install
running install
running bdist_egg
running egg_info
writing we.egg-info/PKG-INFO
writing dependency_links to we.egg-info/dependency_links.txt
writing requirements to we.egg-info/requires.txt
writing top-level names to we.egg-info/top_level.txt
file we.py (for module we) not found
reading manifest file 'we.egg-info/SOURCES.txt'
writing manifest file 'we.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.13-x86_64/egg
running install_lib
running build_py
file we.py (for module we) not found
file we.py (for module we) not found
warning: build_py: byte-compiling is disabled, skipping.
...
问题是没有名为we的模块 ,只有cli工具。 卸下py_modules
线,并替换它packages
指向全包文件夹名解决了这个问题对我来说:
from setuptools import setup
setup(
name='we',
version='3.0.3',
packages=['whatever'],
install_requires=[
...
],
scripts=['whatever/bin/we']
)
现在,当我运行we
,无论执行什么cli包。 希望这有助于未来的读者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.