Skip to content
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

move extension into package - without relative imports. #587

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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"):
Expand Down
8 changes: 4 additions & 4 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = []
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions psutil/_psosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = []
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions psutil/_pssunos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion psutil/_pswindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -115,15 +115,15 @@ 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,
]
# 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'],),
Expand Down