我正在构建一个本地python包
cd <source dir>
python ./setup.py sdist
当我尝试使用pip安装它时,它会尝试删除不存在的文件,然后失败。
pip install --verbose dist/pl_zenoss_handler-0.1.1.tar.gz
Unpacking ./dist/pl_zenoss_handler-0.1.1.tar.gz
Running setup.py (path:/tmp/pip-QohNov-build/setup.py) egg_info for package from file:///Users/travis.bear/p4/depot/service/python/_pl_zenoss_handler/dist/pl_zenoss_handler-0.1.1.tar.gz
running egg_info
creating pip-egg-info/pl_zenoss_handler.egg-info
writing pip-egg-info/pl_zenoss_handler.egg-info/PKG-INFO
writing top-level names to pip-egg-info/pl_zenoss_handler.egg-info/top_level.txt
<... much output deleted for brevity ... >
creating build/scripts-2.7
error: file '/private/tmp/pip-QohNov-build/bin/zen_handler' does not exist
----------------------------------------
Cleaning up...
Command /Users/travis.bear/venv/zenoss/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-QohNov-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-uIoyIG-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/travis.bear/venv/zenoss/include/site/python2.7 failed with error code 1 in /tmp/pip-QohNov-build
Exception information:
Traceback (most recent call last):
File "/Users/travis.bear/venv/zenoss/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Users/travis.bear/venv/zenoss/lib/python2.7/site-packages/pip/commands/install.py", line 279, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Users/travis.bear/venv/zenoss/lib/python2.7/site-packages/pip/req.py", line 1380, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/Users/travis.bear/venv/zenoss/lib/python2.7/site-packages/pip/req.py", line 699, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/Users/travis.bear/venv/zenoss/lib/python2.7/site-packages/pip/util.py", line 697, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /Users/travis.bear/venv/zenoss/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-QohNov-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-uIoyIG-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/travis.bear/venv/zenoss/include/site/python2.7 failed with error code 1 in /tmp/pip-QohNov-build
Storing debug log for failure in /Users/travis.bear/.pip/pip.log
这是setup.py文件:
from setuptools import setup
readme = open('README.rst').read()
history = open('HISTORY.rst').read().replace('.. :changelog:', '')
setup(
name='pl_zenoss_handler',
version='0.1.1',
description='Sensu handler for Zenoss',
long_description=readme + '\n\n' + history,
author='Travis Bear',
author_email='<snip>',
url='<snip>',
packages=[
'zen_handler',
],
scripts=['bin/zen_handler'],
install_requires=[
],
license="BSD",
keywords='zenoss sensu'
)
答案 0 :(得分:1)
bin/zen_handler
个文件问题是,您的setup.py
要求使用bin/zen_handler
中的文件以及您的分发gz文件中缺少该文件。
bin/zen_handler
setup.py
定义了创建分发包的条件bin/zen_handler
并失败。如果gz
文件包含bin/zen_handler
,您应该检查。我会假设,它不存在。
原因是,因为它不是python包zen_handler
本身的一部分,所以它不会打包成分发。
找到setup.py的选项,它甚至会将bin/zen_handler
声明为分发包的一部分。这可能意味着编辑MANIFEST.in
文件(在那里添加该文件)和/或使用参数include_package_data
。
entry_points
不使用paremater scripts
,而是使用Automatic Script Creation中所述的entry_point
。由于这是使用纯包python源代码,因此不需要在外部存在文件。
我建议使用此解决方案,即使代码中几乎不需要修改。