11import os
22import shutil
3+ from pathlib import Path
34
45import eel
56from PyQt5 .QtCore import QSettings
89from rlbot .parsing .agent_config_parser import create_looks_configurations , BOT_CONFIG_LOADOUT_HEADER , \
910 BOT_CONFIG_LOADOUT_ORANGE_HEADER , BOT_CONFIG_LOADOUT_PAINT_BLUE_HEADER , BOT_CONFIG_LOADOUT_PAINT_ORANGE_HEADER , \
1011 load_bot_appearance
11- from rlbot .parsing .bot_config_bundle import get_bot_config_bundle , get_script_config_bundle , RunnableConfigBundle
12+ from rlbot .parsing .bot_config_bundle import get_bot_config_bundle , get_script_config_bundle , RunnableConfigBundle , \
13+ BotConfigBundle
1214from rlbot .parsing .directory_scanner import scan_directory_for_bot_configs , scan_directory_for_script_configs
1315from rlbot .parsing .match_settings_config_parser import map_types , game_mode_types , \
1416 boost_amount_mutator_types , match_length_types , max_score_types , overtime_mutator_types , \
1517 series_length_mutator_types , game_speed_mutator_types , ball_max_speed_mutator_types , ball_type_mutator_types , \
1618 ball_weight_mutator_types , ball_size_mutator_types , ball_bounciness_mutator_types , rumble_mutator_types , \
1719 boost_strength_mutator_types , gravity_mutator_types , demolish_mutator_types , respawn_time_mutator_types , \
1820 existing_match_behavior_types
21+ from rlbot .utils .requirements_management import install_requirements_file
1922
2023from rlbot_gui .bot_management .bot_creation import bootstrap_python_bot , bootstrap_scratch_bot , \
2124 bootstrap_python_hivemind , convert_to_filename
@@ -68,7 +71,7 @@ def pick_bot_folder():
6871 return []
6972
7073
71- def serialize_bundle (bundle ):
74+ def serialize_bundle (bundle : BotConfigBundle ):
7275 return {
7376 'name' : bundle .name ,
7477 'type' : 'rlbot' ,
@@ -77,7 +80,8 @@ def serialize_bundle(bundle):
7780 'path' : bundle .config_path ,
7881 'looks_path' : bundle .looks_path ,
7982 'info' : read_info (bundle ),
80- 'logo' : try_copy_logo (bundle )
83+ 'logo' : try_copy_logo (bundle ),
84+ 'missing_python_packages' : [r .name for r in bundle .get_missing_python_packages ()],
8185 }
8286
8387
@@ -88,7 +92,8 @@ def serialize_script_bundle(bundle):
8892 'image' : 'imgs/rlbot.png' ,
8993 'path' : bundle .config_path ,
9094 'info' : read_info (bundle ),
91- 'logo' : try_copy_logo (bundle )
95+ 'logo' : try_copy_logo (bundle ),
96+ 'missing_python_packages' : [r .name for r in bundle .get_missing_python_packages ()],
9297 }
9398
9499
@@ -374,6 +379,20 @@ def install_package(package_string):
374379 return {'exitCode' : exit_code , 'package' : package_string }
375380
376381
382+ @eel .expose
383+ def install_requirements (config_path ):
384+ try :
385+ bundle = get_bot_config_bundle (config_path )
386+ except Exception :
387+ bundle = get_script_config_bundle (config_path )
388+
389+ if bundle .requirements_file :
390+ exit_code = install_requirements_file (bundle .requirements_file )
391+ return {'exitCode' : exit_code , 'package' : bundle .requirements_file }
392+ else :
393+ return {'exitCode' : 1 , 'package' : None }
394+
395+
377396def get_last_botpack_commit_id ():
378397 url = f'https://api.github.com/repos/{ BOTPACK_REPO_OWNER } /{ BOTPACK_REPO_NAME } /branches/{ BOTPACK_REPO_BRANCH } '
379398 try :
0 commit comments