mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-15 15:34:14 +02:00
logic update
This commit is contained in:
parent
32a58a97ef
commit
b22fe06733
4 changed files with 72 additions and 14 deletions
29
.github/workflows/e2e-tests.yml
vendored
29
.github/workflows/e2e-tests.yml
vendored
|
@ -38,7 +38,7 @@ jobs:
|
||||||
- name: Verify 3.9.13
|
- name: Verify 3.9.13
|
||||||
run: python __tests__/verify-python.py 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: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
python-version: 3.10.11
|
python-version: 3.10.11
|
||||||
|
@ -89,7 +89,34 @@ jobs:
|
||||||
python-version: '<3.13'
|
python-version: '<3.13'
|
||||||
- name: Verify <3.13
|
- name: Verify <3.13
|
||||||
run: python __tests__/verify-python.py 3.12
|
run: python __tests__/verify-python.py 3.12
|
||||||
|
|
||||||
- name: Test Raw Endpoint Access
|
- name: Test Raw Endpoint Access
|
||||||
run: |
|
run: |
|
||||||
curl -L https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json | jq empty
|
curl -L https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json | jq empty
|
||||||
shell: bash
|
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', '3.14']
|
||||||
|
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.py ${{ matrix.architecture }} ${{ matrix.freethreaded }} ${{ matrix.python-version }}
|
||||||
|
|
43
__tests__/verify-windows-install-path.py
Normal file
43
__tests__/verify-windows-install-path.py
Normal file
|
@ -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()
|
6
dist/setup/index.js
vendored
6
dist/setup/index.js
vendored
|
@ -96817,9 +96817,6 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
|
||||||
// Use the freethreaded version if it was specified in the input, e.g., 3.13t
|
// Use the freethreaded version if it was specified in the input, e.g., 3.13t
|
||||||
freethreaded = true;
|
freethreaded = true;
|
||||||
}
|
}
|
||||||
if (architecture.endsWith('-freethreaded')) {
|
|
||||||
throw new Error(`Invalid architecture '${architecture}'. Use 'freethreaded' flag in the python-version (e.g., '3.13.1t') or use freethreaded: true instead of specifying '-freethreaded' in the architecture`);
|
|
||||||
}
|
|
||||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||||
if (freethreaded) {
|
if (freethreaded) {
|
||||||
// Free threaded versions use an architecture suffix like `x64-freethreaded`
|
// Free threaded versions use an architecture suffix like `x64-freethreaded`
|
||||||
|
@ -96909,9 +96906,6 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
|
||||||
else if (architecture === 'arm64-freethreaded') {
|
else if (architecture === 'arm64-freethreaded') {
|
||||||
versionSuffix += '-arm64';
|
versionSuffix += '-arm64';
|
||||||
}
|
}
|
||||||
else if (architecture === 'x64-freethreaded') {
|
|
||||||
versionSuffix += '-64';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Add user Scripts path
|
// Add user Scripts path
|
||||||
const userScriptsDir = path.join(basePath, 'Python', `Python${versionSuffix}`, 'Scripts');
|
const userScriptsDir = path.join(basePath, 'Python', `Python${versionSuffix}`, 'Scripts');
|
||||||
|
|
|
@ -49,11 +49,7 @@ export async function useCpythonVersion(
|
||||||
// Use the freethreaded version if it was specified in the input, e.g., 3.13t
|
// Use the freethreaded version if it was specified in the input, e.g., 3.13t
|
||||||
freethreaded = true;
|
freethreaded = true;
|
||||||
}
|
}
|
||||||
if (architecture.endsWith('-freethreaded')) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid architecture '${architecture}'. Use 'freethreaded' flag in the python-version (e.g., '3.13.1t') or use freethreaded: true instead of specifying '-freethreaded' in the architecture`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||||
if (freethreaded) {
|
if (freethreaded) {
|
||||||
// Free threaded versions use an architecture suffix like `x64-freethreaded`
|
// Free threaded versions use an architecture suffix like `x64-freethreaded`
|
||||||
|
@ -179,8 +175,6 @@ export async function useCpythonVersion(
|
||||||
versionSuffix += '-32';
|
versionSuffix += '-32';
|
||||||
} else if (architecture === 'arm64-freethreaded') {
|
} else if (architecture === 'arm64-freethreaded') {
|
||||||
versionSuffix += '-arm64';
|
versionSuffix += '-arm64';
|
||||||
} else if (architecture === 'x64-freethreaded') {
|
|
||||||
versionSuffix += '-64';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add user Scripts path
|
// Add user Scripts path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue