diff --git a/MANIFEST.in b/MANIFEST.in index c6d8c550a..146cd92df 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -28,7 +28,7 @@ include psutil/_exceptions.py include psutil/_psaix.py include psutil/_psbsd.py include psutil/_pslinux.py -include psutil/_psmacos.py +include psutil/_psosx.py include psutil/_psposix.py include psutil/_pssunos.py include psutil/_psutil_aix.c @@ -36,7 +36,7 @@ include psutil/_psutil_bsd.c include psutil/_psutil_common.c include psutil/_psutil_common.h include psutil/_psutil_linux.c -include psutil/_psutil_macos.c +include psutil/_psutil_osx.c include psutil/_psutil_posix.c include psutil/_psutil_posix.h include psutil/_psutil_sunos.c @@ -55,16 +55,16 @@ include psutil/arch/freebsd/specific.c include psutil/arch/freebsd/specific.h include psutil/arch/freebsd/sys_socks.c include psutil/arch/freebsd/sys_socks.h -include psutil/arch/macos/process_info.c -include psutil/arch/macos/process_info.h -include psutil/arch/macos/smc.c -include psutil/arch/macos/smc.h include psutil/arch/netbsd/socks.c include psutil/arch/netbsd/socks.h include psutil/arch/netbsd/specific.c include psutil/arch/netbsd/specific.h include psutil/arch/openbsd/specific.c include psutil/arch/openbsd/specific.h +include psutil/arch/osx/process_info.c +include psutil/arch/osx/process_info.h +include psutil/arch/osx/smc.c +include psutil/arch/osx/smc.h include psutil/arch/solaris/environ.c include psutil/arch/solaris/environ.h include psutil/arch/solaris/v10/ifaddrs.c @@ -88,7 +88,7 @@ include psutil/tests/test_bsd.py include psutil/tests/test_connections.py include psutil/tests/test_contracts.py include psutil/tests/test_linux.py -include psutil/tests/test_macos.py +include psutil/tests/test_osx.py include psutil/tests/test_memory_leaks.py include psutil/tests/test_misc.py include psutil/tests/test_posix.py diff --git a/Makefile b/Makefile index 58c0d3961..51047383f 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ test-posix: ## POSIX specific tests. test-platform: ## Run specific platform tests only. ${MAKE} install - $(TEST_PREFIX) $(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "MACOS", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py + $(TEST_PREFIX) $(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py test-memleaks: ## Memory leak tests. ${MAKE} install diff --git a/psutil/__init__.py b/psutil/__init__.py index affc5c8c3..43e9aa7e9 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -153,7 +153,7 @@ from ._pswindows import CONN_DELETE_TCB # NOQA elif MACOS: - from . import _psmacos as _psplatform + from . import _psosx as _psplatform elif BSD: from . import _psbsd as _psplatform diff --git a/psutil/_psmacos.py b/psutil/_psosx.py similarity index 99% rename from psutil/_psmacos.py rename to psutil/_psosx.py index a719bedaa..6c77dc691 100644 --- a/psutil/_psmacos.py +++ b/psutil/_psosx.py @@ -14,7 +14,7 @@ from . import _common from . import _psposix -from . import _psutil_macos as cext +from . import _psutil_osx as cext from . import _psutil_posix as cext_posix from ._common import AF_INET6 from ._common import conn_tmap diff --git a/psutil/_psutil_macos.c b/psutil/_psutil_osx.c similarity index 99% rename from psutil/_psutil_macos.c rename to psutil/_psutil_osx.c index 8fc3140f6..e3250caba 100644 --- a/psutil/_psutil_macos.c +++ b/psutil/_psutil_osx.c @@ -43,8 +43,8 @@ #include "_psutil_common.h" #include "_psutil_posix.h" -#include "arch/macos/process_info.h" -#include "arch/macos/smc.h" +#include "arch/osx/process_info.h" +#include "arch/osx/smc.h" #define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0) @@ -342,7 +342,7 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) { if (! PyArg_ParseTuple(args, "l", &pid)) return NULL; - // get the commandline, defined in arch/macos/process_info.c + // get the commandline, defined in arch/osx/process_info.c py_retlist = psutil_get_cmdline(pid); return py_retlist; } @@ -359,7 +359,7 @@ psutil_proc_environ(PyObject *self, PyObject *args) { if (! PyArg_ParseTuple(args, "l", &pid)) return NULL; - // get the environment block, defined in arch/macos/process_info.c + // get the environment block, defined in arch/osx/process_info.c py_retdict = psutil_get_environ(pid); return py_retdict; } @@ -2066,13 +2066,13 @@ struct module_state { #if PY_MAJOR_VERSION >= 3 static int -psutil_macos_traverse(PyObject *m, visitproc visit, void *arg) { +psutil_osx_traverse(PyObject *m, visitproc visit, void *arg) { Py_VISIT(GETSTATE(m)->error); return 0; } static int -psutil_macos_clear(PyObject *m) { +psutil_osx_clear(PyObject *m) { Py_CLEAR(GETSTATE(m)->error); return 0; } @@ -2080,31 +2080,31 @@ psutil_macos_clear(PyObject *m) { static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - "psutil_macos", + "psutil_osx", NULL, sizeof(struct module_state), PsutilMethods, NULL, - psutil_macos_traverse, - psutil_macos_clear, + psutil_osx_traverse, + psutil_osx_clear, NULL }; #define INITERROR return NULL -PyMODINIT_FUNC PyInit__psutil_macos(void) +PyMODINIT_FUNC PyInit__psutil_osx(void) #else #define INITERROR return void -init_psutil_macos(void) +init_psutil_osx(void) #endif { #if PY_MAJOR_VERSION >= 3 PyObject *module = PyModule_Create(&moduledef); #else - PyObject *module = Py_InitModule("_psutil_macos", PsutilMethods); + PyObject *module = Py_InitModule("_psutil_osx", PsutilMethods); #endif PyModule_AddIntConstant(module, "version", PSUTIL_VERSION); // process status constants, defined in: @@ -2130,7 +2130,7 @@ init_psutil_macos(void) // Exception. ZombieProcessError = PyErr_NewException( - "_psutil_macos.ZombieProcessError", NULL, NULL); + "_psutil_osx.ZombieProcessError", NULL, NULL); Py_INCREF(ZombieProcessError); PyModule_AddObject(module, "ZombieProcessError", ZombieProcessError); diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c index e9a8f2d95..c851abbc1 100644 --- a/psutil/_psutil_posix.c +++ b/psutil/_psutil_posix.c @@ -28,7 +28,7 @@ #include #include #include -#elif defined(PSUTIL_BSD) || defined(PSUTIL_MACOS) +#elif defined(PSUTIL_BSD) || defined(PSUTIL_OSX) #include #include #include @@ -71,7 +71,7 @@ psutil_pid_exists(long pid) { #endif } -#if defined(PSUTIL_MACOS) +#if defined(PSUTIL_OSX) ret = kill((pid_t)pid , 0); #else ret = kill(pid , 0); @@ -143,7 +143,7 @@ psutil_posix_getpriority(PyObject *self, PyObject *args) { if (! PyArg_ParseTuple(args, "l", &pid)) return NULL; -#ifdef PSUTIL_MACOS +#ifdef PSUTIL_OSX priority = getpriority(PRIO_PROCESS, (id_t)pid); #else priority = getpriority(PRIO_PROCESS, pid); @@ -166,7 +166,7 @@ psutil_posix_setpriority(PyObject *self, PyObject *args) { if (! PyArg_ParseTuple(args, "li", &pid, &priority)) return NULL; -#ifdef PSUTIL_MACOS +#ifdef PSUTIL_OSX retval = setpriority(PRIO_PROCESS, (id_t)pid, priority); #else retval = setpriority(PRIO_PROCESS, pid, priority); @@ -221,7 +221,7 @@ psutil_convert_ipaddr(struct sockaddr *addr, int family) { len = lladdr->sll_halen; data = (const char *)lladdr->sll_addr; } -#elif defined(PSUTIL_BSD) || defined(PSUTIL_MACOS) +#elif defined(PSUTIL_BSD) || defined(PSUTIL_OSX) else if (addr->sa_family == AF_LINK) { // Note: prior to Python 3.4 socket module does not expose // AF_LINK so we'll do. @@ -433,7 +433,7 @@ psutil_net_if_flags(PyObject *self, PyObject *args) { /* * net_if_stats() macOS/BSD implementation. */ -#if defined(PSUTIL_BSD) || defined(PSUTIL_MACOS) +#if defined(PSUTIL_BSD) || defined(PSUTIL_OSX) int psutil_get_nic_speed(int ifm_active) { // Determine NIC speed. Taken from: @@ -638,7 +638,7 @@ PsutilMethods[] = { "Retrieve NIC MTU"}, {"net_if_flags", psutil_net_if_flags, METH_VARARGS, "Retrieve NIC flags"}, -#if defined(PSUTIL_BSD) || defined(PSUTIL_MACOS) +#if defined(PSUTIL_BSD) || defined(PSUTIL_OSX) {"net_if_duplex_speed", psutil_net_if_duplex_speed, METH_VARARGS, "Return NIC stats."}, #endif @@ -698,7 +698,7 @@ void init_psutil_posix(void) PyObject *module = Py_InitModule("_psutil_posix", PsutilMethods); #endif -#if defined(PSUTIL_BSD) || defined(PSUTIL_MACOS) || defined(PSUTIL_SUNOS) || defined(PSUTIL_AIX) +#if defined(PSUTIL_BSD) || defined(PSUTIL_OSX) || defined(PSUTIL_SUNOS) || defined(PSUTIL_AIX) PyModule_AddIntConstant(module, "AF_LINK", AF_LINK); #endif diff --git a/psutil/arch/macos/process_info.c b/psutil/arch/osx/process_info.c similarity index 98% rename from psutil/arch/macos/process_info.c rename to psutil/arch/osx/process_info.c index de007de48..40c79a2cd 100644 --- a/psutil/arch/macos/process_info.c +++ b/psutil/arch/osx/process_info.c @@ -4,7 +4,7 @@ * found in the LICENSE file. * * Helper functions related to fetching process information. - * Used by _psutil_macos module methods. + * Used by _psutil_osx module methods. */ @@ -142,7 +142,7 @@ psutil_get_cmdline(long pid) { mib[2] = (pid_t)pid; if (sysctl(mib, 3, procargs, &argmax, NULL, 0) < 0) { // In case of zombie process we'll get EINVAL. We translate it - // to NSP and _psmacos.py will translate it to ZP. + // to NSP and _psosx.py will translate it to ZP. if ((errno == EINVAL) && (psutil_pid_exists(pid))) NoSuchProcess(""); else @@ -236,7 +236,7 @@ psutil_get_environ(long pid) { mib[2] = (pid_t)pid; if (sysctl(mib, 3, procargs, &argmax, NULL, 0) < 0) { // In case of zombie process we'll get EINVAL. We translate it - // to NSP and _psmacos.py will translate it to ZP. + // to NSP and _psosx.py will translate it to ZP. if ((errno == EINVAL) && (psutil_pid_exists(pid))) NoSuchProcess(""); else diff --git a/psutil/arch/macos/process_info.h b/psutil/arch/osx/process_info.h similarity index 100% rename from psutil/arch/macos/process_info.h rename to psutil/arch/osx/process_info.h diff --git a/psutil/arch/macos/smc.c b/psutil/arch/osx/smc.c similarity index 100% rename from psutil/arch/macos/smc.c rename to psutil/arch/osx/smc.c diff --git a/psutil/arch/macos/smc.h b/psutil/arch/osx/smc.h similarity index 100% rename from psutil/arch/macos/smc.h rename to psutil/arch/osx/smc.h diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 2b00d4263..d293498e8 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -810,7 +810,7 @@ def get_suite(): x.startswith('test_memory_leaks')] if "WHEELHOUSE_UPLOADER_USERNAME" in os.environ: testmods = [x for x in testmods if not x.endswith(( - "macos", "posix", "linux"))] + "osx", "posix", "linux"))] suite = unittest.TestSuite() for tm in testmods: # ...so that the full test paths are printed on screen diff --git a/psutil/tests/test_macos.py b/psutil/tests/test_osx.py similarity index 100% rename from psutil/tests/test_macos.py rename to psutil/tests/test_osx.py diff --git a/setup.py b/setup.py index 03e315b54..adc7a0e2d 100755 --- a/setup.py +++ b/setup.py @@ -146,13 +146,13 @@ def get_winver(): ) elif MACOS: - macros.append(("PSUTIL_MACOS", 1)) + macros.append(("PSUTIL_OSX", 1)) ext = Extension( - 'psutil._psutil_macos', + 'psutil._psutil_osx', sources=sources + [ - 'psutil/_psutil_macos.c', - 'psutil/arch/macos/process_info.c', - 'psutil/arch/macos/smc.c', + 'psutil/_psutil_osx.c', + 'psutil/arch/osx/process_info.c', + 'psutil/arch/osx/smc.c', ], define_macros=macros, extra_link_args=[