MCPcopy Create free account
hub / github.com/StackStorm/st2 / setup_virtualenvs

Function setup_virtualenvs

st2common/st2common/content/bootstrap.py:109–169  ·  view source on GitHub ↗

Setup Python virtual environments for all the registered or the provided pack.

(recreate_virtualenvs=False)

Source from the content-addressed store, hash-verified

107
108
109def setup_virtualenvs(recreate_virtualenvs=False):
110 """
111 Setup Python virtual environments for all the registered or the provided pack.
112 """
113
114 LOG.info("=========================================================")
115 LOG.info("########### Setting up virtual environments #############")
116 LOG.info("=========================================================")
117 pack_dir = cfg.CONF.register.pack
118 fail_on_failure = not cfg.CONF.register.no_fail_on_failure
119
120 registrar = ResourceRegistrar()
121
122 if pack_dir:
123 pack_name = os.path.basename(pack_dir)
124 pack_names = [pack_name]
125
126 # 1. Register pack
127 registrar.register_pack(pack_name=pack_name, pack_dir=pack_dir)
128 else:
129 # 1. Register pack
130 base_dirs = content_utils.get_packs_base_paths()
131 registrar.register_packs(base_dirs=base_dirs)
132
133 # 2. Retrieve available packs (aka packs which have been registered)
134 pack_names = registrar.get_registered_packs()
135
136 if recreate_virtualenvs:
137 """
138 update = False:
139 this is more than an update of an existing virtualenv
140 the virtualenv itself will be removed & recreated
141 this is i.e. useful for updates to a newer Python release
142 """
143 update = False
144 else:
145 """
146 update = True:
147 only dependencies inside the virtualenv will be updated
148 """
149 update = True
150
151 setup_count = 0
152 for pack_name in pack_names:
153 try:
154 setup_pack_virtualenv(pack_name=pack_name, update=update, logger=LOG)
155 except Exception as e:
156 exc_info = not fail_on_failure
157 LOG.warning(
158 'Failed to setup virtualenv for pack "%s": %s',
159 pack_name,
160 e,
161 exc_info=exc_info,
162 )
163
164 if fail_on_failure:
165 raise e
166 else:

Callers 1

register_contentFunction · 0.85

Calls 5

register_packMethod · 0.95
register_packsMethod · 0.95
get_registered_packsMethod · 0.95
ResourceRegistrarClass · 0.90
setup_pack_virtualenvFunction · 0.90

Tested by

no test coverage detected