def package_theme(app_name, build_dir,<EOL>excludes=None, includes=None, path_prefix=None,<EOL>template_dirs=None):
<EOL>templates_dest = os.path.join(build_dir, '<STR_LIT>')<EOL>orig_static_url = django_settings.STATIC_URL<EOL>if (app_name != settings.APP_NAME<EOL>and not django_settings.STATIC_URL.startswith('<STR_LIT:/>' + app_name)):<EOL><INDENT>django_settings.STATIC_URL = '<STR_LIT:/>' + app_name + orig_static_url<EOL><DEDENT>if not os.path.exists(templates_dest):<EOL><INDENT>os.makedirs(templates_dest)<EOL><DEDENT>if template_dirs is None:<EOL><INDENT>template_dirs = get_template_search_path(app_name)<EOL><DEDENT>for template_dir in template_dirs:<EOL><INDENT>if (templates_dest<EOL>and not os.path.samefile(template_dir, templates_dest)):<EOL><INDENT>install_templates(template_dir, templates_dest,<EOL>excludes=excludes, includes=includes, path_prefix=path_prefix)<EOL><DEDENT><DEDENT>
Package resources and templates for a multi-tier environment
into a zip file.

Templates are pre-compiled into ``*build_dir*/*app_name*/templates``.
Compilation means {% assets '*path*' %} and {% static '*path*' %} tags
are replaced by their compiled expression.