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.

anatoly techtonik
  • 19,847
  • 9
  • 124
  • 140

1 Answers1

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},
)
anatoly techtonik
  • 19,847
  • 9
  • 124
  • 140