Skip to content

Commit 1619c8b

Browse files
committed
Support Windows ARM Python versions
Note that only Python >=3.11.0 supports Windows ARM.
1 parent 4854508 commit 1619c8b

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/com/ableton/Pyenv.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ class Pyenv implements Serializable {
5757
}
5858
}
5959

60+
// For Windows ARM, see if there is a ARM binary that can be used to avoid running
61+
// Python under PRISM.
62+
if (script.env.OS == 'Windows_NT' &&
63+
// If Java is an x86 binary on ARM64 running under PRISM, env.PROCESSOR_ARCHITECTURE
64+
// will report AMD64, so we need to use env.PROCESSOR_IDENTIFIER instead.
65+
script.env.PROCESSOR_IDENTIFIER?.startsWith('ARMv8') &&
66+
versionSupported(trimmedPythonVersion + '-arm')
67+
) {
68+
trimmedPythonVersion += '-arm'
69+
}
70+
6071
VirtualEnv venv = new VirtualEnv(script, randomSeed)
6172
script.withEnv(["PYENV_VERSION=${trimmedPythonVersion}"]) {
6273
try {

test/com/ableton/PyenvTest.groovy

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,35 @@ class PyenvTest extends BasePipelineTest {
160160
shMocks.each { mock -> assertCallStackContains(mock[0]) }
161161
}
162162

163+
@Test
164+
void createVirtualEnvWindowsArm() {
165+
String pythonVersion = '1.2.3'
166+
String pyenvRoot = 'C:\\mock\\pyenv\\root'
167+
String posixPyenvRoot = '/c/mock/pyenv/root'
168+
String shPyenvRoot = 'C:/mock/pyenv/root'
169+
List shMocks = [
170+
new Tuple(installCommands(
171+
pyenvRoot: shPyenvRoot,
172+
pythonVersion: pythonVersion + '-arm',
173+
isUnix: false,
174+
posixPyenvRoot: posixPyenvRoot,
175+
), '', 0),
176+
new Tuple("${shPyenvRoot}/bin/pyenv install --list", '''Available versions:
177+
1.2.3
178+
1.2.3-arm
179+
''', 0),
180+
]
181+
shMocks.each { mock -> helper.addShMock(mock[0], mock[1], mock[2]) }
182+
helper.registerAllowedMethod('fileExists', [String]) { return true }
183+
script.env['OS'] = 'Windows_NT'
184+
script.env['PROCESSOR_IDENTIFIER'] = 'ARMv8 (64-bit) Family 8 Model AC4 Revision 0'
185+
186+
Object venv = new Pyenv(script, pyenvRoot).createVirtualEnv(pythonVersion, 1)
187+
188+
assertEquals("/workspace/.venv/${TEST_RANDOM_NAME}" as String, venv.venvRootDir)
189+
shMocks.each { mock -> assertCallStackContains(mock[0]) }
190+
}
191+
163192
@Test
164193
void createVirtualEnvUnsupportedPythonVersion() {
165194
String pythonVersion = '6.6.6'

0 commit comments

Comments
 (0)