mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Properly handle namespace packages (oslo, dogpile)
Using `site.addsitedir()` handles namespace packages, where the traditional `sys.path.insert` does not. Kudos to Chris Meyers for this discovery.
This commit is contained in:
parent
32a4a941e0
commit
51e2120886
@ -4,6 +4,7 @@
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
import site
|
||||
|
||||
__version__ = '2.3.0'
|
||||
|
||||
@ -39,7 +40,10 @@ def prepare_env():
|
||||
# Add local site-packages directory to path.
|
||||
local_site_packages = os.path.join(os.path.dirname(__file__), 'lib',
|
||||
'site-packages')
|
||||
sys.path.insert(0, local_site_packages)
|
||||
site.addsitedir(local_site_packages)
|
||||
# Work around https://bugs.python.org/issue7744
|
||||
# by moving local_site_packages to the front of sys.path
|
||||
sys.path.insert(0, sys.path.pop())
|
||||
# Hide DeprecationWarnings when running in production. Need to first load
|
||||
# settings to apply our filter after Django's own warnings filter.
|
||||
from django.conf import settings
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user