Skip to content

setuptools.msvc: set host_dir correctly on ARM64 hosts#4786

Merged
jaraco merged 5 commits intopypa:mainfrom
swt2c:fix_msvc_host_dir_arm64
Mar 16, 2025
Merged

setuptools.msvc: set host_dir correctly on ARM64 hosts#4786
jaraco merged 5 commits intopypa:mainfrom
swt2c:fix_msvc_host_dir_arm64

Conversation

@swt2c
Copy link
Contributor

@swt2c swt2c commented Jan 3, 2025

Summary of changes

This corrects the setting of the host directory name on ARM64 hosts so that the EnvironmentInfo.VCTools property and EnvironmentInfo.return_env()['path'] includes the correct path to CL.EXE. Currently, it returns the X64 directory on ARM64 hosts. See below; note HostX64 in first listed path.

$ python
Python 3.13.1 (tags/v3.13.1:0671451, Dec  3 2024, 20:04:37) [MSC v.1942 64 bit (ARM64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools.msvc
>>> ei = setuptools.msvc.EnvironmentInfo('arm64')
>>> ei.return_env()['path']
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\arm64;C:\\Program Files (x86)\\Windows Kits\\10\\Bin\\arm64;C:\\Program Files (x86)\\Windows Kits\\10\\Bin\\10.0.22621.0\\arm64;C:\\Users\\talbert\\.blah_env\\Scripts;C:\\Program Files\\Git\\clangarm64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0;C:\\Windows\\System32\\OpenSSH;C:\\Program Files\\Git\\cmd;C:\\Users\\talbert\\AppData\\Local\\Programs\\Python\\Python313-arm64\\Scripts;C:\\Users\\talbert\\AppData\\Local\\Programs\\Python\\Python313-arm64;C:\\Users\\talbert\\AppData\\Local\\Programs\\Python\\Launcher;C:\\Users\\talbert\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\Git\\usr\\bin\\vendor_perl;C:\\Program Files\\Git\\usr\\bin\\core_perl'

Pull Request Checklist

@swt2c swt2c force-pushed the fix_msvc_host_dir_arm64 branch from 5ef90ee to cf436b4 Compare January 4, 2025 03:23
Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR isn't linked to any issue, can you update the PR description to elaborate on the issue? In particular, answer questions like: Why does it matter? How did you encounter it? Under what conditions is it relevant (e.g. does it affect all users of Setuptools on ARM, or some subset)?

I see lots of other places in this module where the assumption is that there is x86 and x64. I'm not sure it makes sense to add ARM support here, but not elsewhere. What's the value in fixing just this issue and not other parts in the module that deal with processor architecture?

@swt2c
Copy link
Contributor Author

swt2c commented Jan 5, 2025

Since this PR isn't linked to any issue, can you update the PR description to elaborate on the issue? In particular, answer questions like: Why does it matter? How did you encounter it? Under what conditions is it relevant (e.g. does it affect all users of Setuptools on ARM, or some subset)?

I see lots of other places in this module where the assumption is that there is x86 and x64. I'm not sure it makes sense to add ARM support here, but not elsewhere. What's the value in fixing just this issue and not other parts in the module that deal with processor architecture?

I thought the description was pretty clear about what the problem was (it really is just about the path item as returned by EnvironmentInfo.return_env(), but I added a Python interpreter run that shows the exact output that you currently get. This issue affects anyone who is using EnvironmentInfo.return_env() on an ARM64 Windows system and relying on the path that is returned.

This is the only problem that I'm actually aware of with setuptools.msvc on Windows ARM64. I just did another look through the file and while yes, there are a lot of cases where it assumes there is only x86 and x64, I didn't see any cases where it is actually doing the wrong thing on ARM64. The rest of the output of EnvironmentInfo.return_env() looks fine.

@swt2c swt2c force-pushed the fix_msvc_host_dir_arm64 branch from cf436b4 to b8f9800 Compare January 5, 2025 18:18
@swt2c swt2c force-pushed the fix_msvc_host_dir_arm64 branch from b8f9800 to e1d81b8 Compare January 5, 2025 18:20
@swt2c swt2c requested a review from jaraco February 28, 2025 01:26
jaraco added a commit that referenced this pull request Mar 16, 2025
@jaraco jaraco force-pushed the fix_msvc_host_dir_arm64 branch from 792e753 to d69bf04 Compare March 16, 2025 21:55
@swt2c
Copy link
Contributor Author

swt2c commented Mar 16, 2025

Thanks @jaraco for the fixups and adding a test. I wasn't very creative in thinking about how to test this without a Windows ARM64 host.

@jaraco jaraco merged commit a36b7ba into pypa:main Mar 16, 2025
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants