5

I'm using Python 3.5.1 and pip 7.1.2:

pip3 --version
pip 7.1.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5)

In my requirements.txt, I write:

pysam>=0.9.0

Then I use pip3 to install this requirements.txt file like this:

pip3 install -U -r requirements.txt

This pysam has its own dependencies: cython, which can be seen at: https://github.com/pysam-developers/pysam/blob/master/requirements.txt

However, using pip3 install -U -r requirements.txt seems not to install pysam's dependency recursively, it will throw an expection that ValueError: no cython installed.

Does anyone have ideas about why requirements.txt are not installed recursively?

Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237
  • Related? https://pip.readthedocs.io/en/stable/user_guide/#only-if-needed-recursive-upgrade – OneCricketeer May 06 '16 at 03:05
  • @cricket_007 Thanks, but I don't think `--upgrade` is what is expected as I don't have a old version of `cython`. I haven't installed `cython` before at all.. – Hanfei Sun May 06 '16 at 03:08
  • If I read that correctly, then it says it should download the nested dependency. "would upgrade SomePackage **and** AnotherPackage **despite AnotherPackage already being satisfied.**" – OneCricketeer May 06 '16 at 03:11
  • Maybe you haven't installed it directly, but it could have been installed transitively (this is the word you want instead of recursively) by another package. – marcospereira May 06 '16 at 03:13
  • @cricket_007 Thanks! I delete the `-U` option and use `pip3 install -r requirements.txt` but the `cython` dependency is still not installed... – Hanfei Sun May 06 '16 at 03:13

1 Answers1

4

The pysam setup.py script seems to use requires instead of the typical install_requires; the latter generates the metadata that pip needs to figure out its requirements. In fact, pysam seems to need cython in order to build itself, so more appropriately, it should be using setup_requires. You can check that installing pysam fails the normal way if you don't have cython installed.

(edit: DOES NOT WORK) In any case, you can get around this by placing cython before pysam in your requirements file; that way, pip will try to install cython before it moves on the pysam:

cython>=0.22
pysam>=0.9.0

Edit: to be clear, this has nothing to do with pip -r requirements.txt itself. It's that pip doesn't receive enough metadata from pysam to know that it needs to install cython first before trying to install pysam.

Second edit: You're right. The installation still fails because pip tries to get the metadata from the pysam setup script before it moves on to the build stage, and the pysam setup script throws that error if cython isn't installed. In this specific case, I'm not sure there's a solution beyond installing Cython in a seperate command, beforehand.

Te-jé Rodgers
  • 878
  • 1
  • 7
  • 20
  • Thanks, I used your approach to modify the `requirements.txt` (I put cython before pysam in the txt file), but it seems that pip will still build pysam before cython. I pasted my stdout at http://pastebin.com/e2BTS0FP – Hanfei Sun May 06 '16 at 03:20
  • @hanfeisun Yeah, it seems to the pysam setup script bails out even when pip is just trying to get metadata from it, whenever cython isn't installed. Since pip collects metadata for all packages first before the installation step, this above approach will not work. Sadly, I'm out of ideas. – Te-jé Rodgers May 06 '16 at 03:32