From ca09506e7d6ef6262918603469a27c5cd7e84060 Mon Sep 17 00:00:00 2001 From: "DavidCrompton1192@gmail.com" Date: Wed, 15 Mar 2023 23:04:46 -0400 Subject: [PATCH] Console Script Application --- deploy/flake.nix | 12 ++++-------- flake.nix | 3 +-- handyhelper/__init__.py | 1 + handyhelper/__main__.py | 6 ++++-- pyproject.toml | 3 +++ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/deploy/flake.nix b/deploy/flake.nix index 5931974..ccacc90 100644 --- a/deploy/flake.nix +++ b/deploy/flake.nix @@ -4,7 +4,7 @@ outputs = { self, nixpkgs, handyhelper }: let system = "x86_64-linux"; - handy_py = handyhelper.packages.${system}.handyhelper_pkg; + handy_py = handyhelper.packages.${system}.handyhelper; in { nixosConfigurations."staging" = nixpkgs.lib.nixosSystem { inherit system; @@ -16,13 +16,9 @@ wantedBy = ["networking-online.target"]; enable = true; serviceConfig = { - ExecStart = let - python = pkgs.python3.withPackages (p: with p; [ - handy_py - openai - ]); - in - "${python.interpreter} -m handyhelper"; + ExecStart = '' + ${handy_py}/bin/handyhelper + ''; }; }; }) diff --git a/flake.nix b/flake.nix index a52995b..8883870 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,7 @@ handyhelper = pkgs.runCommand "Handy Helper Deploy" { nativeBuildInputs = [ - packages.handyhelper_pkg + packages.handyhelper ]; } '' cat << 'DOC' >> $out @@ -46,7 +46,6 @@ DOC packages = { handyhelper = mkPoetryApplication { projectDir = self; }; - handyhelper_pkg = mkPoetryPackages { projectDir = self; }; default = self.packages.${system}.handyhelper; }; diff --git a/handyhelper/__init__.py b/handyhelper/__init__.py index 2d2ea0b..330565f 100644 --- a/handyhelper/__init__.py +++ b/handyhelper/__init__.py @@ -1 +1,2 @@ # Handle major modules of package +import * from ./__main__ diff --git a/handyhelper/__main__.py b/handyhelper/__main__.py index 7e0cbc2..e1b6a26 100644 --- a/handyhelper/__main__.py +++ b/handyhelper/__main__.py @@ -16,8 +16,10 @@ async def summarize( ): print("Will summarize article.") -# TODO: Import bot token from env -bot.run(os.environ["DISCORD_TOKEN"],) +def main(): + # TODO: Import bot token from env + bot.run(os.environ["DISCORD_TOKEN"]) + if __name__ == "__main__": print("Handy Helper has Begun!") diff --git a/pyproject.toml b/pyproject.toml index 4cec007..d78af6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,9 @@ authors = ["David Crompton"] license = "MIT" readme = "README.md" +[tool.poetry.scripts] +handyhelper = "handyhelper:main" + [tool.poetry.dependencies] python = "^3.10" requests = "^2.28.2"