Skip to content

Commit

Permalink
Merge pull request #2758 from nsait-linaro/win_arm64_launchers
Browse files Browse the repository at this point in the history
Fixes 2757: Add win/arm64 launchers to create arm64 executables
  • Loading branch information
jaraco authored Oct 2, 2021
2 parents baaf8cd + cbbdb86 commit 8519d4e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/2757.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add windows arm64 launchers for scripts generated by easy_install.
19 changes: 19 additions & 0 deletions msvc-build-launcher-arm64.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off

REM Build with jaraco/windows Docker image

set PATH_OLD=%PATH%
set PATH=C:\BuildTools\VC\Auxiliary\Build;%PATH_OLD%

REM now for arm 64-bit
REM Cross compile for arm64
call VCVARSx86_arm64
if "%ERRORLEVEL%"=="0" (
cl /D "GUI=0" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:arm64 /SUBSYSTEM:CONSOLE /out:setuptools/cli-arm64.exe
cl /D "GUI=1" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:arm64 /SUBSYSTEM:WINDOWS /out:setuptools/gui-arm64.exe
) else (
echo Visual Studio 2019 with arm64 toolchain not installed
)

set PATH=%PATH_OLD%

Binary file added setuptools/cli-arm64.exe
Binary file not shown.
5 changes: 4 additions & 1 deletion setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,10 @@ def get_win_launcher(type):
"""
launcher_fn = '%s.exe' % type
if is_64bit():
launcher_fn = launcher_fn.replace(".", "-64.")
if get_platform() == "win-arm64":
launcher_fn = launcher_fn.replace(".", "-arm64.")
else:
launcher_fn = launcher_fn.replace(".", "-64.")
else:
launcher_fn = launcher_fn.replace(".", "-32.")
return resource_string('setuptools', launcher_fn)
Expand Down
Binary file added setuptools/gui-arm64.exe
Binary file not shown.
15 changes: 13 additions & 2 deletions setuptools/tests/test_windows_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""

import sys
import platform
import textwrap
import subprocess

Expand Down Expand Up @@ -51,10 +52,20 @@ def create_script(cls, tmpdir):
f.write(w)


def win_launcher_exe(prefix):
""" A simple routine to select launcher script based on platform."""
assert prefix in ('cli', 'gui')
if platform.machine() == "ARM64":
return "{}-arm64.exe".format(prefix)
else:
return "{}-32.exe".format(prefix)


class TestCLI(WrapperTester):
script_name = 'foo-script.py'
wrapper_source = 'cli-32.exe'
wrapper_name = 'foo.exe'
wrapper_source = win_launcher_exe('cli')

script_tmpl = textwrap.dedent("""
#!%(python_exe)s
import sys
Expand Down Expand Up @@ -155,7 +166,7 @@ class TestGUI(WrapperTester):
-----------------------
"""
script_name = 'bar-script.pyw'
wrapper_source = 'gui-32.exe'
wrapper_source = win_launcher_exe('gui')
wrapper_name = 'bar.exe'

script_tmpl = textwrap.dedent("""
Expand Down

0 comments on commit 8519d4e

Please sign in to comment.