feat: create funkwhale-manage entrypoint
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2191>
This commit is contained in:
parent
29693806db
commit
6f2ecf832c
|
@ -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()
|
|
@ -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)
|
|
|
@ -20,6 +20,9 @@ include = [
|
||||||
]
|
]
|
||||||
exclude = ["tests"]
|
exclude = ["tests"]
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
funkwhale-manage = 'funkwhale_api.main:main'
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.7"
|
python = "^3.7"
|
||||||
Django = "==3.2.16"
|
Django = "==3.2.16"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Create the funkwhale-manage entrypoint in the api package
|
Loading…
Reference in New Issue