From 695d1d95f4addff83d9cada6232bf9f3089c0b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Sun, 25 Feb 2018 13:11:56 +0100 Subject: [PATCH 1/8] Make psutil an optional dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1bd24ab9a12c..962ac676c906 100644 --- a/setup.py +++ b/setup.py @@ -109,9 +109,9 @@ def run(self): classifiers=classifiers, cmdclass={'build_py': CustomPythonBuild}, install_requires = ['typed-ast >= 1.1.0, < 1.2.0', - 'psutil >= 5.4.0, < 5.5.0', ], extras_require = { ':python_version < "3.5"': 'typing >= 3.5.3', + 'dmypy': 'psutil >= 5.4.0, < 5.5.0', }, ) From 43e10e6629ec17a2a51159cea92d8ae2282d867d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Sun, 25 Feb 2018 14:12:24 +0100 Subject: [PATCH 2/8] Suggest installing psutil when it's not found --- mypy/dmypy_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index 166b174a141a..1d9594d09594 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -363,7 +363,8 @@ def get_meminfo() -> Mapping[str, float]: try: import psutil # type: ignore # It's not in typeshed yet except ImportError: - pass + if sys.platform != 'win32': + print('psutil not found, run pip install mypy[dmypy] to install the needed components for dmypy') else: process = psutil.Process(os.getpid()) meminfo = process.memory_info() From 59baef8603423c8878e08b0540f26f778c0d3f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Sun, 25 Feb 2018 14:12:47 +0100 Subject: [PATCH 3/8] Install psutil on non-win32 platforms only --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 962ac676c906..8b7017281bf2 100644 --- a/setup.py +++ b/setup.py @@ -112,6 +112,6 @@ def run(self): ], extras_require = { ':python_version < "3.5"': 'typing >= 3.5.3', - 'dmypy': 'psutil >= 5.4.0, < 5.5.0', + 'dmypy': 'psutil >= 5.4.0, < 5.5.0; sys_platform!="win32"', }, ) From 8911e08158f77ac2e47bde05aae01bda63b7cec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Sun, 25 Feb 2018 15:03:56 +0100 Subject: [PATCH 4/8] Fix flake8 warning --- mypy/dmypy_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index 1d9594d09594..b70a8ab322e5 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -364,7 +364,8 @@ def get_meminfo() -> Mapping[str, float]: import psutil # type: ignore # It's not in typeshed yet except ImportError: if sys.platform != 'win32': - print('psutil not found, run pip install mypy[dmypy] to install the needed components for dmypy') + print('psutil not found, run pip install mypy[dmypy]' + 'to install the needed components for dmypy') else: process = psutil.Process(os.getpid()) meminfo = process.memory_info() From f30901910998dcaf909ea721cb20844492d189d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Sun, 25 Feb 2018 18:39:02 +0100 Subject: [PATCH 5/8] Report missing psutil to res dict instead of printing --- mypy/dmypy_server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index b70a8ab322e5..abfb90887194 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -364,8 +364,10 @@ def get_meminfo() -> Mapping[str, float]: import psutil # type: ignore # It's not in typeshed yet except ImportError: if sys.platform != 'win32': - print('psutil not found, run pip install mypy[dmypy]' - 'to install the needed components for dmypy') + res['memory_psutil_missing'] = ( + 'psutil not found, run pip install mypy[dmypy] ' + 'to install the needed components for dmypy' + ) else: process = psutil.Process(os.getpid()) meminfo = process.memory_info() From c93e70a9824cf1b6e20be7eab1d0af7097b95f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Sun, 25 Feb 2018 18:45:22 +0100 Subject: [PATCH 6/8] Mention optional deps in docs --- docs/source/getting_started.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 3df67d3516f1..1d89b9f1f29d 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -13,6 +13,12 @@ you can install mypy with: $ python3 -m pip install mypy +Optionally you can install extra dependencies for daemon server with: + +.. code-block:: text + + $ python3 -m pip install mypy[dmypy] + Installing from source ********************** From 2c81ac90c2ddb09959e183968b7c08506aaadf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Sun, 25 Feb 2018 19:03:19 +0100 Subject: [PATCH 7/8] Fix type error --- mypy/dmypy_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index abfb90887194..cf4b15e3e6aa 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -349,10 +349,10 @@ def cmd_hang(self) -> Dict[str, object]: MiB = 2**20 -def get_meminfo() -> Mapping[str, float]: +def get_meminfo() -> Dict[str, Any]: # See https://stackoverflow.com/questions/938733/total-memory-used-by-python-process import resource # Since it doesn't exist on Windows. - res = {} + res = {} # type: Dict[str, Any] rusage = resource.getrusage(resource.RUSAGE_SELF) if sys.platform == 'darwin': factor = 1 From 2e7cd01caccdfa65ac0aa343b8f3802a7357a437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Mon, 26 Feb 2018 11:10:40 +0100 Subject: [PATCH 8/8] Revert "Mention optional deps in docs" This reverts commit c93e70a9824cf1b6e20be7eab1d0af7097b95f66. --- docs/source/getting_started.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 1d89b9f1f29d..3df67d3516f1 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -13,12 +13,6 @@ you can install mypy with: $ python3 -m pip install mypy -Optionally you can install extra dependencies for daemon server with: - -.. code-block:: text - - $ python3 -m pip install mypy[dmypy] - Installing from source **********************