【发布时间】:2020-01-22 02:11:10
【问题描述】:
我有一个名为clana(Github,PyPI)的包,其结构如下:
.
├── clana
│ ├── cli.py
│ ├── config.yaml
│ ├── __init__.py
│ ├── utils.py
│ └── visualize_predictions.py
├── docs/
├── setup.cfg
├── setup.py
├── tests/
└── tox.ini
setup.py 如下所示:
from setuptools import find_packages
from setuptools import setup
requires_tests = [...]
install_requires = [...]
config = {
"name": "clana",
"version": "0.3.6",
"author": "Martin Thoma",
"author_email": "info@martin-thoma.de",
"maintainer": "Martin Thoma",
"maintainer_email": "info@martin-thoma.de",
"packages": find_packages(),
"entry_points": {"console_scripts": ["clana=clana.cli:entry_point"]},
"install_requires": install_requires,
"tests_require": requires_tests,
"package_data": {"clana": ["clana/config.yaml"]},
"include_package_data": True,
"zip_safe": False,
}
setup(**config)
如何检查它是否不起作用
快速
python3 setup.py sdist
open dist/clana-0.3.8.tar.gz # config.yaml is not in this file
真正的支票
我认为这可以确保安装软件包时config.yaml 与cli.py 位于同一目录中。但是当我尝试这个时:
virtualenv venv
source venv/bin/activate
pip install clana
cd venv/lib/python3.6/site-packages/clana
ls
我明白了:
cli.py __init__.py __pycache__ utils.py visualize_predictions.py
我上传到 PyPI 的方式:
python3 setup.py sdist bdist_wheel && twine upload dist/*
所以config.yaml 不见了。我怎样才能确定它在那里?
【问题讨论】:
-
@Erwan 是的。就像我在上面的文字中发布的那样。
-
你试过
config.yaml而不是clana/config.yaml吗? -
它适用于
MANIFEST.in(谢谢你,Erwan!) - 但我认为include_package_data=True我不需要那个。为什么include_package_data不起作用? -
sdist主要由文件MANIFESTor its templateMANIFEST.in控制,而不是setup.py。setup.py中的include_package_data=True用于bdist_*(bdist_egg、bdist_wheel等)命令。
标签: python python-3.x setuptools python-packaging