diff --git a/mypy-requirements.txt b/mypy-requirements.txt index b0c632dddac5..6984d9a5d070 100644 --- a/mypy-requirements.txt +++ b/mypy-requirements.txt @@ -4,4 +4,4 @@ typing_extensions>=4.6.0 mypy_extensions>=1.0.0 pathspec>=0.9.0 tomli>=1.1.0; python_version<'3.11' -librt>=0.6.2 +librt>=0.6.2; platform_python_implementation != 'PyPy' diff --git a/pyproject.toml b/pyproject.toml index 38596ac2609d..54d2263a03f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ requires = [ "mypy_extensions>=1.0.0", "pathspec>=0.9.0", "tomli>=1.1.0; python_version<'3.11'", - "librt>=0.6.2", + "librt>=0.6.2; platform_python_implementation != 'PyPy'", # the following is from build-requirements.txt "types-psutil", "types-setuptools", @@ -53,7 +53,7 @@ dependencies = [ "mypy_extensions>=1.0.0", "pathspec>=0.9.0", "tomli>=1.1.0; python_version<'3.11'", - "librt>=0.6.2", + "librt>=0.6.2; platform_python_implementation != 'PyPy'", ] dynamic = ["version"] diff --git a/setup.py b/setup.py index 2892bdc64f38..bc45d90354e5 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ import glob import os import os.path +import platform import sys from typing import TYPE_CHECKING, Any @@ -12,6 +13,14 @@ sys.stderr.write("ERROR: You need Python 3.10 or later to use mypy.\n") exit(1) +if platform.python_implementation() == "PyPy": + sys.stderr.write( + "ERROR: Running mypy on PyPy is not supported yet.\n" + "To type-check a PyPy library please use an equivalent CPython version,\n" + "see https://github.com/mypyc/librt/issues/16 for possible workarounds.\n" + ) + exit(1) + # we'll import stuff from the source tree, let's ensure is on the sys path sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) diff --git a/test-requirements.txt b/test-requirements.txt index 3dab107eba61..883930c681a4 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -22,7 +22,7 @@ identify==2.6.15 # via pre-commit iniconfig==2.1.0 # via pytest -librt==0.6.2 +librt==0.7.3 ; platform_python_implementation != 'PyPy' # via -r mypy-requirements.txt lxml==6.0.2 ; python_version < "3.15" # via -r test-requirements.in