我试图了解如何在package_data
中使用setup.py
来为私有pypiserver正确打包数据。我的文件夹结构如下:
.
└── elastic-manager/
├── elastic_manager/
│ ├── icons/
| | └──icon.svg
│ └── lib/
│ ├── acc/
│ │ ├── elastic/
│ │ │ └── query/
│ │ └── mapping/
│ ├── views/
│ └── widgets/
│ └── json_tree/
│ ├── edit/
│ └── input/
├── dist/
└── setup.py
我正在尝试将图标包含在icons
文件夹下。以下是我的setup.py
的内容:
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="elastic-manager",
version="0.0.6",
description="A graphical application to manage Elasticsearch.",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
include_package_data=True,
package_data={
"elastic_manager": ["icons/*"]
},
install_requires=[
"PyQt5>=5.12",
"pytz>=2019.1",
"pyYAML>=5.1",
"numpy>=1.16",
"simplejson>=3.16",
"elasticsearch>=7.0"
],
classifiers=[
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
"License :: Non-permissive",
"Operating System :: OS Independent",
],
)
当我使用python3 setup.py sdist
打包并使用生成的pip3
中的tar.gz
安装它时,我可以启动该程序,但是其中不包含图标!我怎么了?
谢谢!
答案 0 :(得分:0)
我误解了package_data
的目的。我应该按照指南中的指定在根目录中创建一个MANIFEST.in
:https://packaging.python.org/guides/distributing-packages-using-setuptools/#manifest-in
要在图标文件夹下包含所有内容,我必须添加行include elastic_manager/icons/*
。
感谢@hoefling