setuptools:包含在 `bdist` 中但不包含在 `sdist` 中的数据文件 [英] setuptools: data files included with `bdist` but not with `sdist`

查看:66
本文介绍了setuptools:包含在 `bdist` 中但不包含在 `sdist` 中的数据文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 setup.py 文件,它看起来像这样:

I've got a setup.py file which looks like this:

#!/usr/bin/env python
from setuptools import setup, find_packages

setup(
    name="foo",
    version="1.0",
    packages=find_packages(),
    include_package_data=True,
    package_data={
        "": ["*"],
    },
)

还有一个看起来像这样的包 foo:

And a package foo which looks like this:

foo/__init__.py
foo/bar.txt

当我运行 setup.py bdist 时,bar.txt 文件(正确)包含在发行版中……但是当我使用 setup.py sdist 时 不是.

When I run setup.py bdist, the bar.txt file is (correctly) included in the distribution… But when I use setup.py sdist it isn't.

这是怎么回事?我误解了 package_data 的含义吗?或者这是 setuptools 的一个怪癖?

What's up with that? Am I misunderstanding the meaning of package_data? Or is this a quirk of setuptools?

推荐答案

选择这些文件有不同的来源.package_data 用于从源树安装.构建一个源包你还需要一个MANIFEST.in 文件.它应该包含诸如 recursive-include *.txt 之类的内容,或者您​​需要的任何内容.

There are different sources for selecting those files. The package_data is used for installing from the source tree. The build a source package you also need a MANIFEST.in file. It should contain something like recursive-include *.txt, or whatever you need.

这篇关于setuptools:包含在 `bdist` 中但不包含在 `sdist` 中的数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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