Repository: python/mypy

Issue:
psutil version limitations
#4130 by @gvanrossum, in Oct 2017, added a dependency to psutil >= 5.4.0 < 5.5.0. From git blame I see how the psutil dependency has since been made optional, but the version boundaries have never been touched and I can't find any reasoning behind them.

The only place I could find where psutil is used is:
https://github.com/python/mypy/blob/d387906ebe6afc6d683c1564d3a1a5391254bd57/mypy/dmypy_server.py#L568-L573

I just tested the above code snippet on the following anaconda setups, and they all worked fine:

* Linux, python=3.5.0, psutil=4.0.0
* Linux, python=3.7.3, psutil=5.6.2
* Windows 10, python=3.5.0, psutil=4.0.0
* Windows 10, python=3.7.3, psutil=5.6.2

From my tests it looks like peak_wset was added in psutil 4.0, even if it's not mentioned in the changelog https://github.com/giampaolo/psutil/blob/master/HISTORY.rst.

Any objections to changing the dependency to psutil >= 4.0?


Discussion:
Fine with me as long as it also works on Mac.

On Fri, May 3, 2019 at 06:38 crusaderky <notifications@github.com> wrote:

> #4130 <https://github.com/python/mypy/pull/4130> by @gvanrossum
> <https://github.com/gvanrossum>, in Oct 2017, added a dependency to
> psutil >= 5.4.0 < 5.5.0. From git blame I see how the psutil dependency has
> since been made optional, but the version boundaries have never been
> touched and I can't find any reasoning behind them.
>
> The only place I could find where psutil is used is:
>
> https://github.com/python/mypy/blob/d387906ebe6afc6d683c1564d3a1a5391254bd57/mypy/dmypy_server.py#L568-L573
>
> I just tested the above code snippet on the following anaconda setups, and
> they all worked fine:
>
>    - Linux, python=3.5.0, psutil=4.0.0
>    - Linux, python=3.7.3, psutil=5.6.2
>    - Windows 10, python=3.5.0, psutil=4.0.0
>    - Windows 10, python=3.7.3, psutil=5.6.2
>
> From my tests it looks like peak_wset was added in psutil 4.0, even if
> it's not mentioned in the changelog
> https://github.com/giampaolo/psutil/blob/master/HISTORY.rst.
>
> Any objections to changing the dependency to psutil >= 4.0?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/python/mypy/issues/6758>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAWCWMTIKTUUUGQKHUZZDG3PTQIZ5ANCNFSM4HKS4PKQ>
> .
>
-- 
--Guido (mobile)


Resolving patch:
diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py
--- a/mypy/dmypy_server.py
+++ b/mypy/dmypy_server.py
@@ -559,13 +559,12 @@ def get_meminfo() -> Dict[str, Any]:
     try:
         import psutil  # type: ignore  # It's not in typeshed yet
     except ImportError:
-        if sys.platform != 'win32':
-            res['memory_psutil_missing'] = (
-                '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())
+        process = psutil.Process()
         meminfo = process.memory_info()
         res['memory_rss_mib'] = meminfo.rss / MiB
         res['memory_vms_mib'] = meminfo.vms / MiB
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -174,12 +174,10 @@ def run(self):
       classifiers=classifiers,
       cmdclass=cmdclass,
       # When changing this, also update test-requirements.txt.
-      install_requires = ['typed-ast >= 1.3.5, < 1.4.0',
-                          'mypy_extensions >= 0.4.0, < 0.5.0',
-                          ],
+      install_requires=['typed-ast >= 1.3.5, < 1.4.0',
+                        'mypy_extensions >= 0.4.0, < 0.5.0',
+                        ],
       # Same here.
-      extras_require = {
-          'dmypy': 'psutil >= 5.4.0, < 5.5.0; sys_platform!="win32"',
-      },
+      extras_require={'dmypy': 'psutil >= 4.0'},
       include_package_data=True,
       )


Test patch: