packaging: Automatically generate zulip_bots MANIFEST.in.

Fixes #69.
This commit is contained in:
derAnfaenger 2017-08-16 18:45:00 +02:00 committed by Tim Abbott
parent e1d1c490c8
commit e4c34d77e7
4 changed files with 94 additions and 95 deletions

View file

@ -1,63 +0,0 @@
#!/usr/bin/env python
import os
import glob
def get_zulip_bots_test_fixtures():
# type: () -> List[str]
current_dir = os.path.abspath(os.path.dirname(__file__))
bots_dir = os.path.join(current_dir, '..', 'zulip_bots/zulip_bots/bots')
glob_pattern = os.path.join(bots_dir, '*/fixtures/*.json')
fixtures_paths = map(
lambda fp: os.path.join(*fp.split('/')[-5:]),
glob.glob(glob_pattern)
)
return fixtures_paths
def get_zulip_bots_logos():
# type: () -> List[str]
current_dir = os.path.abspath(os.path.dirname(__file__))
bots_dir = os.path.join(current_dir, '..', 'zulip_bots/zulip_bots/bots')
glob_pattern = os.path.join(bots_dir, '*/logo.*')
logo_paths = map(
lambda fp: os.path.join(*fp.split('/')[-4:]),
glob.glob(glob_pattern)
)
return logo_paths
def get_zulip_bots_docs():
# type: () -> List[str]
current_dir = os.path.abspath(os.path.dirname(__file__))
bots_dir = os.path.join(current_dir, '..', 'zulip_bots/zulip_bots/bots')
glob_pattern = os.path.join(bots_dir, '*/doc.md')
doc_paths = map(
lambda fp: os.path.join(*fp.split('/')[-4:]),
glob.glob(glob_pattern)
)
return doc_paths
def main():
# type: () -> None
current_dir = os.path.abspath(os.path.dirname(__file__))
manifest_path = os.path.join(current_dir, '..', 'zulip_bots/MANIFEST.in')
with open(manifest_path, 'w') as fp:
template = 'include {line}\n'
fixtures = map(lambda line: template.format(line=line),
get_zulip_bots_test_fixtures())
logos = map(lambda line: template.format(line=line),
get_zulip_bots_logos())
docs = map(lambda line: template.format(line=line),
get_zulip_bots_docs())
fp.writelines(fixtures)
fp.write('\n')
fp.writelines(logos)
fp.write('\n')
fp.writelines(docs)
fp.write('\n')
if __name__ == '__main__':
main()

View file

