Skip to content

Make psutil an optional dependency #4634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ you can install mypy with:

$ python3 -m pip install mypy

Optionally you can install extra dependencies for daemon server with:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this since dmypy is otherwise undocumented (and unsupported). This will only confuse users.


.. code-block:: text

$ python3 -m pip install mypy[dmypy]

Installing from source
**********************

Expand Down
10 changes: 7 additions & 3 deletions mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -363,7 +363,11 @@ def get_meminfo() -> Mapping[str, float]:
try:
import psutil # type: ignore # It's not in typeshed yet
except ImportError:
pass
if sys.platform != 'win32':
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()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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; sys_platform!="win32"',
},
)