mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 21:19:26 -02: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:
@@ -4,6 +4,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
import site
|
||||||
|
|
||||||
__version__ = '2.3.0'
|
__version__ = '2.3.0'
|
||||||
|
|
||||||
@@ -39,7 +40,10 @@ def prepare_env():
|
|||||||
# Add local site-packages directory to path.
|
# Add local site-packages directory to path.
|
||||||
local_site_packages = os.path.join(os.path.dirname(__file__), 'lib',
|
local_site_packages = os.path.join(os.path.dirname(__file__), 'lib',
|
||||||
'site-packages')
|
'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
|
# Hide DeprecationWarnings when running in production. Need to first load
|
||||||
# settings to apply our filter after Django's own warnings filter.
|
# settings to apply our filter after Django's own warnings filter.
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
Reference in New Issue
Block a user