@ -1,47 +1,47 @@
include zulip_bots/bots/giphy/fixtures/test_1.json include zulip_bots/bots/define/fixtures/test_incorrect_word.json
include zulip_bots/bots/weather/fixtures/test_city_not_found.json
include zulip_bots/bots/weather/fixtures/test_only_city.json
include zulip_bots/bots/weather/fixtures/test_only_country.json
include zulip_bots/bots/weather/fixtures/test_city_with_country.json
include zulip_bots/bots/github_detail/fixtures/test_issue.json
include zulip_bots/bots/github_detail/fixtures/test_pull.json
include zulip_bots/bots/github_detail/fixtures/test_404.json
include zulip_bots/bots/yoda/fixtures/test_invalid_input.json
include zulip_bots/bots/yoda/fixtures/test_only_numbers.json
include zulip_bots/bots/yoda/fixtures/test_2.json
include zulip_bots/bots/yoda/fixtures/test_1.json
include zulip_bots/bots/define/fixtures/test_multi_type_word.json include zulip_bots/bots/define/fixtures/test_multi_type_word.json
include zulip_bots/bots/define/fixtures/test_single_type_word.json include zulip_bots/bots/define/fixtures/test_single_type_word.json
include zulip_bots/bots/define/fixtures/test_incorrect_word.json include zulip_bots/bots/giphy/fixtures/test_1.json
include zulip_bots/bots/wikipedia/fixtures/test_multi_word.json include zulip_bots/bots/github_detail/fixtures/test_404.json
include zulip_bots/bots/github_detail/fixtures/test_issue.json
include zulip_bots/bots/github_detail/fixtures/test_pull.json
include zulip_bots/bots/weather/fixtures/test_city_not_found.json
include zulip_bots/bots/weather/fixtures/test_city_with_country.json
include zulip_bots/bots/weather/fixtures/test_only_city.json
include zulip_bots/bots/weather/fixtures/test_only_country.json
include zulip_bots/bots/wikipedia/fixtures/test_incorrect_query.json include zulip_bots/bots/wikipedia/fixtures/test_incorrect_query.json
include zulip_bots/bots/wikipedia/fixtures/test_single_word.json include zulip_bots/bots/wikipedia/fixtures/test_multi_word.json
include zulip_bots/bots/wikipedia/fixtures/test_number_query.json include zulip_bots/bots/wikipedia/fixtures/test_number_query.json
include zulip_bots/bots/xkcd/fixtures/test_specific_id.json include zulip_bots/bots/wikipedia/fixtures/test_single_word.json
include zulip_bots/bots/xkcd/fixtures/test_random.json
include zulip_bots/bots/xkcd/fixtures/test_not_existing_id.json
include zulip_bots/bots/xkcd/fixtures/test_latest.json include zulip_bots/bots/xkcd/fixtures/test_latest.json
include zulip_bots/bots/xkcd/fixtures/test_not_existing_id.json
include zulip_bots/bots/xkcd/fixtures/test_not_existing_id_2.json include zulip_bots/bots/xkcd/fixtures/test_not_existing_id_2.json
include zulip_bots/bots/xkcd/fixtures/test_random.json
include zulip_bots/bots/xkcd/fixtures/test_specific_id.json
include zulip_bots/bots/yoda/fixtures/test_1.json
include zulip_bots/bots/yoda/fixtures/test_2.json
include zulip_bots/bots/yoda/fixtures/test_invalid_input.json
include zulip_bots/bots/yoda/fixtures/test_only_numbers.json
include zulip_bots/bots/github_detail/logo.svg include zulip_bots/bots/github_detail/logo.svg
include zulip_bots/bots/googlesearch/logo.png include zulip_bots/bots/googlesearch/logo.png
include zulip_bots/bots/converter/doc.md
include zulip_bots/bots/incrementor/doc.md
include zulip_bots/bots/weather/doc.md
include zulip_bots/bots/github_detail/doc.md
include zulip_bots/bots/yoda/doc.md
include zulip_bots/bots/git_hub_comment/doc.md
include zulip_bots/bots/virtual_fs/doc.md
include zulip_bots/bots/howdoi/doc.md
include zulip_bots/bots/youtube/doc.md
include zulip_bots/bots/john/doc.md
include zulip_bots/bots/foursquare/doc.md
include zulip_bots/bots/commute/doc.md include zulip_bots/bots/commute/doc.md
include zulip_bots/bots/encrypt/doc.md include zulip_bots/bots/converter/doc.md
include zulip_bots/bots/define/doc.md include zulip_bots/bots/define/doc.md
include zulip_bots/bots/helloworld/doc.md include zulip_bots/bots/encrypt/doc.md
include zulip_bots/bots/tictactoe/doc.md include zulip_bots/bots/foursquare/doc.md
include zulip_bots/bots/github_detail/doc.md
include zulip_bots/bots/git_hub_comment/doc.md
include zulip_bots/bots/googlesearch/doc.md include zulip_bots/bots/googlesearch/doc.md
include zulip_bots/bots/helloworld/doc.md
include zulip_bots/bots/howdoi/doc.md
include zulip_bots/bots/incrementor/doc.md
include zulip_bots/bots/john/doc.md
include zulip_bots/bots/tictactoe/doc.md
include zulip_bots/bots/virtual_fs/doc.md
include zulip_bots/bots/weather/doc.md
include zulip_bots/bots/xkcd/doc.md include zulip_bots/bots/xkcd/doc.md
include zulip_bots/bots/yoda/doc.md
include zulip_bots/bots/youtube/doc.md

View file

@ -0,0 +1,58 @@
#!/usr/bin/env python
import os
import glob
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
BOTS_DIR = os.path.normpath(os.path.join(CURRENT_DIR, 'zulip_bots', 'bots'))
def get_test_fixtures():
# type: () -> List[str]
glob_pattern = os.path.join(BOTS_DIR, '*', 'fixtures', '*.json')
fixtures_paths = map(
lambda fp: os.path.join(*fp.split(os.path.sep)[-5:]).replace(os.path.sep, '/'),
glob.glob(glob_pattern)
)
return fixtures_paths
def get_logos():
# type: () -> List[str]
glob_pattern = os.path.join(BOTS_DIR, '*', 'logo.*')
logo_paths = map(
lambda fp: os.path.join(*fp.split(os.path.sep)[-4:]).replace(os.path.sep, '/'),
glob.glob(glob_pattern)
)
return logo_paths
def get_docs():
# type: () -> List[str]
glob_pattern = os.path.join(BOTS_DIR, '*', 'doc.md')
doc_paths = map(
lambda fp: os.path.join(*fp.split(os.path.sep)[-4:]).replace(os.path.sep, '/'),
glob.glob(glob_pattern)
)
return doc_paths
def main():
# type: () -> None
manifest_path = os.path.join(CURRENT_DIR, 'MANIFEST.in')
with open(manifest_path, 'w') as fp:
template = 'include {line}\n'
fixtures = map(lambda line: template.format(line=line),
get_test_fixtures())
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__':
main()

View file

@ -5,6 +5,10 @@ from __future__ import print_function
import sys import sys
# Before anything, generate MANIFEST.in
import generate_manifest
generate_manifest.main()
# We should be installable with either setuptools or distutils. # We should be installable with either setuptools or distutils.
package_info = dict( package_info = dict(
name='zulip_bots', name='zulip_bots',