summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorvser1 <etienne@voucoux.fr>2019-12-17 14:54:55 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2019-12-17 14:54:55 +0100
commit5deeca9e7a104105e17cc16ad4f79b1c5cdca29e (patch)
tree5d7c0fb9c41a28bb876abb4db25806cea0fc0739 /setup.py
parent0e1c78671b0ea0328bc87ea77081ef52e30b1d06 (diff)
downloadpsutil-5deeca9e7a104105e17cc16ad4f79b1c5cdca29e.tar.gz
[Solaris] Fix #1637 (#1638)
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 99818ad5..d2f2d75f 100755
--- a/setup.py
+++ b/setup.py
@@ -14,6 +14,7 @@ import shutil
import sys
import tempfile
import warnings
+import re
with warnings.catch_warnings():
warnings.simplefilter("ignore")
@@ -266,10 +267,28 @@ if POSIX:
define_macros=macros,
sources=sources)
if SUNOS:
+ def get_sunos_update():
+ # See https://serverfault.com/q/524883
+ # for an explanation of Solaris /etc/release
+ with open('/etc/release') as f:
+ update = re.search(r'(?<=s10s_u)[0-9]{1,2}', f.readline())
+ if update is None:
+ return 0
+ else:
+ return int(update.group(0))
+
posix_extension.libraries.append('socket')
if platform.release() == '5.10':
+ # Detect Solaris 5.10, update >= 4, see:
+ # https://github.com/giampaolo/psutil/pull/1638
+ if get_sunos_update() >= 4:
+ # MIB compliancy starts with SunOS 5.10 Update 4:
+ posix_extension.define_macros.append(('NEW_MIB_COMPLIANT', 1))
posix_extension.sources.append('psutil/arch/solaris/v10/ifaddrs.c')
posix_extension.define_macros.append(('PSUTIL_SUNOS10', 1))
+ else:
+ # Other releases are by default considered to be new mib compliant.
+ posix_extension.define_macros.append(('NEW_MIB_COMPLIANT', 1))
elif AIX:
posix_extension.sources.append('psutil/arch/aix/ifaddrs.c')