Skip to content

Commit

Permalink
Merge pull request #3155 from schandrika/sys_path_update_for_vcfg
Browse files Browse the repository at this point in the history
work around for issue #3154
  • Loading branch information
craig8 committed Mar 25, 2024
2 parents e98a043 + 7f088e0 commit 1ebc0b8
Showing 1 changed file with 26 additions and 42 deletions.
68 changes: 26 additions & 42 deletions volttron/platform/instance_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
from gevent.subprocess import Popen
from zmq import green as zmq

from requirements import extras_require
from volttron.platform import is_rabbitmq_available
from volttron.platform.auth import certs
from volttron.platform import jsonapi
Expand Down Expand Up @@ -350,12 +349,7 @@ def _get_dependencies():
return dependencies


def _check_dependencies_met(requirement):
try:
dependencies_needed = extras_require[requirement]
except KeyError:
print(f"ERROR: Requirement {requirement} was not found in requirements.py")
return False
def _check_dependencies_met(dependencies_needed):
current_dependencies = _get_dependencies()
for dependency in dependencies_needed:
if "==" in dependency:
Expand All @@ -372,15 +366,21 @@ def _check_dependencies_met(requirement):

def set_dependencies(requirement):
try:
# go up two level above env/bin
sys.path.append(os.path.dirname(os.path.dirname(sys.path[0])))
from requirements import extras_require
dependencies_needed = extras_require[requirement]
except KeyError:
print("ERROR: Incorrect requirement chosen")
print(f"ERROR: Incorrect requirement chosen: {requirement}")
return

if not _check_dependencies_met(dependencies_needed):
print(f"Installing {requirement} dependencies...")
cmds = [sys.executable, "-m", "pip", "install"]
for dependency in dependencies_needed:
cmds.append(dependency)
subprocess.check_call(cmds)
return
cmds = [sys.executable, "-m", "pip", "install"]
for dependency in dependencies_needed:
cmds.append(dependency)
subprocess.check_call(cmds)
return


def _create_web_certs():
Expand Down Expand Up @@ -907,10 +907,7 @@ def wizard():
prompt = 'Is this instance web enabled?'
response = prompt_response(prompt, valid_answers=y_or_n, default='N')
if response in y:
if not _check_dependencies_met('web'):
print("Web dependencies not installed. Installing now...")
set_dependencies('web')
print("Done!")
set_dependencies('web')
if config_opts['message-bus'] == 'rmq':
do_web_enabled_rmq(volttron_home)
elif config_opts['message-bus'] == 'zmq':
Expand All @@ -930,13 +927,9 @@ def wizard():
prompt = 'Will this instance be controlled by volttron central?'
response = prompt_response(prompt, valid_answers=y_or_n, default='Y')
if response in y:
if not _check_dependencies_met("drivers") or not _check_dependencies_met("web"):
print("VCP dependencies not installed. Installing now...")
if not _check_dependencies_met("drivers"):
set_dependencies("drivers")
if not _check_dependencies_met("web"):
set_dependencies("web")
print("Done!")
print("Checking for VCP dependencies.....")
set_dependencies("drivers")
set_dependencies("web")
do_vcp()

prompt = 'Would you like to install a platform historian?'
Expand All @@ -946,10 +939,8 @@ def wizard():
prompt = 'Would you like to install a platform driver?'
response = prompt_response(prompt, valid_answers=y_or_n, default='N')
if response in y:
if not _check_dependencies_met("drivers"):
print("Driver dependencies not installed. Installing now...")
set_dependencies("drivers")
print("Done!")
print("Checking Driver dependencies...")
set_dependencies("drivers")
do_platform_driver()

prompt = 'Would you like to install a listener agent?'
Expand All @@ -968,13 +959,9 @@ def wizard():
prompt = 'Will this instance be controlled by volttron central?'
response = prompt_response(prompt, valid_answers=y_or_n, default='Y')
if response in y:
if not _check_dependencies_met("drivers") or not _check_dependencies_met("web"):
print("VCP dependencies not installed. Installing now...")
if not _check_dependencies_met("drivers"):
set_dependencies("drivers")
if not _check_dependencies_met("web"):
set_dependencies("web")
print("Done!")
print("Checking VCP dependencies...")
set_dependencies("drivers")
set_dependencies("web")
do_vcp()

prompt = 'Would you like to install a platform historian?'
Expand All @@ -984,10 +971,8 @@ def wizard():
prompt = 'Would you like to install a platform driver?'
response = prompt_response(prompt, valid_answers=y_or_n, default='N')
if response in y:
if not _check_dependencies_met("drivers"):
print("Driver dependencies not installed. Installing now...")
set_dependencies("drivers")
print("Done!")
print("Checking Driver dependencies...")
set_dependencies("drivers")
do_platform_driver()

prompt = 'Would you like to install a listener agent?'
Expand Down Expand Up @@ -1128,10 +1113,9 @@ def process_rmq_inputs(args_dict, instance_name=None):

vhome = get_home()

if args_dict['installation-type'] in ['federation', 'shovel'] and not _check_dependencies_met('web'):
print("Web dependencies not installed. Installing now...")
if args_dict['installation-type'] in ['federation', 'shovel']:
print("Checking Web dependencies...")
set_dependencies('web')
print("Done!")

if args_dict['config'] is not None:
if not os.path.exists(vhome):
Expand Down

0 comments on commit 1ebc0b8

Please sign in to comment.