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

Add Architecture-Specific PATH Management for Python with --user Flag on Windows for x86 #1039

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99611,8 +99611,18 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
const version = path.basename(path.dirname(installDir));
const major = semver.major(version);
const minor = semver.minor(version);
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
core.addPath(userScriptsDir);
if (architecture === 'x86' &&
(major > 3 || (major === 3 && minor >= 10))) {
// For Python >= 3.10 and architecture= 'x86', add the architecture-specific folder to the path
const arch = '32';
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts');
core.addPath(userScriptsDir);
}
else {
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
// Add the default path to the environment PATH variable
core.addPath(userScriptsDir);
}
}
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
}
Expand Down
32 changes: 25 additions & 7 deletions src/find-python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,31 @@ export async function useCpythonVersion(
const major = semver.major(version);
const minor = semver.minor(version);

const userScriptsDir = path.join(
process.env['APPDATA'] || '',
'Python',
`Python${major}${minor}`,
'Scripts'
);
core.addPath(userScriptsDir);
if (
architecture === 'x86' &&
(major > 3 || (major === 3 && minor >= 10))
) {
// For Python >= 3.10 and architecture= 'x86', add the architecture-specific folder to the path
const arch = '32';

const userScriptsDir = path.join(
process.env['APPDATA'] || '',
'Python',
`Python${major}${minor}-${arch}`,
'Scripts'
);
core.addPath(userScriptsDir);
} else {
const userScriptsDir = path.join(
process.env['APPDATA'] || '',
'Python',
`Python${major}${minor}`,
'Scripts'
);

// Add the default path to the environment PATH variable
core.addPath(userScriptsDir);
}
}
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
}
Expand Down