如何在 setup.py 中指定 `--formats` sdist 选项?

How to specify the `--formats` sdist option inside setup.py?

我尝试在 linux 发行版上创建一个压缩源 python 包,但没有在命令行上为 sdist 指定 --formats 选项(使用现有的 Jenkins 管道,它不支持此选项)。 在文档 here 中,它指出:

(assuming you haven’t specified any sdist options in the setup script or config file), sdist creates the archive of the default format for the current platform. The default format is a gzip’ed tar file (.tar.gz) on Unix, and ZIP file on Windows.

但它没有说明您应该如何在安装脚本中指定 sdist 选项?

来自链接文档previous topic

The basic syntax of the configuration file is simple:

[command]
option=value
...

where command is one of the Distutils commands (e.g. build_py, install), and option is one of the options that command supports

以及稍后 build_ext --inplace

的示例
[build_ext]
inplace=1

这意味着您必须写入 setup.cfg 文件:

[sdist]
formats=zip

注意:未经测试,因为我没有可用的 Python2...