(env=None)
| 3817 | |
| 3818 | @contextlib.contextmanager |
| 3819 | def original_ld_library_path(env=None): |
| 3820 | # See: https://pyinstaller.readthedocs.io/en/stable/runtime-information.html |
| 3821 | # When running under pyinstaller, it will set an |
| 3822 | # LD_LIBRARY_PATH to ensure it prefers its bundled version of libs. |
| 3823 | # There are times when we don't want this behavior, for example when |
| 3824 | # running a separate subprocess. |
| 3825 | if env is None: |
| 3826 | env = os.environ |
| 3827 | |
| 3828 | # Unless the user provided an explicit value, set this so |
| 3829 | # PyInstaller resets the environment variables used by its |
| 3830 | # bootloader causing a subprocess to be treated as new. |
| 3831 | # This avoids interfering with starting another PyInstaller |
| 3832 | # process, such as the CLI using another instance of itself |
| 3833 | # as a credentials process. |
| 3834 | should_clear_pyinstaller_reset_environment = False |
| 3835 | if 'PYINSTALLER_RESET_ENVIRONMENT' not in env: |
| 3836 | env['PYINSTALLER_RESET_ENVIRONMENT'] = '1' |
| 3837 | should_clear_pyinstaller_reset_environment = True |
| 3838 | |
| 3839 | value_to_put_back = env.get('LD_LIBRARY_PATH') |
| 3840 | # The first case is where a user has exported an LD_LIBRARY_PATH |
| 3841 | # in their env. This will be mapped to LD_LIBRARY_PATH_ORIG. |
| 3842 | if 'LD_LIBRARY_PATH_ORIG' in env: |
| 3843 | env['LD_LIBRARY_PATH'] = env['LD_LIBRARY_PATH_ORIG'] |
| 3844 | else: |
| 3845 | # Otherwise if they didn't set an LD_LIBRARY_PATH we just need |
| 3846 | # to make sure this value is unset. |
| 3847 | env.pop('LD_LIBRARY_PATH', None) |
| 3848 | try: |
| 3849 | yield |
| 3850 | finally: |
| 3851 | if value_to_put_back is not None: |
| 3852 | env['LD_LIBRARY_PATH'] = value_to_put_back |
| 3853 | if should_clear_pyinstaller_reset_environment: |
| 3854 | env.pop('PYINSTALLER_RESET_ENVIRONMENT', None) |
| 3855 | |
| 3856 | |
| 3857 | class EventbridgeSignerSetter: |
no outgoing calls