From ba586d1d48b2d78663999c8c0b7dfa992b818152 Mon Sep 17 00:00:00 2001 From: Bernat Zaragoza Travieso Date: Tue, 21 Nov 2017 13:42:23 +0100 Subject: [PATCH 1/2] Fix SIGKILL not available in Windows --- memory_profiler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/memory_profiler.py b/memory_profiler.py index e07881c..72e460c 100644 --- a/memory_profiler.py +++ b/memory_profiler.py @@ -17,8 +17,12 @@ import subprocess import logging import traceback -from signal import SIGKILL - +if sys.platform == "win32": + # any value except signal.CTRL_C_EVENT and signal.CTRL_BREAK_EVENT + # can be used to kill a process unconditionally in Windows + SIGKILL = -1 +else: + from signal import SIGKILL import psutil From a563dd0f4d752aebce7a6637e664a813e46df08c Mon Sep 17 00:00:00 2001 From: Bernat Zaragoza Travieso Date: Tue, 21 Nov 2017 13:44:39 +0100 Subject: [PATCH 2/2] Fix mprof command not working in Windows Adds mprof.bat to python scripts so the mprof command can be executed --- mprof.bat | 2 ++ setup.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 mprof.bat diff --git a/mprof.bat b/mprof.bat new file mode 100644 index 0000000..aeea6e5 --- /dev/null +++ b/mprof.bat @@ -0,0 +1,2 @@ +@echo off +python %~dpn0 %* \ No newline at end of file diff --git a/setup.py b/setup.py index fd320c8..592106b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ import os import io import re +import sys from setuptools import setup @@ -39,6 +40,10 @@ def find_version(*file_paths): """ +scripts = ['mprof'] +if sys.platform == "win32": + scripts.append('mprof.bat') + setup( name='memory_profiler', description='A module for monitoring memory usage of a python program', @@ -48,7 +53,7 @@ def find_version(*file_paths): author_email='f@bianp.net', url='http://pypi.python.org/pypi/memory_profiler', py_modules=['memory_profiler'], - scripts=['mprof'], + scripts=scripts, install_requires=['psutil'], classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f], license='BSD'