Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #12340 - Reload site to pick up new expressions package
  • Loading branch information
NathanW2 committed Jun 1, 2015
1 parent 4b6ad0c commit 738838a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/user.py
Expand Up @@ -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
Expand Down

10 comments on commit 738838a

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on 738838a Jun 1, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

@NathanW2 NathanW2 commented on 738838a Jun 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on 738838a Jun 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NathanW2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on 738838a Jun 2, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NathanW2
Copy link
Member Author

@NathanW2 NathanW2 commented on 738838a Jun 2, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on 738838a Jun 2, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NathanW2
Copy link
Member Author

@NathanW2 NathanW2 commented on 738838a Jun 2, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wonder-sk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will have a look into a better solution.

Please sign in to comment.