遵循@Joe的建议删除该include_package_data=True
行也对我有用。
详细说明一下,我没有 MANIFEST.in
文件。我使用Git而不是CVS。
存储库采用以下形式:
/myrepo
- .git/
- setup.py
- myproject
- __init__.py
- some_mod
- __init__.py
- animals.py
- rocks.py
- config
- __init__.py
- settings.py
- other_settings.special
- cool.huh
- other_settings.xml
- words
- __init__.py
word_set.txt
setup.py
:
from setuptools import setup, find_packages
import os.path
setup (
name='myproject',
version = "4.19",
packages = find_packages(),
# package_dir={'mypkg': 'src/mypkg'}, # didnt use this.
package_data = {
# If any package contains *.txt or *.rst files, include them:
'': ['*.txt', '*.xml', '*.special', '*.huh'],
},
#
# Oddly enough, include_package_data=True prevented package_data from working.
# include_package_data=True, # Commented out.
data_files=[
# ('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
('/opt/local/myproject/etc', ['myproject/config/settings.py', 'myproject/config/other_settings.special']),
('/opt/local/myproject/etc', [os.path.join('myproject/config', 'cool.huh')]),
#
('/opt/local/myproject/etc', [os.path.join('myproject/config', 'other_settings.xml')]),
('/opt/local/myproject/data', [os.path.join('myproject/words', 'word_set.txt')]),
],
install_requires=[ 'jsonschema',
'logging', ],
entry_points = {
'console_scripts': [
# Blah...
], },
)
我python setup.py sdist
为源发行版(没有尝试过二进制)运行。
在新的虚拟环境中,我有一个myproject-4.19.tar.gz
文件,并且我使用
(venv) pip install ~/myproject-4.19.tar.gz
...
除了将所有内容都安装到我的虚拟环境中之外site-packages
,这些特殊数据文件也都安装到/opt/local/myproject/data
和中/opt/local/myproject/etc
。
data_files
解决了该问题。但这容易出错,对我来说并不“正确”。有人可以验证是否确实有必要在package_data
和中复制配置data_files
吗?