-
Notifications
You must be signed in to change notification settings - Fork 621
Add Architecture-Specific PATH Management for Python with --user Flag on Windows #1122
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
base: main
Are you sure you want to change the base?
Add Architecture-Specific PATH Management for Python with --user Flag on Windows #1122
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request improves the PATH configuration for Windows Python installations when using the --user flag by adding architecture-specific directory handling for Python 3.10+ and adjusting for freethreaded builds.
- Moves a debug log to a new location
- Introduces new logic to append architecture-specific suffixes to the PATH for Windows
- Updates the construction of the user Scripts directory
Comments suppressed due to low confidence (1)
src/find-python.ts:164
- [nitpick] Consider clarifying the conditional handling of the architecture. Using explicit variables or abstractions for base architecture and freethreaded variations can reduce confusion between 'x86' and 'x86-freethreaded' cases.
if (architecture === 'x86' && (major > 3 || (major === 3 && minor >= 10))) {
// Append '-32' for x86 architecture if Python version is >= 3.10 | ||
if ( | ||
architecture === 'x86' && | ||
(major > 3 || (major === 3 && minor >= 10)) | ||
) { | ||
versionSuffix += '-32'; | ||
} else if (architecture === 'arm64') { | ||
versionSuffix += '-arm64'; | ||
} | ||
// Append 't' for freethreaded builds | ||
if (freethreaded) { | ||
versionSuffix += 't'; | ||
if (architecture === 'x86-freethreaded') { | ||
versionSuffix += '-32'; | ||
} else if (architecture === 'arm64-freethreaded') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider refactoring the nested freethreaded logic to clearly separate the base architecture check from freethreaded adjustments. This may help prevent potential misconfigurations when combining freethreaded and architecture-specific suffixes.
// Append '-32' for x86 architecture if Python version is >= 3.10 | |
if ( | |
architecture === 'x86' && | |
(major > 3 || (major === 3 && minor >= 10)) | |
) { | |
versionSuffix += '-32'; | |
} else if (architecture === 'arm64') { | |
versionSuffix += '-arm64'; | |
} | |
// Append 't' for freethreaded builds | |
if (freethreaded) { | |
versionSuffix += 't'; | |
if (architecture === 'x86-freethreaded') { | |
versionSuffix += '-32'; | |
} else if (architecture === 'arm64-freethreaded') { | |
// Determine base architecture suffix | |
if (architecture === 'x86' && (major > 3 || (major === 3 && minor >= 10))) { | |
versionSuffix += '-32'; | |
} else if (architecture === 'arm64') { | |
versionSuffix += '-arm64'; | |
} | |
// Adjust for freethreaded builds | |
if (freethreaded) { | |
versionSuffix += 't'; | |
if (architecture.includes('x86')) { | |
versionSuffix += '-32'; | |
} else if (architecture.includes('arm64')) { |
Copilot uses AI. Check for mistakes.
Description:
This update modifies the PATH handling for Python installations on Windows, specifically for the --user flag. For Python 3.10 and above, architecture-specific directories (e.g., Python310-32) are added to the PATH, while for earlier versions, the default --user path is used. This ensures proper environment configuration for user-installed Python versions based on version and architecture.
Related issue:
#1005