Skip to content
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

Remove dependency on win32ole #1051

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

Earlopain
Copy link
Contributor

@Earlopain Earlopain commented Jun 6, 2024

This will become bundled in Ruby 3.5

Unfortunately there is no portable way of checking for this. The wmic command is deprecated, though I don't observe this myself on W11 (yet?)

Closes #1048

The powershell variant will work in at least releases from 2012 (Windows 8):
https://learn.microsoft.com/en-us/previous-versions/powershell/module/cimcmdlets/get-ciminstance?view=powershell-3.0
https://learn.microsoft.com/en-us/previous-versions/powershell/module/microsoft.powershell.utility/select-object?view=powershell-3.0
https://learn.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.4

There are no docs from earlier so I can't say about versions from before that. Maybe supporting 12 year old versions is good enough and wmic doesn't even need to be used? Let me know.

This is overall very defensive in what could happen because I'm not primarily developing on windows.

This will become bundled in Ruby 3.5

Unfortunately there is no portable way of checking for this.
The wmic command is deprecated, though I don't observe this myself on W11 (yet?)
@Earlopain Earlopain force-pushed the drop-win32ole branch 2 times, most recently from 2c42376 to 6742a0d Compare June 6, 2024 09:46
Copy link
Collaborator

@eregon eregon left a comment

Choose a reason for hiding this comment

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

This looks great, thank you!

@eregon
Copy link
Collaborator

eregon commented Jun 7, 2024

@MSP-Greg I wonder if you might know what's the best way to get the number of (physical) cores on a Windows machine from Ruby?

@MSP-Greg
Copy link

MSP-Greg commented Jun 7, 2024

@eregon

The PowerShell command Get-CimInstance -ClassName Win32_Processor | Select-Object -Property NumberOfCores works.

On my system, it shows 10. Etc.nprocessors shows 20, both on Windows and WSL2/Ubuntu. I have a single CPU.

Do you mean via c code?

@eregon
Copy link
Collaborator

eregon commented Jun 7, 2024

I meant via the command-line.
OK, thanks for confirming it works.

@eregon eregon merged commit c672d6e into ruby-concurrency:master Jun 7, 2024
14 checks passed
@eregon
Copy link
Collaborator

eregon commented Jun 7, 2024

I made a release with this: https://github.com/ruby-concurrency/concurrent-ruby/releases/tag/v1.3.2

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.

Ruby 3.5 to drop win32ole
3 participants