After-stream commit.

This commit is contained in:
Kiri 2024-07-15 07:39:58 -07:00
parent f0cb6f7c1f
commit 39282b1a38
6 changed files with 71 additions and 14 deletions

View File

@ -0,0 +1,5 @@
mediapipe == 0.10.14
numpy == 1.26.0
psutil == 5.9.7
cv2-enumerate-cameras == 1.1.10

View File

@ -0,0 +1,10 @@
#!/usr/bin/python3
import time
a = 10
while a > 0:
print("asdf: ", a)
a -= 1
time.sleep(1)

View File

@ -17,13 +17,31 @@ func _ready():
#pw.stop_process() #pw.stop_process()
# #
pw = KiriPythonWrapperInstance.new( pw = KiriPythonWrapperInstance.new(
"res://SomePythonThingy/test_a_thing.py") "res://SomePythonThingy/test_a_thing.py")
pw.setup_python() pw.setup_python()
pw.start_process()
#print("running command...")
#var utility_script_path = pw.convert_cache_item_to_real_path(
#"res://SomePythonThingy/some_utility_script.py")
#var r1 = pw.run_python_command([utility_script_path], [], true)
#print("done running command... ", r1)
print("running command...")
var requirements_txt_path = pw.convert_cache_item_to_real_path(
"res://SomePythonThingy/requirements.txt")
var output_array = []
var r1 = pw.run_python_command(
["-m", "pip", "install", "-r", requirements_txt_path],
output_array, true, true)
print("done running command... ", r1)
print("OUTPUT WAS:", output_array[0])
pw.start_process(true)
print("Call thingy...") print("Call thingy...")
var ret = await pw.call_rpc_async("some_function_to_call", []) var ret = await pw.call_rpc_async("some_function_to_call", [])
print("Done thingy...") print("Done thingy...")

View File

@ -211,6 +211,7 @@ func unpack_python(overwrite : bool = false):
var cache_path_godot : String = _get_cache_path_godot() var cache_path_godot : String = _get_cache_path_godot()
# FIXME: !!! THIS CAN END UP WITH PARTIAL INSTALLS !!!
# Check to see if the Python executable already exists. If it does, we might # Check to see if the Python executable already exists. If it does, we might
# just skip unpacking. # just skip unpacking.
var python_executable_expected_path : String = \ var python_executable_expected_path : String = \

View File

@ -92,21 +92,40 @@ func get_status():
return KiriPythonWrapperStatus.STATUS_RUNNING return KiriPythonWrapperStatus.STATUS_RUNNING
func start_process(open_terminal : bool = false): func run_python_command(
args : PackedStringArray,
output : Array = [],
read_stderr : bool = false,
open_console : bool = false):
# FIXME: Make sure we don't have one running. var python_exe_path : String = _get_python_executable()
var open_port = 9500 # Do a little switcheroo on Linux to open a console.
if open_console:
if OS.get_name() == "Linux":
args = PackedStringArray(["-e", python_exe_path]) + args
python_exe_path = "xterm"
# Convert Python script path into a real path on the system. return OS.execute(python_exe_path, args, output, read_stderr, open_console)
var real_python_script_path = python_script_path
func convert_cache_item_to_real_path(path : String):
var real_python_script_path = path
if real_python_script_path.begins_with("res://"): if real_python_script_path.begins_with("res://"):
real_python_script_path = _build_wrangler._get_script_cache_path_system().path_join( real_python_script_path = _build_wrangler._get_script_cache_path_system().path_join(
real_python_script_path.substr(len("res://"))) real_python_script_path.substr(len("res://")))
else: else:
real_python_script_path = ProjectSettings.globalize_path( real_python_script_path = ProjectSettings.globalize_path(
real_python_script_path) real_python_script_path)
print("REAL PATH: ", real_python_script_path) return real_python_script_path
func start_process(open_terminal : bool = false):
# FIXME: Make sure we don't have one running.
var open_port = 9500
var real_python_script_path = convert_cache_item_to_real_path(
python_script_path)
assert(not _server_packet_socket) assert(not _server_packet_socket)
_server_packet_socket = KiriPacketSocket.new() _server_packet_socket = KiriPacketSocket.new()

View File

@ -9,11 +9,15 @@ Done:
x Fix whatever this is: <stuff was here> x Fix whatever this is: <stuff was here>
x example Python module from OUTSIDE the addon x example Python module from OUTSIDE the addon
x Remove xterm dependency, or make it like a debug-only thing. x Remove xterm dependency, or make it like a debug-only thing.
x Test on WINE/Windows.
x First-time setup of requirements (pip, etc).
The big ones: The big ones:
- First-time setup of requirements (pip, etc). - Deal with interrupted setup operations
- Test on WINE/Windows. - We check for the python.exe file in a given setup location to see if
we need to unpack stuff, but what if that exists but the setup was
interrupted and we're missing files?
- Documentation. - Documentation.
- how to use .kiri_export_python - how to use .kiri_export_python