@@ -17,7 +17,7 @@ defmodule Pythonx do
1717
1818 alias Pythonx.Object
1919
20- @ type python_config :: % __MODULE__ {
20+ @ type init_state :: % __MODULE__ {
2121 python_dl_path: String . t ( ) ,
2222 python_home_path: String . t ( ) ,
2323 python_executable_path: String . t ( ) ,
@@ -71,7 +71,21 @@ defmodule Pythonx do
7171 opts = Keyword . validate! ( opts , force: false , uv_version: Pythonx.Uv . default_uv_version ( ) )
7272
7373 Pythonx.Uv . fetch ( pyproject_toml , false , opts )
74- Pythonx.Uv . init ( pyproject_toml , false , Keyword . take ( opts , [ :uv_version ] ) )
74+ init_state = Pythonx.Uv . init ( pyproject_toml , false , Keyword . take ( opts , [ :uv_version ] ) )
75+ :persistent_term . put ( :pythonx_init_state , init_state )
76+ end
77+
78+ @ doc ~s'''
79+ Returns a map containing the environment variables required to initialize Pythonx.
80+ '''
81+ @ spec flame_env ( ) :: map ( )
82+ def flame_env ( ) do
83+ init_state =
84+ :persistent_term . get ( :pythonx_init_state )
85+ |> :erlang . term_to_binary ( )
86+ |> Base . encode64 ( )
87+
88+ % { "PYTHONX_FLAME_INIT_STATE" => init_state }
7589 end
7690
7791 # Initializes the Python interpreter.
@@ -124,7 +138,7 @@ defmodule Pythonx do
124138 Pythonx.NIF . init ( python_dl_path , python_home_path , python_executable_path , opts [ :sys_paths ] )
125139 end
126140
127- @ spec init ( python_config ( ) ) :: :ok
141+ @ spec init ( init_state ( ) ) :: :ok
128142 def init ( % __MODULE__ {
129143 python_dl_path: python_dl_path ,
130144 python_home_path: python_home_path ,
0 commit comments