Force `sdist` to create .zip archive even on Linux
Asked Answered
B

1

6

I know it is possible to force sdist to produce .zip from command line:

python setup.py sdist --formats=zip

But how to make this option a default for my setup.py?

I'd like to get consistency for running setup.py sdist on both Windows and Linux, and I choose .zip format, because I can turn .zip into executable.

Bidden answered 17/1, 2015 at 10:37 Comment(0)
B
5

Found it myself from distutils docs here and here, and from 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},
)
Bidden answered 18/1, 2015 at 14:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.