nhoffman / mkvenv

A wrapper for virtualenv, pip, and wheel
3 stars 1 forks source link

--index-url in requirements.txt throws error #4

Open tyleraland opened 9 years ago

tyleraland commented 9 years ago

if a requirements file contains: --index-url https://pypi.python.org/simple/

this points pip there (the command line feature is documented here https://pip.pypa.io/en/latest/user_guide.html#requirements-files but I see no explicit mention of the behavior when the line is included in the requirements.txt directly).

Regardless, pip either uses that line or ignores it. If mkvenv sees that line and throws an error.

nhoffman commented 9 years ago

Thanks for the issue - I agree that throwing an error is not what we want if the file is valid for pip. As you point out, the behavior in pip isn't very well described - it looks like package names are skipped when a line starts with a (supported) command line option (--index-url https://pypi.python.org/simple/ twine), and throws an error when the package name precedes the option (twine --index-url https://pypi.python.org/simple/). It also appears from the pip source code (https://github.com/pypa/pip/blob/573ddd4/pip/req/req_file.py#L27) that only the first option on each line is considered. So it seems that a command line option is expected to appear on a line without a package name, one at a time.

The difficulty is that mkvenv executes each line of requirements.txt, one line at a time - is the desired behavior to apply any command line options appearing in requirements.txt to all packages?

In general, I'd like to make sure not to extend pip's definition for the requirements.txt file format (except by enforcing the order in which packages are installed).

tyleraland commented 9 years ago

Perhaps the right thing to do is say that the only forms of lines supported are...

[-e ] [version-control+[repository_URL[@tagname[#egg=eggname]]]]

or something. I agree that attempting to support un-documented features is a fool's errand.