zulip_bots/MANIFEST: Support generating MANIFEST for PyPA release.

The generate_manifest.py script now takes a --release argument
that generates a separate MANIFEST for a PyPA release that
include:

* doc.md files
* related assets/* files

A release MANIFEST doesn't include logos and fixtures.
A non-release MANIFEST includes everything.
This commit is contained in:
Eeshan Garg 2017-09-20 00:59:59 -02:30 committed by Tim Abbott
parent a887692ae4
commit dfe4360108
2 changed files with 49 additions and 18 deletions

View file

@ -1,10 +1,12 @@
#!/usr/bin/env python #!/usr/bin/env python
import argparse
import os import os
import glob import glob
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
BOTS_DIR = os.path.normpath(os.path.join(CURRENT_DIR, 'zulip_bots', 'bots')) BOTS_DIR = os.path.normpath(os.path.join(CURRENT_DIR, 'zulip_bots', 'bots'))
MANIFEST_PATH = os.path.join(CURRENT_DIR, 'MANIFEST.in')
def get_test_fixtures(): def get_test_fixtures():
# type: () -> List[str] # type: () -> List[str]
@ -42,26 +44,55 @@ def get_assets():
) )
return assets_files return assets_files
def generate_and_write(filepaths, file_obj):
# type: () -> None
template = 'include {line}\n'
lines = map(lambda line: template.format(line=line), filepaths)
file_obj.writelines(lines)
file_obj.write('\n')
def generate_dev_manifest():
# type: () -> None
with open(MANIFEST_PATH, 'w') as fp:
generate_and_write(get_test_fixtures(), fp)
generate_and_write(get_logos(), fp)
generate_and_write(get_docs(), fp)
generate_and_write(get_assets(), fp)
def generate_release_manifest():
# type: () -> None
with open(MANIFEST_PATH, 'w') as fp:
generate_and_write(get_docs(), fp)
generate_and_write(get_assets(), fp)
def parse_args():
usage = """
To generate a MANIFEST.in for a PyPA release, run:
./generate_manifest.py --release
To generate a MANIFEST.in for development, run without arguments:
./generate_manifest.py
"""
parser = argparse.ArgumentParser(usage=usage)
parser.add_argument('--release', '-r',
action='store_true',
default=False,
help='Generate MANIFEST.in for a PyPA release.')
return parser.parse_args()
def main(): def main():
# type: () -> None # type: () -> None
manifest_path = os.path.join(CURRENT_DIR, 'MANIFEST.in') options = parse_args()
with open(manifest_path, 'w') as fp: if options.release:
template = 'include {line}\n' generate_release_manifest()
fixtures = map(lambda line: template.format(line=line), else:
get_test_fixtures()) generate_dev_manifest()
logos = map(lambda line: template.format(line=line),
get_logos())
docs = map(lambda line: template.format(line=line),
get_docs())
fp.writelines(fixtures)
fp.write('\n')
fp.writelines(logos)
fp.write('\n')
fp.writelines(docs)
fp.write('\n')
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -7,7 +7,7 @@ import sys
# Before anything, generate MANIFEST.in # Before anything, generate MANIFEST.in
import generate_manifest import generate_manifest
generate_manifest.main() generate_manifest.generate_dev_manifest()
# We should be installable with either setuptools or distutils. # We should be installable with either setuptools or distutils.
package_info = dict( package_info = dict(