Skip to content

Not possible to build and install mypy with mypyc support, and run the tests against it. #16143

@eli-schwartz

Description

@eli-schwartz

mypy's built wheels includes two installable packages available after mypy is fully installed. They appear to not be practically usable:

  • import mypy.test
  • import mypyc.test

The testsuite depends on conftest.py and pyproject.toml from the root of the repository to run. Also, the test-data/ directory provides data the tests need. None of this data is distributed in the built wheels.

The fact that the packages are installed at all appears to be a bug. This is a side effect of #2784 which requested that the sdist (not the wheel) include the testsuite so that redistributors such as Debian can run the tests when packaging.

The intertwining of the testsuite as part of the mypy module alongside the requirement to use data from the sources makes it difficult to test mypy correctly. Allowing the tests to be detected by pytest means making the mypy/ directory importable and causes the tests to incorrectly run against the pure-python version, which means the compiled extensions do not get tested.

And mypy's own CI is working around this with editable installs:

- name: Compiled with mypyc
if: ${{ matrix.test_mypyc }}
run: |
pip install -r test-requirements.txt
CC=clang MYPYC_OPT_LEVEL=0 MYPY_USE_MYPYC=1 pip install -e .
- name: Setup tox environment
run: tox run -e ${{ matrix.toxenv }} --notest
- name: Test
run: tox run -e ${{ matrix.toxenv }} --skip-pkg-install -- ${{ matrix.tox_extra_args }}

Also, the installation footprint of these unused files seems to be a couple of MB, which could be a nice optimization...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions