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

"pip freeze -r" returns ValueError() if requirements file contains --find-links #391

Closed
dasein opened this Issue Dec 3, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@dasein

dasein commented Dec 3, 2011

It seems that pip freeze should not pass --find-links or --index-url to distribute/setuptools when inlined in a requirements file. Here is an easy way to repro the problem:

  1. echo "--find-links http://foo.bar/" > /tmp/req.txt
  2. pip freeze -r /tmp/req.txt

"""
Exception:
Traceback (most recent call last):
File "/Users/hpfennig/work/pip/pip/basecommand.py", line 95, in main
self.run(options, args)
File "/Users/hpfennig/work/pip/pip/commands/freeze.py", line 92, in run
line_req = InstallRequirement.from_line(line)
File "/Users/hpfennig/work/pip/pip/req.py", line 105, in from_line
return cls(req, comes_from, url=url)
File "/Users/hpfennig/work/pip/pip/req.py", line 39, in init
req = pkg_resources.Requirement.parse(req)
File "/Users/hpfennig/.virtualenvs/pip-bug-virt-env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2510, in parse
reqs = list(parse_requirements(s))
File "/Users/hpfennig/.virtualenvs/pip-bug-virt-env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2436, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "/Users/hpfennig/.virtualenvs/pip-bug-virt-env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2404, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', '--find-links http://foo.bar/', 'at', ' http://foo.bar/')

Storing complete log in /Users/hpfennig/.pip/pip.log
"""

I have a fix, but I am not sure this is the correct way to go about it. Would be happy to do an official pull request if needed.

diff --git a/pip/commands/freeze.py b/pip/commands/freeze.py
index 01b5df9..03ac80f 100644
--- a/pip/commands/freeze.py
+++ b/pip/commands/freeze.py
@@ -85,7 +85,9 @@ class FreezeCommand(Command):
elif (line.startswith('-r') or line.startswith('--requirement')
or line.startswith('-Z') or line.startswith('--always-unzip')
or line.startswith('-f') or line.startswith('-i')

  •                  or line.startswith('--extra-index-url')):
    
  •                  or line.startswith('--extra-index-url')
    
  •                  or line.startswith('--find-links')
    
  •                  or line.startswith('--index-url')):
                 f.write(line)
                 continue
             else:
    
@carljm

This comment has been minimized.

Show comment
Hide comment
@carljm

carljm Dec 3, 2011

Contributor

Yep, that fix looks correct - thanks for the report! A pull request (with a test; should be easy to follow other examples in test_freeze.py) would be great - otherwise I'll get to it when I can.

Contributor

carljm commented Dec 3, 2011

Yep, that fix looks correct - thanks for the report! A pull request (with a test; should be easy to follow other examples in test_freeze.py) would be great - otherwise I'll get to it when I can.

@dasein

This comment has been minimized.

Show comment
Hide comment
@dasein

dasein Dec 4, 2011

Please ignore the first referenced commit (8d692f5). I performed a bad upstream merge and needed to start over. You should have a pull request for the correct commit, 9732a96.

dasein commented Dec 4, 2011

Please ignore the first referenced commit (8d692f5). I performed a bad upstream merge and needed to start over. You should have a pull request for the correct commit, 9732a96.

@carljm carljm closed this in 9732a96 Dec 5, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment