Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building: do not attempt to expand env. vars in paths #8441

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

rokm
Copy link
Member

@rokm rokm commented Apr 29, 2024

Remove the compat.expand_path helper, and stop attempting to expand environment variables in paths given via --workpath, --distpath, --specpath, and --additional-hooks-dir.

The Windows implementation of expandvars found in ntpath translates $$ and %% into $ and %, respectively, which mangles the paths that contain such sequences (as literal characters, without using environment variables at all).

While the above issue could be worked around by duplicating characters in the problematic character sequences, the whole environment variable expansion in paths seems rather unnecessary. It was introduced in response to #696, which was caused by the fact that shell does not expand the tilde when using --argname=~/path/abc argument syntax instead of --argname ~/path/abc (or when the path argument is quoted).

As that seems like legitimate shortcoming, keep the tilde expansion part (os.path.expanduser) around, but remove the general environment variable expansion attempts (os.path.expandvars), which should be left to the shell.

Remove the `compat.expand_path` helper, and stop attempting to
expand environment variables in paths given via `--workpath`,
`--distpath`, `--specpath`, and `--additional-hooks-dir`.

The Windows implementation of `expandvars` found in `ntpath`
translates `$$` and `%%` into `$` and `%`, respectively, which
mangles the paths that contain such sequences (as literal characters,
without using environment variables at all).

While the above issue could be worked around by duplicating characters
in the problematic character sequences, the whole environment
variable expansion in paths seems rather unnecessary. It was introduced
in response to pyinstaller#696, which was caused by the fact that shell does
not expand the tilde when using `--argname=~/path/abc` argument syntax
instead of `--argname ~/path/abc` (or when the path argument is
quoted).

As that seems like legitimate shortcoming, keep the tilde expansion
part (`os.path.expanduser`) around, but remove the general environment
variable expansion attempts (`os.path.expandvars`), which should
be left to the shell.
@rokm rokm merged commit 22f073b into pyinstaller:develop Apr 30, 2024
18 checks passed
@rokm rokm deleted the remove-envvar-expansion-from-paths branch April 30, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants