Files
MINGW-packages/mingw-w64-python-psutil/0001-MSYS-Allow-detecting-when-running-on-MSYS.patch
2016-09-19 08:32:26 -03:00

99 lines
3.4 KiB
Diff

From 92f37549d4be5632bde8373ec6329024455143aa Mon Sep 17 00:00:00 2001
From: Manuel Naranjo <naranjo.manuel@gmail.com>
Date: Thu, 23 Jun 2016 18:11:02 -0300
Subject: [PATCH 1/2] [MSYS] Allow detecting when running on MSYS
* Adding a check for testing for msys2
* disabling inet_ntop.c on msys2 as it's provided by mingw
---
psutil/_common.py | 3 ++-
setup.py | 45 +++++++++++++++++++++++++--------------------
2 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/psutil/_common.py b/psutil/_common.py
index 1e48b63..38d46f8 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -39,7 +39,7 @@ else:
__all__ = [
# OS constants
'FREEBSD', 'BSD', 'LINUX', 'NETBSD', 'OPENBSD', 'OSX', 'POSIX', 'SUNOS',
- 'WINDOWS',
+ 'WINDOWS', 'MSYS',
# connection constants
'CONN_CLOSE', 'CONN_CLOSE_WAIT', 'CONN_CLOSING', 'CONN_ESTABLISHED',
'CONN_FIN_WAIT1', 'CONN_FIN_WAIT2', 'CONN_LAST_ACK', 'CONN_LISTEN',
@@ -69,6 +69,7 @@ __all__ = [
POSIX = os.name == "posix"
WINDOWS = os.name == "nt"
+MSYS = "MSYSTEM" in os.environ
LINUX = sys.platform.startswith("linux")
OSX = sys.platform.startswith("darwin")
FREEBSD = sys.platform.startswith("freebsd")
diff --git a/setup.py b/setup.py
index a61b5ed..18472db 100644
--- a/setup.py
+++ b/setup.py
@@ -78,32 +78,37 @@ if _common.POSIX:
posix_extension.sources.append('psutil/arch/solaris/v10/ifaddrs.c')
posix_extension.define_macros.append(('PSUTIL_SUNOS10', 1))
# Windows
-if _common.WINDOWS:
+if _common.WINDOWS or _common.MSYS:
def get_winver():
maj, min = sys.getwindowsversion()[0:2]
return '0x0%s' % ((maj * 100) + min)
+ sources=[
+ 'psutil/_psutil_windows.c',
+ 'psutil/_psutil_common.c',
+ 'psutil/arch/windows/process_info.c',
+ 'psutil/arch/windows/process_handles.c',
+ 'psutil/arch/windows/security.c',
+ 'psutil/arch/windows/services.c',
+ ]
+
+ if not _common.MSYS:
+ sources.append('psutil/arch/windows/inet_ntop.c')
+
+ define_macros=[
+ VERSION_MACRO,
+ # be nice to mingw, see:
+ # http://www.mingw.org/wiki/Use_more_recent_defined_functions
+ ('_WIN32_WINNT', get_winver()),
+ ('_AVAIL_WINVER_', get_winver()),
+ ('_CRT_SECURE_NO_WARNINGS', None),
+ # see: https://github.com/giampaolo/psutil/issues/348
+ ('PSAPI_VERSION', 1),
+ ]
ext = Extension(
'psutil._psutil_windows',
- sources=[
- 'psutil/_psutil_windows.c',
- 'psutil/_psutil_common.c',
- 'psutil/arch/windows/process_info.c',
- 'psutil/arch/windows/process_handles.c',
- 'psutil/arch/windows/security.c',
- 'psutil/arch/windows/inet_ntop.c',
- 'psutil/arch/windows/services.c',
- ],
- define_macros=[
- VERSION_MACRO,
- # be nice to mingw, see:
- # http://www.mingw.org/wiki/Use_more_recent_defined_functions
- ('_WIN32_WINNT', get_winver()),
- ('_AVAIL_WINVER_', get_winver()),
- ('_CRT_SECURE_NO_WARNINGS', None),
- # see: https://github.com/giampaolo/psutil/issues/348
- ('PSAPI_VERSION', 1),
- ],
+ sources = sources,
+ define_macros = define_macros,
libraries=[
"psapi", "kernel32", "advapi32", "shell32", "netapi32",
"iphlpapi", "wtsapi32", "ws2_32",
--
2.7.2