From ced1edc1157db6b1483a5c08ea008d9a1fb3de7a Mon Sep 17 00:00:00 2001 From: Brian May Date: Sat, 28 Oct 2023 13:18:49 +1100 Subject: [PATCH] Add karaage script --- flake.nix | 2 +- karaage/cli.py | 7 +++++++ manage.py | 19 +------------------ pyproject.toml | 3 +++ 4 files changed, 12 insertions(+), 19 deletions(-) create mode 100644 karaage/cli.py diff --git a/flake.nix b/flake.nix index 10ea775a6..17f609c1b 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ in { packages = { - karaage = mkPoetryApplication { + karaage = p2n.mkPoetryApplication { projectDir = self; overrides = p2n.overrides.withDefaults (final: prev: { #nh3 = prev.nh3.override { preferWheel = true; }; diff --git a/karaage/cli.py b/karaage/cli.py new file mode 100644 index 000000000..0ed4888cd --- /dev/null +++ b/karaage/cli.py @@ -0,0 +1,7 @@ +import os +import sys +from django.core.management import execute_from_command_line + +def manage(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'karaage.conf.settings') + execute_from_command_line(sys.argv) diff --git a/manage.py b/manage.py index 2592ea0e6..16a11dfcf 100755 --- a/manage.py +++ b/manage.py @@ -22,22 +22,5 @@ if __name__ == "__main__": os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'karaage.conf.settings') - - try: - from django.core.management import execute_from_command_line - except ImportError: - # The above import may fail for some other reason. Ensure that the - # issue is really that Django is missing to avoid masking other - # exceptions on Python 2. - execute_from_command_line = None - try: - import django # pylint:disable=unused-import - except ImportError: - django = None - 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?" - ) - raise + from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) diff --git a/pyproject.toml b/pyproject.toml index 39f84e1c6..250477d09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,3 +66,6 @@ build-backend = "poetry.core.masonry.api" [tool.black] line-length = 120 + +[tool.poetry.scripts] +karaage = "karaage.cli:manage"