Skip to content

Commit 8f0e5cc

Browse files
pipcl.py: swig_get(): fix use of bison on MacOS.
* swig_get(): install bison. * macos_add_brew_path(): fail if no relevent directories exist. This avoids confusion if the package is not installed.
1 parent dfe809d commit 8f0e5cc

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pipcl.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ def log2(text='', caller=1):
29452945

29462946
def _log(text, level, caller):
29472947
'''
2948-
Logs lines with prefix, if <level> is lower than <g_verbose>.
2948+
Logs lines with prefix, if <level> is lower or equal to <g_verbose>.
29492949
'''
29502950
if level <= g_verbose:
29512951
fr = inspect.stack(context=0)[caller]
@@ -3207,6 +3207,7 @@ def swig_get(swig, quick, swig_local='pipcl-swig-git'):
32073207
if darwin():
32083208
run(f'brew install automake')
32093209
run(f'brew install pcre2')
3210+
run(f'brew install bison')
32103211
# Default bison doesn't work, and Brew's bison is not added to $PATH.
32113212
#
32123213
# > bison is keg-only, which means it was not symlinked into /opt/homebrew,
@@ -3235,6 +3236,8 @@ def macos_add_brew_path(package, env=None, gnubin=True):
32353236
'''
32363237
Adds path(s) for Brew <package>'s binaries to env['PATH'].
32373238
3239+
We assert-fail if the relevant directory does no exist.
3240+
32383241
Args:
32393242
package:
32403243
Name of package. We get <package_root> of installed package by
@@ -3253,14 +3256,22 @@ def macos_add_brew_path(package, env=None, gnubin=True):
32533256
if 'PATH' not in env:
32543257
env['PATH'] = os.environ['PATH']
32553258
package_root = run(f'brew --prefix {package}', capture=1).strip()
3259+
log(f'{package=} {package_root=}')
32563260
def add(path):
3261+
log(f'{path=}')
32573262
if os.path.isdir(path):
3258-
log1(f'Adding to $PATH: {path}')
3263+
log(f'Prepending to $PATH: {path}')
32593264
PATH = env['PATH']
32603265
env['PATH'] = f'{path}:{PATH}'
3261-
add(f'{package_root}/bin')
3266+
return 1
3267+
else:
3268+
log(f'Not a directory: {path=}')
3269+
return 0
3270+
n = 0
3271+
n += add(f'{package_root}/bin')
32623272
if gnubin:
3263-
add(f'{package_root}/libexec/gnubin')
3273+
n += add(f'{package_root}/libexec/gnubin')
3274+
assert n, f'Failed to add to $PATH, {package=} {gnubin=}.'
32643275

32653276

32663277
def _show_dict(d):

0 commit comments

Comments
 (0)