Skip to content

Commit

Permalink
Merge pull request #2573 from lunkwill42/bugfix/broken-virtualenv-det…
Browse files Browse the repository at this point in the history
…ection

Detect current virtualenv in a more compatible way
lunkwill42 authored Mar 31, 2023
2 parents 9e21fac + ccd3042 commit b5597a9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/nav/config.py
Original file line number Diff line number Diff line change
@@ -42,7 +42,14 @@
'/etc/nav',
os.path.join(buildconf.datadir, 'conf'),
]
_venv = os.getenv('VIRTUAL_ENV')
# If running inside a virtualenv, add that virtualenv to the search path as well:
_base_prefix = (
# Detect the base prefix in a manner compatible with both old and new virtualenv
getattr(sys, "base_prefix", None)
or getattr(sys, "real_prefix", None)
or sys.prefix
)
_venv = sys.prefix if sys.prefix != _base_prefix else None
if _venv:
CONFIG_LOCATIONS = [
os.path.join(_venv, 'etc'),

0 comments on commit b5597a9

Please sign in to comment.