New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extension implementation load path problems in apps #5315

bryevdv opened this Issue Oct 5, 2016 · 3 comments



bryevdv commented Oct 5, 2016

see ref: #5304


This comment has been minimized.


bryevdv commented Oct 24, 2016

@mattpap I believe the root cause of this has to do with the cwd is set when the app is run. It works for "directory style" apps, but I am fairly certain it does not work well with single file apps.


This comment has been minimized.


mattpap commented Oct 24, 2016

@bryevdv, it's "directory style" apps that don't work in particular and the problem is in cwd (and some other factors, including Python's simplicty).

In we have the following code:

sys.path.insert(0, '')

This makes manual setting of __imlementation__ work, but not logic in custom module compiler. The reason is the custom models are resolved at later time, when those two lines aren't in effect anymore, and because Python graciously resolves module paths as relative if a module is run from the current directory and it's path is on sys.path (both conditions are met here) and as absolute otherwise. Don't know why anyone would invent such a thing, besides making things aesthetically pleasing, but this was fixed in 3.4. The only non-obtrusive solution I found, is to replace those two lines with:

sys.path.insert(0, os.path.dirname(self._path))

where self._path is already absolute. This makes both:

__implementation__ = open(join(dirname(__file__), "")).read()


__implementation__ = ""

work at the same time. Obviously current directory is now set to wherever bin/bokeh was run from. I didn't yet fully analyzed this, but this may not have any negative effect, because we uniformly used __file__ to derive location of auxiliary files.


This comment has been minimized.


bryevdv commented Dec 7, 2016

Migration note: we will no longer os.chdir into app directories, but __file__ will have correct path that can be used with open, etc. (which we already demonstrate, but let's underscore this more)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment