Skip to content

Commit

Permalink
#811: on Win XP let the possibility to install psutil from sources as…
Browse files Browse the repository at this point in the history
… it still (kind of) works)
  • Loading branch information
giampaolo committed Nov 8, 2016
1 parent c431926 commit e2f71f7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
8 changes: 6 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1924,8 +1924,12 @@ Q&A
===

* Q: What Windows versions are supported?
* A: From Windows Vista onwards. Latest release supporting Windows 2000, XP and
2003 server is psutil `3.4.2 <https://pypi.python.org/pypi?name=psutil&version=3.4.2&:action=files>`__.
* A: From Windows **Vista** onwards. Latest binary (wheel / exe) release
supporting Windows **2000**, **XP** and **2003 server** which can installed
via pip without a compiler being installed is
`psutil 3.4.2 <https://pypi.python.org/pypi?name=psutil&version=3.4.2&:action=files>`__.
More recent psutil versions may still be compiled from sources and work
(more or less) but they are no longer being tested or maintained.


Timeline
Expand Down
21 changes: 17 additions & 4 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,24 @@
pass

elif WINDOWS:
from ._common import assert_supported_winver
assert_supported_winver()
del assert_supported_winver
try:
from . import _pswindows as _psplatform
except ImportError as err:
if sys.getwindowsversion()[0] < 6:
# We may get here if:
# 1) we are on an old Windows version
# 2) psutil was installed via pip + wheel
# See: https://github.com/giampaolo/psutil/issues/811
# It must be noted that psutil can still (kind of) work
# on outdated systems if compiled / installed from sources,
# but if we get here it means this this was a wheel (or exe).
msg = "this Windows version is too old (< Windows Vista); "
msg += "psutil 3.4.2 is the latest version which supports Windows "
msg += "2000, XP and 2003 server"
raise RuntimeError(msg)
else:
raise

from . import _pswindows as _psplatform
from ._psutil_windows import ABOVE_NORMAL_PRIORITY_CLASS # NOQA
from ._psutil_windows import BELOW_NORMAL_PRIORITY_CLASS # NOQA
from ._psutil_windows import HIGH_PRIORITY_CLASS # NOQA
Expand Down
9 changes: 0 additions & 9 deletions psutil/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,3 @@ def inner(self, *args, **kwargs):
return getattr(self, replacement)(*args, **kwargs)
return inner
return outer


def assert_supported_winver():
"""Raise an error if this Windows version is not supported."""
if WINDOWS and sys.getwindowsversion()[0] < 6:
msg = "this Windows version is too old (< Windows Vista); "
msg += "psutil 3.4.2 is the latest version which supports Windows "
msg += "2000, XP and 2003 server"
raise RuntimeError(msg)
13 changes: 9 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
import contextlib
import io
import os
import platform
import sys
import tempfile
import platform
import warnings
try:
from setuptools import setup, Extension
except ImportError:
Expand All @@ -24,7 +25,6 @@
HERE = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(HERE, "psutil"))

from _common import assert_supported_winver # NOQA
from _common import BSD # NOQA
from _common import FREEBSD # NOQA
from _common import LINUX # NOQA
Expand Down Expand Up @@ -99,12 +99,17 @@ def write(self, s):

# Windows
if WINDOWS:
assert_supported_winver()

def get_winver():
maj, min = sys.getwindowsversion()[0:2]
return '0x0%s' % ((maj * 100) + min)

if sys.getwindowsversion()[0] < 6:
msg = "Windows versions < Vista are no longer supported or maintained;"
msg = " latest supported version is psutil 3.4.2; "
msg += "psutil may still be installed from sources if you have "
msg += "Visual Studio and may also (kind of) work though"
warnings.warn(msg, UserWarning)

macros.extend([
# be nice to mingw, see:
# http://www.mingw.org/wiki/Use_more_recent_defined_functions
Expand Down

0 comments on commit e2f71f7

Please sign in to comment.