From 3d067a72387c08d001a8fb6648b3c6d0d1ab5570 Mon Sep 17 00:00:00 2001 From: Gabi Davar Date: Mon, 9 Feb 2015 07:51:49 +0200 Subject: [PATCH] move extension into package - without relative imports. --- psutil/__init__.py | 16 ++++++++-------- psutil/_psbsd.py | 8 ++++---- psutil/_pslinux.py | 8 ++++---- psutil/_psosx.py | 8 ++++---- psutil/_pssunos.py | 8 ++++---- psutil/_pswindows.py | 2 +- setup.py | 12 ++++++------ 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/psutil/__init__.py b/psutil/__init__.py index c92fe4a5e..2e30ff1f4 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -70,7 +70,7 @@ IOPRIO_CLASS_IDLE) # Linux >= 2.6.36 if _psplatform.HAS_PRLIMIT: - from _psutil_linux import (RLIM_INFINITY, # NOQA + from psutil._psutil_linux import (RLIM_INFINITY, # NOQA RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, @@ -85,7 +85,7 @@ # Kinda ugly but considerably faster than using hasattr() and # setattr() against the module object (we are at import time: # speed matters). - import _psutil_linux + from psutil import _psutil_linux try: RLIMIT_MSGQUEUE = _psutil_linux.RLIMIT_MSGQUEUE except AttributeError: @@ -110,12 +110,12 @@ elif sys.platform.startswith("win32"): from psutil import _pswindows as _psplatform - from _psutil_windows import (ABOVE_NORMAL_PRIORITY_CLASS, # NOQA - BELOW_NORMAL_PRIORITY_CLASS, - HIGH_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS, - REALTIME_PRIORITY_CLASS) + from psutil._psutil_windows import (ABOVE_NORMAL_PRIORITY_CLASS, # NOQA + BELOW_NORMAL_PRIORITY_CLASS, + HIGH_PRIORITY_CLASS, + IDLE_PRIORITY_CLASS, + NORMAL_PRIORITY_CLASS, + REALTIME_PRIORITY_CLASS) from psutil._pswindows import CONN_DELETE_TCB # NOQA elif sys.platform.startswith("darwin"): diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index 9e9751fa9..855dd54be 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -16,8 +16,8 @@ from psutil import _psposix from psutil._common import conn_tmap, usage_percent, sockfam_to_enum from psutil._common import socktype_to_enum -import _psutil_bsd as cext -import _psutil_posix +import psutil._psutil_bsd as cext +import psutil._psutil_posix as cext_posix __extra__all__ = [] @@ -341,11 +341,11 @@ def wait(self, timeout=None): @wrap_exceptions def nice_get(self): - return _psutil_posix.getpriority(self.pid) + return cext_posix.getpriority(self.pid) @wrap_exceptions def nice_set(self, value): - return _psutil_posix.setpriority(self.pid, value) + return cext_posix.setpriority(self.pid, value) @wrap_exceptions def status(self): diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 96e562c7d..f03e060aa 100755 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -23,8 +23,8 @@ from psutil import _psposix from psutil._common import isfile_strict, usage_percent, deprecated from psutil._compat import PY3 -import _psutil_linux as cext -import _psutil_posix +import psutil._psutil_linux as cext +import psutil._psutil_posix as cext_posix __extra__all__ = [ @@ -941,11 +941,11 @@ def nice_get(self): # return int(data.split()[18]) # Use C implementation - return _psutil_posix.getpriority(self.pid) + return cext_posix.getpriority(self.pid) @wrap_exceptions def nice_set(self, value): - return _psutil_posix.setpriority(self.pid, value) + return cext_posix.setpriority(self.pid, value) @wrap_exceptions def cpu_affinity_get(self): diff --git a/psutil/_psosx.py b/psutil/_psosx.py index 68ba4d373..d09f2d93e 100644 --- a/psutil/_psosx.py +++ b/psutil/_psosx.py @@ -15,8 +15,8 @@ from psutil import _psposix from psutil._common import conn_tmap, usage_percent, isfile_strict from psutil._common import sockfam_to_enum, socktype_to_enum -import _psutil_osx as cext -import _psutil_posix +import psutil._psutil_osx as cext +import psutil._psutil_posix as cext_posix __extra__all__ = [] @@ -317,11 +317,11 @@ def wait(self, timeout=None): @wrap_exceptions def nice_get(self): - return _psutil_posix.getpriority(self.pid) + return cext_posix.getpriority(self.pid) @wrap_exceptions def nice_set(self, value): - return _psutil_posix.setpriority(self.pid, value) + return cext_posix.setpriority(self.pid, value) @wrap_exceptions def status(self): diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index a55c5ee48..8dca91702 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -18,8 +18,8 @@ from psutil._common import isfile_strict, socktype_to_enum, sockfam_to_enum from psutil._common import usage_percent from psutil._compat import PY3 -import _psutil_posix -import _psutil_sunos as cext +import psutil._psutil_posix as cext_posix +import psutil._psutil_sunos as cext __extra__all__ = ["CONN_IDLE", "CONN_BOUND"] @@ -295,7 +295,7 @@ def nice_get(self): # Note: tested on Solaris 11; on Open Solaris 5 everything is # fine. try: - return _psutil_posix.getpriority(self.pid) + return cext_posix.getpriority(self.pid) except EnvironmentError as err: if err.errno in (errno.ENOENT, errno.ESRCH): if pid_exists(self.pid): @@ -310,7 +310,7 @@ def nice_set(self, value): # The process actually exists though, as it has a name, # creation time, etc. raise AccessDenied(self.pid, self._name) - return _psutil_posix.setpriority(self.pid, value) + return cext_posix.setpriority(self.pid, value) @wrap_exceptions def ppid(self): diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index 8971d2d6f..31a146378 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -15,7 +15,7 @@ from psutil._common import conn_tmap, usage_percent, isfile_strict from psutil._common import sockfam_to_enum, socktype_to_enum from psutil._compat import PY3, xrange, lru_cache -import _psutil_windows as cext +import psutil._psutil_windows as cext # process priority constants, import from __init__.py: diff --git a/setup.py b/setup.py index 87218ee07..134af9579 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ def get_description(): # POSIX if os.name == 'posix': posix_extension = Extension( - '_psutil_posix', + 'psutil._psutil_posix', sources=['psutil/_psutil_posix.c'], ) # Windows @@ -58,7 +58,7 @@ def get_winver(): return '0x0%s' % ((maj * 100) + min) extensions = [Extension( - '_psutil_windows', + 'psutil._psutil_windows', sources=[ 'psutil/_psutil_windows.c', 'psutil/_psutil_common.c', @@ -86,7 +86,7 @@ def get_winver(): # OS X elif sys.platform.startswith("darwin"): extensions = [Extension( - '_psutil_osx', + 'psutil._psutil_osx', sources=[ 'psutil/_psutil_osx.c', 'psutil/_psutil_common.c', @@ -102,7 +102,7 @@ def get_winver(): # FreeBSD elif sys.platform.startswith("freebsd"): extensions = [Extension( - '_psutil_bsd', + 'psutil._psutil_bsd', sources=[ 'psutil/_psutil_bsd.c', 'psutil/_psutil_common.c', @@ -115,7 +115,7 @@ def get_winver(): # Linux elif sys.platform.startswith("linux"): extensions = [Extension( - '_psutil_linux', + 'psutil._psutil_linux', sources=['psutil/_psutil_linux.c'], define_macros=[VERSION_MACRO]), posix_extension, @@ -123,7 +123,7 @@ def get_winver(): # Solaris elif sys.platform.lower().startswith('sunos'): extensions = [Extension( - '_psutil_sunos', + 'psutil._psutil_sunos', sources=['psutil/_psutil_sunos.c'], define_macros=[VERSION_MACRO], libraries=['kstat', 'nsl'],),