From 07edd4aa9bc4083db1eec8239ef81495f890bffd Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Wed, 20 Sep 2017 01:42:40 -0230 Subject: [PATCH] zulip_bots: Add custom command for generating MANIFEST.in. We now have a custom command in zulip_bots/setup.py to generate a MANIFEST.in. To generate a MANIFEST for a PyPA release, we can now run: python setup.py gen_manifest --release To generate a non-release MANIFEST, we can run: python setup.py gen_manifest This allows us to automate the MANIFEST generation in our release automation script. --- tools/provision | 6 ++++++ zulip_bots/generate_manifest.py | 32 ++++++++++++++++++++++++++++++++ zulip_bots/setup.py | 5 +++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/tools/provision b/tools/provision index 7d5f276..34fb2a8 100755 --- a/tools/provision +++ b/tools/provision @@ -8,6 +8,12 @@ import warnings from importlib import import_module +CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) +ZULIP_BOTS_DIR = os.path.join(CURRENT_DIR, '..', 'zulip_bots') +sys.path.append(ZULIP_BOTS_DIR) + +import generate_manifest + def main(): usage = """./tools/provision diff --git a/zulip_bots/generate_manifest.py b/zulip_bots/generate_manifest.py index 0f09ef6..4b28705 100755 --- a/zulip_bots/generate_manifest.py +++ b/zulip_bots/generate_manifest.py @@ -3,11 +3,43 @@ import argparse import os import glob +import distutils.cmd +import distutils.log CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) BOTS_DIR = os.path.normpath(os.path.join(CURRENT_DIR, 'zulip_bots', 'bots')) MANIFEST_PATH = os.path.join(CURRENT_DIR, 'MANIFEST.in') +class GenerateManifest(distutils.cmd.Command): + """ + A custom setup.py command to generate a MANIFEST.in + for the zulip_bots package. + """ + description = 'generate a MANIFEST.in for PyPA or for development' + user_options = [ + ('release', None, 'generate a MANIFEST for a PyPA release'), + ] + + def initialize_options(self): + self.release = False + + def finalize_options(self): + pass + + def run(self): + if self.release: + generate_release_manifest() + self.announce( + 'Generating a MANIFEST for a PyPA release of zulip_bots.', + level=distutils.log.INFO + ) + else: + generate_dev_manifest() + self.announce( + 'Generating a MANIFEST for zulip_bots\' development.', + level=distutils.log.INFO + ) + def get_test_fixtures(): # type: () -> List[str] glob_pattern = os.path.join(BOTS_DIR, '*', 'fixtures', '*.json') diff --git a/zulip_bots/setup.py b/zulip_bots/setup.py index f0d7e0b..974c151 100755 --- a/zulip_bots/setup.py +++ b/zulip_bots/setup.py @@ -5,9 +5,7 @@ from __future__ import print_function import sys -# Before anything, generate MANIFEST.in import generate_manifest -generate_manifest.generate_dev_manifest() # We should be installable with either setuptools or distutils. package_info = dict( @@ -31,6 +29,9 @@ package_info = dict( ], }, include_package_data=True, + cmdclass={ + 'gen_manifest': generate_manifest.GenerateManifest, + }, ) # type: Dict[str, Any] setuptools_info = dict(