def on_plugin_install(plugin_directory, ostream=sys.stdout):
current_directory = os.getcwd()<EOL>plugin_directory = ph.path(plugin_directory).realpath()<EOL>print(('<STR_LIT>'<EOL>'<STR_LIT:{}>'.format(plugin_directory.name)), file=ostream)<EOL>hooks_dir_i = plugin_directory.joinpath('<STR_LIT>').realpath()<EOL>hook_path_i = hooks_dir_i.joinpath('<STR_LIT>')<EOL>if hook_path_i.isfile():<EOL><INDENT>logger.info('<STR_LIT>',<EOL>plugin_directory.name)<EOL>os.chdir(hook_path_i.parent)<EOL>try:<EOL><INDENT>process = sp.Popen([hook_path_i, sys.executable], shell=True,<EOL>stdin=sp.PIPE)<EOL>process.communicate(input='<STR_LIT:\r\n>')<EOL>if process.returncode != <NUM_LIT:0>:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>.format(process.returncode))<EOL><DEDENT>return hook_path_i<EOL><DEDENT>except Exception as exception:<EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(hook_path_i,<EOL>exception))<EOL><DEDENT>finally:<EOL><INDENT>os.chdir(current_directory)<EOL><DEDENT><DEDENT>
Run ``on_plugin_install`` script for specified plugin directory (if
available).

**TODO** Add support for Linux, OSX.

Parameters
----------
plugin_directory : str
    File system to plugin directory.
ostream :file-like
    Output stream for status messages (default: ``sys.stdout``).