【问题标题】:How to specify the `--formats` sdist option inside setup.py?如何在 setup.py 中指定 `--formats` sdist 选项?
【发布时间】:2021-01-20 03:28:09
【问题描述】:

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

(假设您没有在设置脚本或配置文件中指定任何 sdist 选项),sdist 会为当前平台创建默认格式的存档。默认格式在 Unix 上是 gzip 的 tar 文件 (.tar.gz),在 Windows 上是 ZIP 文件。

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

【问题讨论】:

  • 你真的在使用 distutils 和 Python2 吗?当前的标准是 setuptools 和 Python3...
  • @SergeBallesta 是的,不幸的是,我被困在使用 python2... :(

标签: python python-2.7 setup.py sdist


【解决方案1】:

来自链接文档previous topic:

配置文件的基本语法很简单:

[command]
option=value
...

其中 command 是 Distutils 命令之一(例如 build_py、install),而 option 是 command 支持的选项之一

之后是build_ext --inplace的示例

[build_ext]
inplace=1

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

[sdist]
formats=zip

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

【讨论】:

  • 很抱歉在这件事上偷懒了,感谢您的帮助。阅读文档后,我感觉这在 setup.py 中应该是可行的,但拥有一个配置文件可能更干净。
猜你喜欢
  • 2020-08-02
  • 2010-12-09
  • 2012-05-21
  • 1970-01-01
  • 1970-01-01
  • 2017-12-02
  • 1970-01-01
  • 2014-12-20
  • 2021-03-05
相关资源
最近更新 更多