Title: pip install -r requirements.txt fails with RE recursion limit
Type: Severity: major
Components: Versions: Jython 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jamesmudd, pjac, stefan.richthofer
Priority: Keywords:

Created on 2017-04-06.10:52:26 by pjac, last changed 2017-04-08.11:46:29 by jamesmudd.

msg11299 (view) Author: Peter (pjac) Date: 2017-04-06.10:52:25
Discovered and tested under macOS, then reduced to the following simple test case

(1) Install Jython 2.7.0, e.g. as follows:

$ java -jar jython-installer-2.7.0.jar -s -d ~/jython-2.7.0

(2) Update pip to current release, pip 9.0.1

$ ~/jython-2.7.0/bin/jython -m pip install --upgrade pip
Downloading/unpacking pip from
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.6.dev1
    Uninstalling pip:
      Successfully uninstalled pip
Successfully installed pip
Cleaning up...

(3) Attempt to run pip with a requirements file, even a trivial example:

$ echo pip > requirements.txt
$ ~/jython-2.7.0/bin/jython -m pip install -r requirements.txt 
Traceback (most recent call last):
  File "/Users/xxx/jython-2.7.0/Lib/site-packages/pip/", line 215, in main
    status =, args)
  File "/Users/xxx/jython-2.7.0/Lib/site-packages/pip/commands/", line 310, in run
  File "/Users/xxx/jython-2.7.0/Lib/site-packages/pip/", line 292, in populate_requirement_set
    for req in parse_requirements(
  File "/Users/xx/jython-2.7.0/Lib/site-packages/pip/req/", line 89, in parse_requirements
    for line_number, line in lines_enum:
  File "/Users/xxx/jython-2.7.0/Lib/site-packages/pip/req/", line 323, in ignore_comments
    for line_number, line in lines_enum:
  File "/Users/xxx/jython-2.7.0/Lib/site-packages/pip/req/", line 298, in join_lines
    if COMMENT_RE.match(line):
RuntimeError: maximum recursion depth exceeded (Java StackOverflowError)

I'm assuming this is a Jython problem given pip 9.0.1 works fine for me under CPython and PyPy.
msg11300 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-04-06.12:27:17
Peter, could you please test this with current trunk version or at least with 2.7.1 soft release candidate?

There have been some improvements regarding PIP since Jython 2.7.0.
msg11301 (view) Author: James Mudd (jamesmudd) Date: 2017-04-08.11:46:28
I have just tested this with the current master and it appears to have already been fixed. I get:

james@james-ubuntu:~/jython2.7.1rc1/bin$ ./jython -m pip install --upgrade pip
Requirement already up-to-date: pip in /home/james/jython2.7.1rc1/Lib/site-packages

james@james-ubuntu:~/jython2.7.1rc1/bin$ ./pip --version
pip 9.0.1 from /home/james/jython2.7.1rc1/Lib/site-packages (python 2.7)

james@james-ubuntu:~/jython2.7.1rc1/bin$ echo pip > requirements.txt 

james@james-ubuntu:~/jython2.7.1rc1/bin$ ./jython -m pip install -r requirements.txt 
Requirement already satisfied: pip in /home/james/jython2.7.1rc1/Lib/site-packages (from -r requirements.txt (line 1))
Date User Action Args
2017-04-08 11:46:29jamesmuddsetnosy: + jamesmudd
messages: + msg11301
2017-04-06 12:27:17stefan.richthofersetnosy: + stefan.richthofer
messages: + msg11300
2017-04-06 10:52:27pjaccreate