From 9e008299bf8389603b5232baee7a55aa700ade36 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 3 Mar 2019 22:24:01 +0100 Subject: first step towards successful compilation --- INSTALL.rst | 8 ++++++++ psutil/_common.py | 5 +++-- psutil/_psutil_bsd.c | 16 ++++++++++++---- setup.py | 11 +++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/INSTALL.rst b/INSTALL.rst index 567758c9..bafe7ec4 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -102,11 +102,19 @@ NetBSD ====== :: + export PKG_PATH="ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/`uname -m`/`uname -r`/All" pkg_add -v pkgin pkgin install python gcc python -m pip install psutil +DragonflyBSD +============ + +:: + + pkg install python3 + Solaris ======= diff --git a/psutil/_common.py b/psutil/_common.py index 6d430388..f9ba714e 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -43,7 +43,7 @@ PY3 = sys.version_info[0] == 3 __all__ = [ # constants 'FREEBSD', 'BSD', 'LINUX', 'NETBSD', 'OPENBSD', 'MACOS', 'OSX', 'POSIX', - 'SUNOS', 'WINDOWS', + 'SUNOS', 'WINDOWS', 'DRAGONFLYBSD', 'ENCODING', 'ENCODING_ERRS', 'AF_INET6', # connection constants 'CONN_CLOSE', 'CONN_CLOSE_WAIT', 'CONN_CLOSING', 'CONN_ESTABLISHED', @@ -80,7 +80,8 @@ OSX = MACOS # deprecated alias FREEBSD = sys.platform.startswith("freebsd") OPENBSD = sys.platform.startswith("openbsd") NETBSD = sys.platform.startswith("netbsd") -BSD = FREEBSD or OPENBSD or NETBSD +DRAGONFLYBSD = sys.platform.startswith("dragonfly") +BSD = FREEBSD or OPENBSD or NETBSD or DRAGONFLYBSD SUNOS = sys.platform.startswith(("sunos", "solaris")) AIX = sys.platform.startswith("aix") diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c index efb933fb..b810b784 100644 --- a/psutil/_psutil_bsd.c +++ b/psutil/_psutil_bsd.c @@ -42,20 +42,21 @@ #include #include #include -#include #include #include #include + +#ifndef PSUTIL_DRAGONFLYBSD +#include #include // for struct xtcpcb +#endif + #include // for TCP connection states #include // for inet_ntop() - #include - #include // net io counters #include #include - #include // process open files/connections #include @@ -94,9 +95,16 @@ #ifndef DTYPE_VNODE #define DTYPE_VNODE 1 #endif +// #elif PSUTIL_DRAGONFLYBSD +// #include #endif +#include +#include +#include + + // convert a timeval struct to a double #define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0) diff --git a/setup.py b/setup.py index 465a9b9e..722e72ce 100755 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ sys.path.insert(0, os.path.join(HERE, "psutil")) from _common import AIX # NOQA from _common import BSD # NOQA +from _common import DRAGONFLYBSD # NOQA from _common import FREEBSD # NOQA from _common import LINUX # NOQA from _common import MACOS # NOQA @@ -195,6 +196,16 @@ elif NETBSD: define_macros=macros, libraries=["kvm"]) +elif DRAGONFLYBSD: + macros.append(("PSUTIL_DRAGONFLYBSD", 1)) + ext = Extension( + 'psutil._psutil_bsd', + sources=sources + [ + 'psutil/_psutil_bsd.c', + ], + define_macros=macros, + libraries=["kvm"]) + elif LINUX: def get_ethtool_macro(): # see: https://github.com/giampaolo/psutil/issues/659 -- cgit v1.2.1