Skip to content

Commit

Permalink
conftest: macOS: have pyi_builder set up minimal PATH
Browse files Browse the repository at this point in the history
On macOS, have the `pyi_builder` set up minimal `PATH` before running
the test executable. The minimal `PATH` encompasses system directories
that are also available to applications ran via Finder, a subset
of what is typically available in the shell: `/usr/bin`, `/bin`,
`/usr/sbin`, and `/sbin`.

This accommodates tested python packages that make use of system
utilities - for example, `matplotlib` 3.9.0 started querying system
fonts by running `system_profiler`, which is found in `/usr/sbin`.
  • Loading branch information
rokm committed May 19, 2024
1 parent 4f111a7 commit 6765848
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions PyInstaller/utils/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ def _run_executable(self, prog, args, run_from_path, runtime):
if is_win:
# Minimum Windows PATH is in most cases: C:\Windows\system32;C:\Windows
prog_env['PATH'] = os.pathsep.join(winutils.get_system_path())
# On macOS, we similarly set up minimal PATH with system directories, in case utilities from there are used by
# tested python code (for example, matplotlib >= 3.9.0 uses `system_profiler` that is found in /usr/sbin).
if is_darwin:
# The following paths are registered when application is launched via Finder, and are a subset of what is
# typically available in the shell.
prog_env['PATH'] = os.pathsep.join(['/usr/bin', '/bin', '/usr/sbin', '/sbin'])

exe_path = prog
if run_from_path:
Expand Down

0 comments on commit 6765848

Please sign in to comment.