coverage.py cannot be imported in Jython2.7 due to missing multiprocessing library

Issue #551 resolved
Chris
created an issue

When running Jython 2.7.1b3 and using multiprocessing by way of pytest-cov:

  File "/lib/jython2.7/site-packages/pytest_cov/plugin.py", line 5, in <module>
    from coverage.misc import CoverageException
  File "/lib/jython2.7/site-packages/coverage-4.3.1-py2.7.egg/coverage/__init__.py", line 13, in <module>
    from coverage.control import Coverage, process_startup
  File "/lib/jython2.7/site-packages/coverage-4.3.1-py2.7.egg/coverage/control.py", line 27, in <module>
    from coverage.multiproc import patch_multiprocessing
  File "/lib/jython2.7/site-packages/coverage-4.3.1-py2.7.egg/coverage/multiproc.py", line 6, in <module>
    import multiprocessing
ImportError: No module named multiprocessing

According to a Jython issue this is a known gap.

There seems to be no way to prevent the attempt to import multiprocessing, as it happens in unconditional imports in __init__.py -> control.py -> multiproc.py

Comments (8)

  1. Ned Batchelder repo owner

    @Chris it's been a long time since I've been able to support Jython. The Jython people aren't making this easy... I tried running my tox tests against 2.7.0, and couldn't even install the requirements:

    ☿ .tox/jython/bin/python -m pip install -rrequirements/pytest.pip
    Exception:
    Traceback (most recent call last):
      File "/Users/ned/coverage/trunk/.tox/jython/Lib/site-packages/pip/basecommand.py", line 215, in main
        status = self.run(options, args)
      File "/Users/ned/coverage/trunk/.tox/jython/Lib/site-packages/pip/commands/install.py", line 310, in run
        self.populate_requirement_set(
      File "/Users/ned/coverage/trunk/.tox/jython/Lib/site-packages/pip/basecommand.py", line 292, in populate_requirement_set
        for req in parse_requirements(
      File "/Users/ned/coverage/trunk/.tox/jython/Lib/site-packages/pip/req/req_file.py", line 89, in parse_requirements
        for line_number, line in lines_enum:
      File "/Users/ned/coverage/trunk/.tox/jython/Lib/site-packages/pip/req/req_file.py", line 323, in ignore_comments
        for line_number, line in lines_enum:
      File "/Users/ned/coverage/trunk/.tox/jython/Lib/site-packages/pip/req/req_file.py", line 298, in join_lines
        if COMMENT_RE.match(line):
    RuntimeError: maximum recursion limit exceeded
    

    I went to jython.org to get the 2.7.1b1 you mentioned, and I see nothing there. Googling around, the releases are mentioned on Frank's blog and nowhere else? I'm trying to install it now, but one way to get better Jython support would be to encourage Jython to be less unique in their release choreography.

  2. Ned Batchelder repo owner

    I've pushed some changes to deal with a missing multiprocessing module. The test suite mostly still doesn't run, so let me know what you find trying to use coverage.py on Jython.

  3. Ned Batchelder repo owner

    Also, other tips for Jython would be appreciated. For example, I can't run "coverage --version" under Jython because shebang line in the launcher refers to the jython executable, which is really a Python 2.7 script, or something?

  4. Chris reporter

    I have to admit, the thing I most want is for importing it not to blow up on Jython :) If it works, so much the better -- and I'll probably be motivated to look at that in the near-ish future. But for now, "not exploding" is a good start.

    Will you release a 4.3.2 to include that?

  5. Log in to comment