You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adds fallback to newly created environment block for known OS variables. - #432
This PR addresses #427 by recovering missing Windows environment variables during configuration loading, helping prevent Python Manager from resolving installation paths against the working directory.
Changes:
Adds a native helper to generate a default Windows environment and exposes it through both builds.
Adds configuration fallback lookups and rejects empty substitutions before path separators.
Adds absolute-path detection and tests for configuration expansion and fallback behavior.
File
Description
tests/test_pathutils.py
Tests absolute and relative Windows paths.
tests/test_config.py
Tests missing variables, fallback values, and configuration resolution.
src/manage/pathutils.py
Adds absolute-path detection.
src/manage/config.py
Adds environment fallback and stricter substitution handling.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Explicit environment mappings are ignored when empty and are not forwarded during nested configuration resolution.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Forward environ when resolving nested settings
src/manage/config.py:259
The new environ argument is not forwarded by the recursive call on line 275. Nested settings such as install.source and list.format therefore use the process environment instead of the supplied mapping, unlike top-level settings. A value consisting solely of a variable supplied only in that mapping is silently removed. Forward environ when resolving nested schemas so all levels use the same environment.
An explicitly supplied empty environment is ignored because {} is falsy. For example, resolving %AppData%/Python with environ={} reads the process environment and OS fallbacks instead of reporting the missing variable. Select the default only when environ is None so an intentionally empty mapping is respected.
Reject empty substitutions in path-valued settings
src/manage/config.py:254
This only raises when the placeholder is followed by a path separator. A path-valued setting whose entire value is %TEMP% or %AppData% still expands to an empty string, and resolve_config then deletes the setting, allowing a later default (such as the current directory) instead of failing as promised. Apply strict empty-substitution validation to path-valued settings while preserving optional expansion for non-path settings.
Return a boolean from is_absolute drive-root check
src/manage/pathutils.py:110
drive and root returns the root string rather than a boolean (for example, an absolute drive path returns "\\"). That makes is_absolute() type-inconsistent with the pathlib-style API and breaks callers that use is True or otherwise require a boolean; return bool(drive and root) instead.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved moderate issues remain in log-directory fallback, empty-variable validation without separators, and UNC-path absolute detection.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Log path still falls back to the current working directory
src/manage/config.py:190
Adding TEMP/TMP here does not protect the log path in the reported minimal-environment case: BaseCommand.get_log_file() still calls os.getenv("TMP") or os.getenv("TEMP") or os.getcwd(), so when both variables are absent it writes into the caller's current directory. Please route log-directory resolution through the same fallback environment (or fail rather than choosing the CWD), otherwise this part of #427 remains reproducible.
My other important change needs to build on this, and I don't think this is going to get properly exercised without a beta release (and probably not even without a full release), so I'm merging based on the Copilot reviews being clean (the log path fallback is intentional and won't be changed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes it a hard failure for environment variables in paths to be empty.
Fixes #427