使用 setup.py 将数据文件安装到站点包中 [英] Installing data files into site-packages with setup.py
问题描述
我有一个带有标准 setup.py 安装程序的 Python 包,但我一生都无法将一些预定义的配置文件安装到某个地方的站点包中……我的 setup() 函数是这样调用的:
I have a Python package with a standard setup.py installer but I cannot for the life of me get it to install some pre-defined configuration files into site-packages somewhere... my setup() function is called like this:
setup(
name='Hydrant',
version=version,
description=long_description,
author='Scott Frazer',
author_email='scott.d.frazer@gmail.com',
packages=['hydrant'],
package_data={'hydrant': ['sql/*.sql', 'hydrant.conf', 'hydrant.deploy']},
data_files=[('config', ['hydrant/hydrant.conf'])],
install_requires=[
"xtermcolor>=1.0.3",
"pyyaml",
"pymysql",
"jprops"
],
entry_points={
'console_scripts': [
'hydrant = hydrant.Main:Cli'
]
},
test_suite='hydrant.test',
license = "MIT",
)
我正在尝试使用 package_data
和 data_files
但它们似乎什么也没做.我正在使用命令行安装到虚拟环境中:
I was experimenting around with package_data
and data_files
but they simply don't seem to DO anything. I'm installing into a virtual environment with the command line:
$ python setup.py install
任何见解将不胜感激!
推荐答案
尝试将 MANIFEST.in
文件添加到您的模块中.虽然 AFAIK 它仅用于将数据添加到生成的包(eggs 或 tar.gz 分发文件)
看看这个 StackOverflow 相关问题/答案.
Try adding a MANIFEST.in
file to your module. Althought AFAIK it's only used to add data to generated packages (eggs or tar.gz distribution files)
Look at this StackOverflow related question/answer.
其他程序员使其工作切换到 distutils,但我不推荐它,因为它已被分发弃用.
看看这个其他与 StackOverflow 相关的问题/答案
Others programmers made it work switching to distutils, but i wouldn't recommend it since it's deprecated by distribute.
Look at this other StackOverflow related question/answer
这篇关于使用 setup.py 将数据文件安装到站点包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!