Skip to content
Permalink
Browse files

Fix #12340 - Reload site to pick up new expressions package

  • Loading branch information
NathanW2 committed Jun 1, 2015
1 parent 4b6ad0c commit 738838acd4ed023e2a181fba4707e6425223315f
Showing with 3 additions and 0 deletions.
  1. +3 −0 python/user.py
@@ -44,6 +44,9 @@ def load_user_expressions(path):
if not os.path.exists(initfile):
open(initfile, "w").close()

import site
reload(site)

import expressions

expressions.load = load_user_expressions

10 comments on commit 738838a

@m-kuhn

This comment has been minimized.

Copy link
Member

m-kuhn replied Jun 1, 2015

It seems that the PyQgsAppStartup test fails since this commit.
(We should really get a green state again... it's a pain to find commits breaking stuff at the moment)

@NathanW2

This comment has been minimized.

Copy link
Member Author

NathanW2 replied Jun 1, 2015

@m-kuhn

This comment has been minimized.

Copy link
Member

m-kuhn replied Jun 1, 2015

@NathanW2

This comment has been minimized.

Copy link
Member Author

NathanW2 replied Jun 1, 2015

I'm not even sure why it's failing because doing it manually on the command line works as expected.

@m-kuhn

This comment has been minimized.

Copy link
Member

m-kuhn replied Jun 2, 2015

@NathanW2

This comment has been minimized.

Copy link
Member Author

NathanW2 replied Jun 2, 2015

@m-kuhn

This comment has been minimized.

Copy link
Member

m-kuhn replied Jun 2, 2015

@NathanW2

This comment has been minimized.

Copy link
Member Author

NathanW2 replied Jun 2, 2015

@wonder-sk

This comment has been minimized.

Copy link
Member

wonder-sk replied Jun 2, 2015

I am not sure about this fix... I do not understand why import + reload of site module should help. The site module is imported automatically when python starts and the docs do not suggest it is meant to be explicitly imported... It also imports sitecustomize module which may be doing some distro specific initialization (and some distros may not like to do it twice?). Finally I find the reload() function not very straightforward - this is a good reading: http://pyunit.sourceforge.net/notes/reloading.html

Maybe it would be enough to clear sys.path_importer_cache for the user's python directory?

@NathanW2

This comment has been minimized.

Copy link
Member Author

NathanW2 replied Jun 2, 2015

OK I will have a look into a better solution.

Please sign in to comment.
You can’t perform that action at this time.