Now that we are Python 3 only, it's fairly straightforward to enable things like
from .data import process_data
in the main.py of a directory style Bokeh server app. And even to have subpackages with __init__.py files work. This has been a fairly unpleasant pain point for some users.
A minimal diff just sets __path__ and __package__ but we will want to put it behind a flag so that it only happens for directory style apps:
diff --git a/bokeh/application/handlers/code_runner.py b/bokeh/application/handlers/code_runner.py
index 9b8c26f90..e1a75ae99 100644
--- a/bokeh/application/handlers/code_runner.py
+++ b/bokeh/application/handlers/code_runner.py
@@ -137,6 +137,9 @@ class CodeRunner(object):
module_name = 'bk_script_' + make_id().replace('-', '')
module = ModuleType(module_name)
module.__dict__['__file__'] = os.path.abspath(self._path)
+ module.__package__ = module_name
+ from os.path import dirname
+ module.__path__ = [dirname(self._path)]
return module
Now that we are Python 3 only, it's fairly straightforward to enable things like
in the
main.pyof a directory style Bokeh server app. And even to have subpackages with__init__.pyfiles work. This has been a fairly unpleasant pain point for some users.A minimal diff just sets
__path__and__package__but we will want to put it behind a flag so that it only happens for directory style apps: