-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Windows] fix psutil installation on arm64 #81071
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
base: main
Are you sure you want to change the base?
[Windows] fix psutil installation on arm64 #81071
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d like to see the arm64 fix, but the approach here makes me wonder if this is a good idea. This removes the control from our hands and relies on pip managing that properly. I think that there is some value to the additional complexity for controlling the supply chain more aggressively.
I see, would you be more favorable to have a try/catch strategy, sort of like 345452c? We can:
Another option would be to vendor our own wheel for arm64-windows. What do you think? |
Would it be possible to just add a wheel and specify the locations for ARM64 like we do other tools? |
Unfortunately |
Ugh, that is unfortunate. There are separate projects (e.g. https://github.com/cgohlke/win_arm64-wheels) to create wheels for Windows ARM64. The I'd love to get @shahmishal's take on this. |
@compnerd @shahmishal Would using |
I think that we should absolutely constrain the version. I also wondering if we should be doing more to ensure that something else isn't being injected. If you note the existing implementation, we have a specific URL and expected SHA256 that we compare against. |
A quick web search seems to indicate that this might be possible with pip: https://pip.pypa.io/en/stable/topics/secure-installs/ |
pip install with versions (and hashes if you wish) sounds great! Thanks for working on this. |
Oh, nice, I didn't know about that feature! Versions, Hash Checking Mode, and binary only combined would be great. |
This approach combines the best of both worlds:
We have to use a temporary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the source distribution - this will add additional CI time and we are working to reduce that. If you want to use the from source distributions, it will require that we find some way to reduce the build times first.
utils/build.ps1
Outdated
@@ -1008,27 +1032,47 @@ function Get-Dependencies { | |||
} | |||
} | |||
|
|||
function Install-PythonWheel([string] $ModuleName) { | |||
function Is-Python-Module-Installed([string] $ModuleName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions are not named using kebab case, there is a dictated nomenclature for PowerShell functions. https://learn.microsoft.com/en-us/powershell/scripting/learn/ps101/09-functions?view=powershell-7.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know about that convention, fixed, thanks!
The source distributions are only used as a fallback. All the modules should be installed from the wheel (no build time), except for psutil on Windows arm64, because there are no wheels for it. The only way I see to not use a source distribution for psutil on Windows arm64 would be to build a wheel ourselves and host is somewhere or vendor it inside of the repository. |
I think there are 3 approaches to fix this script failure on Windows ARM64: 1. Build psutil from sourceWe use Pros: Simple to implement, no need to host a file for win-arm64.
2. Use a pre-built wheel onlineWe use the Pros: We don't have to build/host a wheel. 3. Vendor our own wheelI was able to build a wheel for psutil==6.1.0 on Windows ARM64. We can host it somewhere or include it in the repo. Pros: The wheel is available without the need to download. ConclusionAll 3 approaches ensure that we maintain control of the supply chain through checksum checking. |
I think that a build taking 4s is reasonable enough to then consider. I agree with your assessment - it avoids the hosting problem and has a negligible impact on the build. |
@compnerd If you're okay with the patch, can you merge it? (I can do it, too, but I think it's better if you review it) |
ping @compnerd |
Yeah, I'll take a look soon, at an offsite this week. |
@charles-zablit would you mind just using the same process for all architectures? That is, lets completely ignore the wheel and just build the dependencies. This makes the ARM64 and X64 paths identical and therefore less likely to be an issue when working on one architecture. |
Done, this revision of the code uses |
Currently, the
build.ps1
script will try to install apsutil
wheel for amd64, regardless of the platform. The script fails on windows if psutil was not installed manually before running the script.Instead of manually downloading wheels and installing them via
pip
, we directly invokepip install
with the correct version of the package and letpip
figure out if there is an available wheel or not.This should not be an issue for building the wheel locally as the VisualStudio toolchain should already be installed before running the script.