Skip to content

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

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bd89e34
update-install path --user flag for x86 for >=3.10
aparnajyothi-y Feb 19, 2025
feb0ff9
update-install-path-freethreaded
aparnajyothi-y Mar 25, 2025
da44513
update the install path for free-threaded
aparnajyothi-y Mar 25, 2025
72794c8
Support free threaded Python versions like '3.13t' (#973)
colesbury Mar 4, 2025
6a33031
Bump @actions/glob from 0.4.0 to 0.5.0 (#1015)
dependabot[bot] Mar 12, 2025
0704aaf
Add support for .tool-versions file in setup-python (#1043)
mahabaleshwars Mar 13, 2025
12c4557
Add e2e Testing for free threaded and Bump @action/cache from 4.0.0 t…
priya-kinthali Mar 24, 2025
56f2fac
Remove Ubuntu 20.04 from workflows due to deprecation from 2025-04-15…
aparnajyothi-y Apr 11, 2025
358da85
Fix for Candidate Not Iterable Error (#1082)
aparnajyothi-y Apr 17, 2025
4260a61
update the logic for free threaded also
aparnajyothi-y Apr 22, 2025
1df3e33
logic update
aparnajyothi-y Apr 22, 2025
68111ac
Merge remote-tracking branch 'origin/main' into update-install-path
aparnajyothi-y Apr 22, 2025
114b468
code update for free threaded
aparnajyothi-y Apr 28, 2025
c614f62
resolve conflicts
aparnajyothi-y Apr 28, 2025
404bd3b
update the logic
aparnajyothi-y Apr 30, 2025
0b865b9
code update for freethreaded
aparnajyothi-y May 2, 2025
3d7ca5f
updated code logic for arm64
aparnajyothi-y May 9, 2025
9d11fda
update the logic to allow x86-freethreaded, arm64-freethreaded, x64-f…
aparnajyothi-y Jun 5, 2025
b26f6d0
Added architecture validation validated for freethreaded related inputs
aparnajyothi-y Jun 5, 2025
32a58a9
polished the error message
aparnajyothi-y Jun 5, 2025
b22fe06
logic update
aparnajyothi-y Jun 6, 2025
53228cb
logic update
aparnajyothi-y Jun 6, 2025
a14e4fd
file update
aparnajyothi-y Jun 6, 2025
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
29 changes: 28 additions & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Verify 3.9.13
run: python __tests__/verify-python.py 3.9.13

- name: Run with setup-python 3.9.13
- name: Run with setup-python 3.10.11
uses: ./
with:
python-version: 3.10.11
Expand Down Expand Up @@ -89,7 +89,34 @@ jobs:
python-version: '<3.13'
- name: Verify <3.13
run: python __tests__/verify-python.py 3.12

- name: Test Raw Endpoint Access
run: |
curl -L https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json | jq empty
shell: bash

verify-install-path:
name: Verify Install Path
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, windows-11-arm]
architecture: [x64, x86, arm64]
freethreaded: ['false', 'true']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13.1']
exclude:
- architecture: x64
freethreaded: 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: ./
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
freethreaded: ${{ matrix.freethreaded }}

- name: Verify Install Path
run: python __tests__/verify_windows_install_path.ps1 ${{ matrix.architecture }} ${{ matrix.freethreaded }} ${{ matrix.python-version }}
9 changes: 0 additions & 9 deletions .github/workflows/test-python-freethreaded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -62,7 +61,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -103,7 +101,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -142,7 +139,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -184,7 +180,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -226,7 +221,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -258,7 +252,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -371,7 +364,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down Expand Up @@ -461,7 +453,6 @@ jobs:
[
macos-latest,
windows-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-22.04-arm,
macos-13,
Expand Down
43 changes: 43 additions & 0 deletions __tests__/verify-windows-install-path.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import sys

def build_expected_path(architecture, freethreaded):
major = 3
minor = 13
version_suffix = f"{major}{minor}"

if architecture == "x86" and (major > 3 or (major == 3 and minor >= 10)):
version_suffix += "-32"
elif architecture == "arm64":
version_suffix += "-arm64"

if freethreaded == "true":
version_suffix += "t"
if architecture == "x86":
version_suffix += "-32"
elif architecture == "arm64":
version_suffix += "-arm64"

base_path = os.getenv("APPDATA", "")
return os.path.join(base_path, "Python", f"Python{version_suffix}", "Scripts")

def main():
if len(sys.argv) != 3:
print("Usage: python verify_windows_install_path.py <architecture> <freethreaded>")
sys.exit(1)

architecture = sys.argv[1]
freethreaded = sys.argv[2]

expected_path = build_expected_path(architecture, freethreaded)
print(f"Expected PATH entry: {expected_path}")

path_env = os.getenv("PATH", "")
if expected_path.lower() not in path_env.lower():
print("Expected path not found in PATH")
sys.exit(1)
else:
print("Correct path present in PATH")

if __name__ == "__main__":
main()
27 changes: 23 additions & 4 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96883,13 +96883,32 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
core.addPath(installDir);
core.addPath(_binDir);
if (utils_1.IS_WINDOWS) {
// Add --user directory
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
// So if `findLocalTool` succeeded above, we must have a conformant `installDir`
// Extract version details
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');
const basePath = process.env['APPDATA'] || '';
let versionSuffix = `${major}${minor}`;
// 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') {
versionSuffix += '-arm64';
}
}
// Add user Scripts path
const userScriptsDir = path.join(basePath, 'Python', `Python${versionSuffix}`, 'Scripts');
core.addPath(userScriptsDir);
}
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
Expand Down
31 changes: 25 additions & 6 deletions src/find-python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export async function useCpythonVersion(
// Use the freethreaded version if it was specified in the input, e.g., 3.13t
freethreaded = true;
}
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);

core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
if (freethreaded) {
// Free threaded versions use an architecture suffix like `x64-freethreaded`
core.debug(`Using freethreaded version of ${semanticVersionSpec}`);
Expand Down Expand Up @@ -152,17 +152,36 @@ export async function useCpythonVersion(
core.addPath(_binDir);

if (IS_WINDOWS) {
// Add --user directory
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
// So if `findLocalTool` succeeded above, we must have a conformant `installDir`
// Extract version details
const version = path.basename(path.dirname(installDir));
const major = semver.major(version);
const minor = semver.minor(version);

const basePath = process.env['APPDATA'] || '';
let versionSuffix = `${major}${minor}`;
// 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') {
versionSuffix += '-arm64';
}
}
// Add user Scripts path
const userScriptsDir = path.join(
process.env['APPDATA'] || '',
basePath,
'Python',
`Python${major}${minor}`,
`Python${versionSuffix}`,
'Scripts'
);
core.addPath(userScriptsDir);
Expand Down
Loading