我正在尝试将data_file
添加到setup.py
项目中。我可以使用/tmp/
目录中的文件,不能在脚本的当前目录中使用它:
from setuptools import setup, find_packages
import os
packages = find_packages("src")
foo_path = os.path.dirname(os.path.abspath(__file__)) + '/foo.dat'
print foo_path # file exists and there full absolute path is printed:
# '/home/loom/myapp/foo.dat'
setup(name='myapp',
version='0.2.0',
url='http://loom.st',
author='Loom',
author_email='admin@loom.st',
package_dir={'': 'src'},
packages=packages,
py_modules=['my_start'],
# 1. data_files=[('lib/python', [foo_path])],
# 2. data_files=[('lib/python', [/tmp/foo.dat])],
setup_cfg=True,
)
当行1.
取消注释时,python setup.py bdist_rpm
失败并显示消息:
running install_data
error: can't copy '/home/loom/myapp/build/bdist.linux-x86_64/rpm/BUILD/myapp-0.2.0/foo.dat': doesn't exist or not a regular file
error: Bad exit status from /var/tmp/rpm-tmp.02mmV8 (%install)
取消注释第2.
行后,即可完成构建,并包含foo.dat
(文件/tmp/foo.dat
存在)
为什么行1.
会导致错误以及如何避免错误?
答案 0 :(得分:1)
这里的问题是,您给出了<UserControl ...><Image DataContext="{Binding}" DataContextChanged="ItemImage_DataContextChanged" /></UserControl>
的错误路径,它是作为目录提供的:
/home/loom/myapp/foo.dat /
只需删除末尾的foo.dat
,因此它是文件的路径:
/home/loom/myapp/foo.dat
如果文件确实存在,现在一切都应该没问题。