为什么“pip install"不包括我的 package_data 文件? [英] Why does "pip install" not include my package_data files?

查看:113
本文介绍了为什么“pip install"不包括我的 package_data 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么当我运行 pip install ../path_to_my_proj/(来自 virtualenv)没有任何数据文件被复制到 sitepackage/myproj/文件夹.正确复制了 python 包.

I can't figure out why when I run pip install ../path_to_my_proj/ (from a virtualenv) none of the data files are copied across to the sitepackage/myproj/ folder. The python packages are copied across correctly.

python 版本 3.4.4

python version 3.4.4

我的项目目录是这样的:

My project directory is like this:

├── myproj
│   ├── __init__.py
│   ├── module1.py
│   └── module2.py
├── data_files
|    ├── subfolder1
│    |   ├── datafile.dll
│    |   └── datafile2.dll
|    └── subfolder2
│        ├── datafile3.dll
│        └── datafile4.dll
|
├── MANIFEST.in
└── setup.py

我的 MANIFEST.in 看起来像

And my MANIFEST.in looks like

recursive-include data_files *
include README.md

我的设置如下:

setup(
    name='myproj',
    version='0.1.1',
    install_requires=['requirement'],
    packages=['myproj'],
    include_package_data=True,
)  

推荐答案

我遇到了同样的问题并在 https://gitter.im/pypa/setuptools.结果?你不能那样做.data_files 必须位于 myproj 下.

I encountered the same problem and asked about it on https://gitter.im/pypa/setuptools. The result? You just can't do that. data_files must live under myproj.

你可以通过在 data_files 中放置一个空的 __init__.py 来伪造它,但它会被放入 PYTHONHOME\Lib\site-packagescode> 与 myproj 并排在同一级别,污染名称空间.

You can fake it by putting an empty __init__.py in data_files, but then it will get put into PYTHONHOME\Lib\site-packages along side myproj at same level, polluting the name space.

这篇关于为什么“pip install"不包括我的 package_data 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