-
Notifications
You must be signed in to change notification settings - Fork 79
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
psutil is missing in setup dependencies #70
Comments
The minimum work which can be done is to enhance the error message to mention that psutil is recommended on Windows. Something like:
Would you be interested to propose a PR for that? psutil is mostly useful on Windows. But I didn't feel brave enough to use environment markers in setup.py. pyperf used environment markers when Python 2.7 was still supported:
which caused issues with old setuptools versions: https://pyperf.readthedocs.io/en/latest/run_benchmark.html#install-pyperf I'm open to reintroduce environment markers to require psutil, but only on Windows. Another option is to write a C extension just for set_cpu_affinity(). Another option is to simply make the warning quiet on Windows. |
Yes, adding another line to the warning would be sufficient with minimal code.: def _process_priority(self):
if not MS_WINDOWS:
return
if not set_highest_priority():
print("WARNING: unable to increase process priority")
print("Use Python 3.3 or newer, or install psutil dependency") # <--- My first choice was:
But I understand that it's not required for basic functionality. I got the warning because of the set_highest_priority(). Suppressing warning/error/exception leads to confusion. Replacing all import pyperf._psutil as psutil And then in _psutil.py file: try:
# Optional dependency
from psutil import *
except ImportError:
__IMPORT_FAILED = True
raise ImportError("psutil")
else:
__IMPORT_FAILED = False
finally:
if __IMPORT_FAILED:
print("Optional dependency 'psutil' is not available: some features will not be available.") And then in set_highest_priority() and set_cpu_affinity() check psutil against None instead of trying to reimport it. Is there any reason for that reimport? |
If you propose a PR to implement that, I can test it ;-) |
I get this too with 3.11 built from main, today. It seems psutil is not compatible with the latest main branch. Though it looks like psutil still builds with 3.11a6, and then the set_highest_priority() function (in _cpu_utils.py) returns True, so you wouldn't get the error. |
When running from a virtual environment shell on Windows 10 (2004):
pipenv run python speed_test.py
I got this warning:
WARNING: unable to increase process priority
for each process and one extra for each runner.timeit() call.Figured out that it is because psutil is missing in package dependencies.
The text was updated successfully, but these errors were encountered: