Skip to content
Snippets Groups Projects
Commit ae065eac authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Added "setup.py zip" command to create distributable zip files.

These zips contain the Wheel, an example configuration, README and LICENSE
files, and system integration files.
parent 2585f273
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python #!/usr/bin/env python
from pathlib import Path
import collections
import setuptools import setuptools
import sys
import zipfile
from distutils.cmd import Command
from distutils.errors import DistutilsOptionError
from distutils import dir_util, log
sys.dont_write_bytecode = True
# noinspection PyAttributeOutsideInit
class ZipCommand(Command):
"""Ensures that 'setup.py dist' creates a zip file with a wheel and other useful stuff."""
description = "create a zip with a wheel and other useful files"
user_options = [
('dist-dir=', 'd',
"directory to put the archive in "
"[default: dist]"),
]
def initialize_options(self):
self.dist_dir = None
def finalize_options(self):
if self.dist_dir is None:
self.dist_dir = "dist"
def run(self):
self.run_command('bdist_wheel')
if not self.distribution.dist_files:
msg = "No dist file created, even though we ran 'bdist_wheel' ourselves."
raise DistutilsOptionError(msg)
base_dir = Path(self.distribution.get_fullname())
zip_base = Path(self.dist_dir) / base_dir
zip_name = zip_base.with_name(zip_base.name + '.zip')
log.info('Creating ZIP file %s', zip_name)
with zipfile.ZipFile(str(zip_name), mode='w') as archive:
def add_to_root(fname: Path):
log.info(' adding %s', fname.name)
archive.write(str(fname), fname.name)
for command, pyversion, filename in self.distribution.dist_files:
add_to_root(Path(filename))
add_to_root(Path('flamenco-worker.cfg'))
add_to_root(Path('LICENSE.txt'))
add_to_root(Path('README.md'))
paths = collections.deque([Path('system-integration')])
while paths:
this_path = paths.popleft()
if this_path.is_dir():
paths.extend(this_path.iterdir())
continue
log.info(' adding %s', this_path)
archive.write(str(this_path), str(this_path))
if __name__ == '__main__': if __name__ == '__main__':
setuptools.setup( setuptools.setup(
cmdclass={'zip': ZipCommand},
name='flamenco-worker', name='flamenco-worker',
version='2.0-beta10-worker6', version='2.0-beta10-worker6',
description='Flamenco Worker implementation', description='Flamenco Worker implementation',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment