【问题标题】:Force `sdist` to create .zip archive even on Linux即使在 Linux 上也强制 `sdist` 创建 .zip 存档
【发布时间】:2015-01-17 10:37:34
【问题描述】:

我知道可以强制 sdist 从命令行生成 .zip:

python setup.py sdist --formats=zip

但是如何将此选项设为我的setup.py 的默认选项?

我希望在 Windows 和 Linux 上运行 setup.py sdist 时保持一致,我选择 .zip 格式,因为我可以 turn .zip into executable

【问题讨论】:

    标签: python distutils sdist


    【解决方案1】:

    我自己从 distutils 文档 herehere 以及 distutils sources 找到它:

    # Override sdist to always produce .zip archive
    from distutils.command.sdist import sdist as _sdist
    class sdistzip(_sdist):
        def initialize_options(self):
            _sdist.initialize_options(self)
            self.formats = 'zip'
    
    setup(
        ...
        cmdclass={'sdist': sdistzip},
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-18
      • 2019-05-25
      • 2010-11-12
      相关资源
      最近更新 更多