Python 将json文件添加到MANIFEST.in并安装包会导致错误

Python 将json文件添加到MANIFEST.in并安装包会导致错误,python,setuptools,distribute,Python,Setuptools,Distribute,我的包树如下所示:(还有一些不相关的文件) setup.py: from distutils.core import setup setup( name = 'mydir', packages = ['mydir'], version = '1.2.2', description = 'desc', author = 'my name', author_email = 'my@email.com', url = 'https://git

我的包树如下所示:(还有一些不相关的文件)

setup.py:

from distutils.core import setup

setup(
    name = 'mydir',
    packages = ['mydir'], 
    version = '1.2.2',
    description = 'desc',
    author = 'my name',
    author_email = 'my@email.com',
    url = 'https://github.com/myname/mydir', 
    download_url = 'https://github.com/myname/mydir/archive/1.2.2.tar.gz',
    keywords = ['key1', 'key2'],
    classifiers = [],
  )
MANIFEST.in
文件为空时,json不包括在dist文件中。
因此,我将json文件添加到了
清单中。在
中,现在它只包含:

include mydir/file.json
当我执行
python setup.py sdist
命令时,自动生成的
MANIFEST
文件包含所有必要的文件,包括
file.json

但是,当我尝试使用
pip
安装我的软件包时,出现以下错误:

error: can't copy 'file.json': doesn't exist or not a regular file
明白了。
setup.py
更改为使用setuptools导入设置中的
,查找\u程序包
,而不是
distutils.core

还向
setup.py
添加了
include\u package\u data=True.

setup(
    ...
    include_package_data = True,
    ...
)

清单中的include一起,在
中,json文件按预期被提取到目标目录。

您能发布setup.py文件吗?@fasouto已更新。谢谢,我认为include_package_数据丢失:)@fasouto你是对的,但这还不够,我不得不将
setup.py
使用的lib从
distutils.core
更改为
setuptools
,请参阅下面的解决方案,如果你想在
file.py
中使用
file.json
,该怎么办,获取文件路径的正确方法是什么?
setup(
    ...
    include_package_data = True,
    ...
)