Skip to content

Commit e634022

Browse files
committed
Ensure that configure runs quiet and release works #941
* somehow if was failing for the release Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 81346a5 commit e634022

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

etc/configure.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def call(cmd, root_dir):
103103
if subprocess.Popen(cmd, shell=True, env=dict(os.environ), cwd=root_dir).wait() != 0:
104104
print()
105105
print('Failed to execute command:\n%(cmd)s. Aborting...' % locals())
106-
print(usage)
107106
sys.exit(1)
108107

109108

@@ -199,7 +198,6 @@ def create_virtualenv(std_python, root_dir, tpp_dirs, quiet=False):
199198
# error out if venv_py not found
200199
if not venv_py:
201200
print("Configuration Error ... aborting.")
202-
print(usage)
203201
exit(1)
204202

205203
vcmd = [std_python, venv_py, '--never-download']
@@ -214,7 +212,6 @@ def create_virtualenv(std_python, root_dir, tpp_dirs, quiet=False):
214212

215213
def activate(root_dir):
216214
""" Activate a virtualenv in the current process."""
217-
# print("* Activating...")
218215
bin_dir = os.path.join(root_dir, 'bin')
219216
activate_this = os.path.join(bin_dir, 'activate_this.py')
220217
with open(activate_this) as f:
@@ -229,7 +226,7 @@ def install_3pp(configs, root_dir, tpp_dirs, quiet=False):
229226
"""
230227
if not quiet:
231228
print("* Installing components ...")
232-
requirement_files = get_conf_files(configs, root_dir, requirements)
229+
requirement_files = get_conf_files(configs, root_dir, requirements, quiet)
233230
for req_file in requirement_files:
234231
pcmd = ['pip', 'install', '--no-allow-external',
235232
'--use-wheel', '--no-index', '--no-cache-dir']
@@ -274,7 +271,7 @@ def chmod_bin(directory):
274271
os.chmod(os.path.join(path, f), rwx)
275272

276273

277-
def get_conf_files(config_dir_paths, root_dir, file_names=requirements):
274+
def get_conf_files(config_dir_paths, root_dir, file_names=requirements, quiet=False):
278275
"""
279276
Return a list of collected path-prefixed file paths matching names in a
280277
file_names tuple, based on config_dir_paths, root_dir and the types of
@@ -302,11 +299,10 @@ def get_conf_files(config_dir_paths, root_dir, file_names=requirements):
302299
for config_dir_path in config_dir_paths:
303300
abs_config_dir_path = os.path.join(root_dir, config_dir_path)
304301
if not os.path.exists(abs_config_dir_path):
305-
print('Configuration directory %(config_dir_path)s '
306-
'does not exists.' % locals())
307-
print(usage)
308-
sys.exit(1)
309-
302+
if not quiet:
303+
print('Configuration directory %(config_dir_path)s '
304+
'does not exists. Skipping.' % locals())
305+
continue
310306
# Support args like enterprise or enterprise/dev
311307
paths = config_dir_path.strip('/').replace('\\', '/').split('/')
312308
# a tuple of (relative path, location,)
@@ -335,6 +331,9 @@ def get_conf_files(config_dir_paths, root_dir, file_names=requirements):
335331

336332
if __name__ == '__main__':
337333

334+
# you must create a CONFIGURE_QUIET env var if you want to run quietly
335+
quiet = 'CONFIGURE_QUIET' in os.environ
336+
338337
# define/setup common directories
339338
etc_dir = os.path.abspath(os.path.dirname(__file__))
340339
root_dir = os.path.dirname(etc_dir)
@@ -354,9 +353,6 @@ def get_conf_files(config_dir_paths, root_dir, file_names=requirements):
354353
bin_dir = os.path.join(root_dir, 'bin')
355354
standard_python = sys.executable
356355

357-
# you must create a CONFIGURE_QUIET env var if you want to run quietly
358-
run_quiet = 'CONFIGURE_QUIET' in os.environ
359-
360356
if on_win:
361357
configured_python = os.path.join(bin_dir, 'python.exe')
362358
scripts_dir = os.path.join(root_dir, 'Scripts')
@@ -396,24 +392,24 @@ def get_conf_files(config_dir_paths, root_dir, file_names=requirements):
396392
if not os.path.isabs(path):
397393
abs_path = os.path.join(root_dir, path)
398394
if not os.path.exists(abs_path):
399-
print()
400-
print('ERROR: Third-party Python libraries directory does not exists:\n'
401-
' %(path)r: %(abs_path)r\n'
402-
' Provided by environment variable:\n'
403-
' set %(envvar)s=%(path)r' % locals())
404-
print(usage)
405-
sys.exit(1)
406-
407-
thirdparty_dirs.append(path)
395+
if not quiet:
396+
print()
397+
print('WARNING: Third-party Python libraries directory does not exists:\n'
398+
' %(path)r: %(abs_path)r\n'
399+
' Provided by environment variable:\n'
400+
' set %(envvar)s=%(path)r' % locals())
401+
print()
402+
else:
403+
thirdparty_dirs.append(path)
408404

409405
# Finally execute our three steps: venv, install and scripts
410406
if not os.path.exists(configured_python):
411-
create_virtualenv(standard_python, root_dir, thirdparty_dirs, quiet=run_quiet)
407+
create_virtualenv(standard_python, root_dir, thirdparty_dirs, quiet=quiet)
412408
activate(root_dir)
413409

414-
install_3pp(configs, root_dir, thirdparty_dirs, quiet=run_quiet)
415-
run_scripts(configs, root_dir, configured_python, quiet=run_quiet)
410+
install_3pp(configs, root_dir, thirdparty_dirs, quiet=quiet)
411+
run_scripts(configs, root_dir, configured_python, quiet=quiet)
416412
chmod_bin(bin_dir)
417-
if not run_quiet:
413+
if not quiet:
418414
print("* Configuration completed.")
419415
print()

0 commit comments

Comments
 (0)