feat: create funkwhale-manage entrypoint

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2191>
environments/review-docs-fix-b-0p3p4g/deployments/16281
jo 2022-11-23 20:35:53 +01:00
rodzic 29693806db
commit 6f2ecf832c
4 zmienionych plików z 38 dodań i 29 usunięć

Wyświetl plik

@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
try:
import django
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
if len(sys.argv) > 1 and sys.argv[1] in ["fw", "funkwhale"]:
django.setup()
from funkwhale_api.cli import main as cli
sys.argv = sys.argv[1:]
cli.invoke()
else:
execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()

Wyświetl plik

@ -1,29 +0,0 @@
#!/usr/bin/env python3
import os
import sys
import django
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
# we're doing this here since otherwise, missing environment
# files in settings result in AttributeError being raised, generating
# a cryptic django.core.exceptions.AppRegistryNotReady error.
# To prevent that, we explicitly load settings here before anything
# else, so we fail fast with a relevant error. See #140 for more details.
django.setup()
from django.core.management import execute_from_command_line
if len(sys.argv) > 1 and sys.argv[1] in ["fw", "funkwhale"]:
# trigger our own click-based cli
from funkwhale_api.cli import main
sys.argv = sys.argv[1:]
main.invoke()
else:
execute_from_command_line(sys.argv)

Wyświetl plik

@ -20,6 +20,9 @@ include = [
]
exclude = ["tests"]
[tool.poetry.scripts]
funkwhale-manage = 'funkwhale_api.main:main'
[tool.poetry.dependencies]
python = "^3.7"
Django = "==3.2.16"

Wyświetl plik

@ -0,0 +1 @@
Create the funkwhale-manage entrypoint in the api package