Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force `sdist` to create .zip archive even on Linux

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.

like image 970
anatoly techtonik Avatar asked Jan 17 '15 10:01

anatoly techtonik


1 Answers

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},
)
like image 164
anatoly techtonik Avatar answered Oct 26 '22 02:10

anatoly techtonik