Skip to content

Commit

Permalink
feat(python): externally configurable python exe/dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt committed Jul 25, 2024
1 parent ba21742 commit 917812d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ config :ex_unit,
# By default, Nostrum requires ffmpeg to use voice.
config :nostrum, :ffmpeg, false

config :stampede,
python_exe: System.fetch_env!("FLAKE_PYTHON"),
python_plugin_dirs: ["./lib_py"]

for config <- "./*.secret.exs" |> Path.expand(__DIR__) |> Path.wildcard() do
import_config config
end
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@

# define shell startup command
sh-hook = ''
export FLAKE_PYTHON="${python}/bin/python3"
# this allows mix to work on the local directory
mkdir -p .nix-mix
mkdir -p .nix-hex
Expand Down
6 changes: 5 additions & 1 deletion lib/stampede/plugin_foreign/python.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
defmodule Stampede.PluginForeign.Python.Pool do
@moduledoc false
use Doumi.Port,
adapter: {Doumi.Port.Adapter.Python, python_path: ["./lib_py"]},
adapter: {
Doumi.Port.Adapter.Python,
python: Application.fetch_env!(:stampede, :python_exe),
python_path: Application.fetch_env!(:stampede, :python_plugin_dirs)
},
pool_size: 4
end

Expand Down
6 changes: 2 additions & 4 deletions lib_py/example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import (
Optional,
Dict
)
from typing import Optional, Dict


def process(cfg, event) -> Optional[Dict]:
if event[b"body"] == b"ping python":
Expand Down

0 comments on commit 917812d

Please sign in to comment.