如何根据我希望使用的 extra_requires 更改 Manifest.in? [英] How to I change the Manifest.in depending on the extra_requires I wish to use?

查看:43
本文介绍了如何根据我希望使用的 extra_requires 更改 Manifest.in?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,我正在处理的一个项目附带了重现其结果所需的所有训练数据.我希望默认安装 (pip install package) 包含所有这些东西,但特定安装 (pip install package[train_only]) 不包含.

My problem is that a project I'm working with comes shipped with all of the training data needed to reproduce its results. I want the default installation (pip install package) to include all this stuff, but a specific installation (pip install package[train_only]) to not.

我想瘦下来的两种方法是:

The two ways I want to slim it down are:

  1. 默认和 train_only 版本具有不同的清单,其中默认清单更具包容性,并且

  1. Having different manifests for the default and the train_only version, where the default manifest is more inclusive, and

每个都有不同的 install_requires,其中默认值更具包容性.

Having different install_requires for each, where the default is more inclusive.

我知道如何使用 extra_requires 安装 extra 的东西,但我如何安装更少的东西?

I know how to install extra stuff using extra_requires, but how do I install less?

推荐答案

distribution[extras] 语法仅用于为可选功能指定额外的依赖项,这通常是意味着收集其他发行版进行安装.您不能以任何方式使用此功能来控制包数据.

The distribution[extras] syntax is just used for specifying additional dependencies for optional features, this typically means collecting other distributions to install. You can not use this feature to control package data in any way.

条件 MANIFEST.in 和/或包数据在 distutils 和 setuptools 中不受支持.您最好的选择是为自定义安装后脚本创建挂钩.

Conditional MANIFEST.in and/or package data is unsupported in distutils and setuptools. Your best option would be creating the hooks for a custom post-install script.

如果您愿意考虑转而使用附加"安装模型来获取额外数据,那么您有一个更好的选择:

If you are willing to consider moving to an "additive" installation model for the extra data instead, you have a nicer option available:

pip install mypackage           # to install without extra training data stuff
pip install mypackage[mystuff]  # to install with extra training data stuff

然后您将创建一个单独的分发mystuff,其中将包含所有需要的训练数据.

Then you will create a separate distribution mystuff which will include all of the training data needed.

这篇关于如何根据我希望使用的 extra_requires 更改 Manifest.in?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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