Make Funkwhale configuration independend from install location
The following discussion from !2283 (merged) should be addressed:
-
@georgkrause started a discussion: (+7 comments) I get the following on a ansible-install, might be doing something wrong, though:
fw@ansible-testing:/srv/funkwhale$ ./virtualenv/bin/funkwhale-manage migrate 2023-01-08 14:41:54,292 funkwhale_api.config INFO Running with the following plugins enabled: funkwhale_api.contrib.scrobbler, funkwhale_api.contrib.listenbrainz, funkwhale_api.contrib.maloja 2023-01-08 14:41:54,298 funkwhale_api.config INFO Running with the following plugins enabled: funkwhale_api.contrib.scrobbler, funkwhale_api.contrib.listenbrainz, funkwhale_api.contrib.maloja Traceback (most recent call last): File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/environ/environ.py", line 403, in get_value value = self.ENVIRON[var_name] File "/usr/lib/python3.9/os.py", line 679, in __getitem__ raise KeyError(key) from None KeyError: 'FUNKWHALE_URL' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/srv/funkwhale/./virtualenv/bin/funkwhale-manage", line 8, in <module> sys.exit(main()) File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/funkwhale_api/main.py", line 30, in main execute_from_command_line(sys.argv) File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/core/management/base.py", line 86, in wrapped saved_locale = translation.get_language() File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/utils/translation/__init__.py", line 254, in get_language return _trans.get_language() File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__ if settings.USE_I18N: File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name) File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module) File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 790, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/config/settings/production.py", line 12, in <module> from .common import * # noqa File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/config/settings/common.py", line 163, in <module> FUNKWHALE_URL = env("FUNKWHALE_URL") File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/environ/environ.py", line 197, in __call__ return self.get_value( File "/srv/funkwhale/virtualenv/lib/python3.9/site-packages/environ/environ.py", line 407, in get_value raise ImproperlyConfigured(error_msg) from exc django.core.exceptions.ImproperlyConfigured: Set the FUNKWHALE_URL environment variable
@jooola any hints?
Reply by @jooola:
I really don't like:
Which assume way to much on where funkwhale is installed. I would recommend using Path.cwd() or os.getcwd() with only relative paths.