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 the package #578

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
89 changes: 47 additions & 42 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,47 @@
except ImportError:
pwd = None

from psutil._common import memoize
from psutil._compat import callable, long
from psutil._compat import PY3 as _PY3
from psutil._common import (deprecated_method as _deprecated_method,
deprecated as _deprecated,
sdiskio as _nt_sys_diskio,
snetio as _nt_sys_netio)

from psutil._common import (STATUS_RUNNING, # NOQA
STATUS_SLEEPING,
STATUS_DISK_SLEEP,
STATUS_STOPPED,
STATUS_TRACING_STOP,
STATUS_ZOMBIE,
STATUS_DEAD,
STATUS_WAKING,
STATUS_LOCKED,
STATUS_IDLE, # bsd
STATUS_WAITING, # bsd
STATUS_LOCKED) # bsd

from psutil._common import (CONN_ESTABLISHED,
CONN_SYN_SENT,
CONN_SYN_RECV,
CONN_FIN_WAIT1,
CONN_FIN_WAIT2,
CONN_TIME_WAIT,
CONN_CLOSE,
CONN_CLOSE_WAIT,
CONN_LAST_ACK,
CONN_LISTEN,
CONN_CLOSING,
CONN_NONE)
from ._common import memoize
from ._compat import callable, long
from ._compat import PY3 as _PY3
from ._common import (
deprecated_method as _deprecated_method,
deprecated as _deprecated,
sdiskio as _nt_sys_diskio,
snetio as _nt_sys_netio
)

from ._common import (
STATUS_RUNNING, # NOQA
STATUS_SLEEPING,
STATUS_DISK_SLEEP,
STATUS_STOPPED,
STATUS_TRACING_STOP,
STATUS_ZOMBIE,
STATUS_DEAD,
STATUS_WAKING,
STATUS_LOCKED,
STATUS_IDLE, # bsd
STATUS_WAITING, # bsd
) # bsd

from ._common import (
CONN_ESTABLISHED,
CONN_SYN_SENT,
CONN_SYN_RECV,
CONN_FIN_WAIT1,
CONN_FIN_WAIT2,
CONN_TIME_WAIT,
CONN_CLOSE,
CONN_CLOSE_WAIT,
CONN_LAST_ACK,
CONN_LISTEN,
CONN_CLOSING,
CONN_NONE
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't do this for now. I'll think about whether I'm OK with this later.


if sys.platform.startswith("linux"):
import psutil._pslinux as _psplatform
from . import _pslinux as _psplatform
from psutil._pslinux import (phymem_buffers, # NOQA
cached_phymem)

Expand All @@ -97,7 +102,7 @@
IOPRIO_CLASS_IDLE)
# Linux >= 2.6.36
if _psplatform.HAS_PRLIMIT:
from _psutil_linux import (RLIM_INFINITY, # NOQA
from ._psutil_linux import (RLIM_INFINITY, # NOQA
RLIMIT_AS,
RLIMIT_CORE,
RLIMIT_CPU,
Expand All @@ -112,7 +117,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 . import _psutil_linux
try:
RLIMIT_MSGQUEUE = _psutil_linux.RLIMIT_MSGQUEUE
except AttributeError:
Expand All @@ -136,8 +141,8 @@
del _psutil_linux

elif sys.platform.startswith("win32"):
import psutil._pswindows as _psplatform
from _psutil_windows import (ABOVE_NORMAL_PRIORITY_CLASS, # NOQA
from . import _pswindows as _psplatform
from ._psutil_windows import (ABOVE_NORMAL_PRIORITY_CLASS, # NOQA
BELOW_NORMAL_PRIORITY_CLASS,
HIGH_PRIORITY_CLASS,
IDLE_PRIORITY_CLASS,
Expand All @@ -146,14 +151,14 @@
from psutil._pswindows import CONN_DELETE_TCB # NOQA

elif sys.platform.startswith("darwin"):
import psutil._psosx as _psplatform
from . import _psosx as _psplatform

elif sys.platform.startswith("freebsd"):
import psutil._psbsd as _psplatform
from . import _psbsd as _psplatform

elif sys.platform.startswith("sunos"):
import psutil._pssunos as _psplatform
from psutil._pssunos import (CONN_IDLE, # NOQA
from . import _pssunos as _psplatform
from ._pssunos import (CONN_IDLE, # NOQA
CONN_BOUND)

else:
Expand Down
10 changes: 5 additions & 5 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import sys
from collections import namedtuple

from psutil import _common
from psutil import _psposix
from psutil._common import conn_tmap, usage_percent
import _psutil_bsd as cext
import _psutil_posix
from . import _common
from . import _psposix
from ._common import conn_tmap, usage_percent
from . import _psutil_bsd as cext
from . import _psutil_posix


__extra__all__ = []
Expand Down
12 changes: 6 additions & 6 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import warnings
from collections import namedtuple, defaultdict

from psutil import _common
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
from . import _common
from . import _psposix
from ._common import (isfile_strict, usage_percent, deprecated)
from ._compat import PY3
from . import _psutil_linux as cext
from . import _psutil_posix


__extra__all__ = [
Expand Down
10 changes: 5 additions & 5 deletions psutil/_psosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import os
from collections import namedtuple

from psutil import _common
from psutil import _psposix
from psutil._common import conn_tmap, usage_percent, isfile_strict
import _psutil_osx as cext
import _psutil_posix
from . import _common
from . import _psposix
from ._common import conn_tmap, usage_percent, isfile_strict
from . import _psutil_osx as cext
from . import _psutil_posix


__extra__all__ = []
Expand Down
4 changes: 2 additions & 2 deletions psutil/_psposix.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import sys
import time

from psutil._common import sdiskusage, usage_percent, memoize
from psutil._compat import PY3, unicode
from ._common import sdiskusage, usage_percent, memoize
from ._compat import PY3, unicode


class TimeoutExpired(Exception):
Expand Down
12 changes: 6 additions & 6 deletions psutil/_pssunos.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import sys
from collections import namedtuple

from psutil import _common
from psutil import _psposix
from psutil._common import usage_percent, isfile_strict
from psutil._compat import PY3
import _psutil_posix
import _psutil_sunos as cext
from . import _common
from . import _psposix
from ._common import usage_percent, isfile_strict
from ._compat import PY3
from . import _psutil_posix
from . import _psutil_sunos as cext


__extra__all__ = ["CONN_IDLE", "CONN_BOUND"]
Expand Down
8 changes: 4 additions & 4 deletions psutil/_pswindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import os
from collections import namedtuple

from psutil import _common
from psutil._common import conn_tmap, usage_percent, isfile_strict
from psutil._compat import PY3, xrange, lru_cache
import _psutil_windows as cext
from . import _common
from ._common import conn_tmap, usage_percent, isfile_strict
from ._compat import PY3, xrange, lru_cache
from . import _psutil_windows as cext

# process priority constants, import from __init__.py:
# http://msdn.microsoft.com/en-us/library/ms686219(v=vs.85).aspx
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 All @@ -85,7 +85,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 @@ -101,7 +101,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 @@ -114,15 +114,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