@plac.annotations(<EOL>input_dir=("<STR_LIT>", "<STR_LIT>", None, str),<EOL>output_dir=("<STR_LIT>", "<STR_LIT>", None, str),<EOL>meta_path=("<STR_LIT>", "<STR_LIT>", "<STR_LIT:m>", str),<EOL>create_meta=("<STR_LIT>", "<STR_LIT>", "<STR_LIT:c>", bool),<EOL>force=("<STR_LIT>", "<STR_LIT>", "<STR_LIT:f>", bool),<EOL>)<EOL>def package(input_dir, output_dir, meta_path=None, create_meta=False, force=False):
msg = Printer()<EOL>input_path = util.ensure_path(input_dir)<EOL>output_path = util.ensure_path(output_dir)<EOL>meta_path = util.ensure_path(meta_path)<EOL>if not input_path or not input_path.exists():<EOL><INDENT>msg.fail("<STR_LIT>", input_path, exits=<NUM_LIT:1>)<EOL><DEDENT>if not output_path or not output_path.exists():<EOL><INDENT>msg.fail("<STR_LIT>", output_path, exits=<NUM_LIT:1>)<EOL><DEDENT>if meta_path and not meta_path.exists():<EOL><INDENT>msg.fail("<STR_LIT>", meta_path, exits=<NUM_LIT:1>)<EOL><DEDENT>meta_path = meta_path or input_path / "<STR_LIT>"<EOL>if meta_path.is_file():<EOL><INDENT>meta = srsly.read_json(meta_path)<EOL>if not create_meta:  <EOL><INDENT>msg.good("<STR_LIT>", meta_path)<EOL><DEDENT>else:<EOL><INDENT>meta = generate_meta(input_dir, meta, msg)<EOL><DEDENT><DEDENT>for key in ("<STR_LIT>", "<STR_LIT:name>", "<STR_LIT:version>"):<EOL><INDENT>if key not in meta or meta[key] == "<STR_LIT>":<EOL><INDENT>msg.fail(<EOL>"<STR_LIT>".format(key),<EOL>"<STR_LIT>",<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT><DEDENT>model_name = meta["<STR_LIT>"] + "<STR_LIT:_>" + meta["<STR_LIT:name>"]<EOL>model_name_v = model_name + "<STR_LIT:->" + meta["<STR_LIT:version>"]<EOL>main_path = output_path / model_name_v<EOL>package_path = main_path / model_name<EOL>if package_path.exists():<EOL><INDENT>if force:<EOL><INDENT>shutil.rmtree(path2str(package_path))<EOL><DEDENT>else:<EOL><INDENT>msg.fail(<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(path=path2str(package_path)),<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT><DEDENT>Path.mkdir(package_path, parents=True)<EOL>shutil.copytree(path2str(input_path), path2str(package_path / model_name_v))<EOL>create_file(main_path / "<STR_LIT>", srsly.json_dumps(meta, indent=<NUM_LIT:2>))<EOL>create_file(main_path / "<STR_LIT>", TEMPLATE_SETUP)<EOL>create_file(main_path / "<STR_LIT>", TEMPLATE_MANIFEST)<EOL>create_file(package_path / "<STR_LIT>", TEMPLATE_INIT)<EOL>msg.good("<STR_LIT>".format(model_name_v), main_path)<EOL>msg.text("<STR_LIT>")<EOL>
Generate Python package for model data, including meta and required
installation files. A new directory will be created in the specified
output directory, and model data will be copied over. If --create-meta is
set and a meta.json already exists in the output directory, the existing
values will be used as the defaults in the command-line prompt.