machinalis / iepy

Information Extraction in Python
BSD 3-Clause "New" or "Revised" License
906 stars 186 forks source link

Use of pip.req.parse_requirements breaks with newer versions of pip #63

Closed paul-english closed 9 years ago

paul-english commented 9 years ago

Using parse_requirements isn't a recommended way to deal with setup.py & requirements.txt dependencies. This is because you can't be sure of the pip version used by someone installing your package.

With pip 6.0.6 on python 3.4 attempting to install iepy ends up with the following error.

pip install iepy
Collecting iepy
  Using cached iepy-0.9.2.tar.gz
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-f81tq_so/iepy/setup.py", line 15, in <module>
        base_reqs = [str(x.req) for x in parse_requirements(requirements_path)]
      File "/tmp/pip-build-f81tq_so/iepy/setup.py", line 15, in <listcomp>
        base_reqs = [str(x.req) for x in parse_requirements(requirements_path)]
      File "/srv/venvs/venv/lib/python3.4/site-packages/pip/req/req_file.py", line 19, in parse_requirements
        "parse_requirements() missing 1 required keyword argument: "
    TypeError: parse_requirements() missing 1 required keyword argument: 'session'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

      File "<string>", line 20, in <module>

      File "/tmp/pip-build-f81tq_so/iepy/setup.py", line 15, in <module>

        base_reqs = [str(x.req) for x in parse_requirements(requirements_path)]

      File "/tmp/pip-build-f81tq_so/iepy/setup.py", line 15, in <listcomp>

        base_reqs = [str(x.req) for x in parse_requirements(requirements_path)]

      File "/srv/venvs/env/lib/python3.4/site-packages/pip/req/req_file.py", line 19, in parse_requirements

        "parse_requirements() missing 1 required keyword argument: "

    TypeError: parse_requirements() missing 1 required keyword argument: 'session'

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-f81tq_so/iepy

One thing I've seen is to have the dependencies only specified in setup.py, and in requirements.txt simply have -e . to install the local package. I'm not sure if this is the recommended approach, but it may work.

rafacarrascosa commented 9 years ago

Hi Paul, thanks for the report.

We just tripped with this issue a few days ago and commited a hotfix in the development branch using PipSession, which was an optional argument in older versions of pip... it's not ideal but it works for now :(

Your fix suggestion is interesting, what do you think of it @jmansilla?

jmansilla commented 9 years ago

I like what Paul is mentioning, and sounds less hackish (ie, lower dependence on what pip boys decide).

paul-english commented 9 years ago

I came across that in a comment on this post. It's noted that pip isn't supported as an API

Speaking as a pip maintainer pip does not support being called as an API like this at all. ~Donald Stufft

Additionally another answer in that thread offers up the solution I proposed.

rafacarrascosa commented 9 years ago

@log0ymxm yeah, I got the same answer a few days ago: https://github.com/pypa/pip/issues/2286 https://github.com/pypa/pip/issues/2287