gst-uninstalled: De-dedup before prepending to an env var

Helps us avoid breaching the maximum length limit for env var values
on Windows.
This commit is contained in:
Nirbheek Chauhan 2019-04-15 15:32:36 +05:30
parent 35e6c8b160
commit c786776f27

View file

@ -44,7 +44,12 @@ def stringify(o):
raise AssertionError('Object {!r} must be a string or a list'.format(o))
def prepend_env_var(env, var, value):
env[var] = os.pathsep + value + os.pathsep + env.get(var, "")
env_val = env.get(var, '')
val = os.pathsep + value + os.pathsep
# Don't add the same value twice
if val in env_val or env_val.startswith(value + os.pathsep):
return
env[var] = val + env_val
env[var] = env[var].replace(os.pathsep + os.pathsep, os.pathsep).strip(os.pathsep)