0

I've got a simple project that I want to be able to be pip installed - and where the 'development time' dependencies are the same as the 'use time' dependencies. To avoid duplication between setup.py and requirements.txt - I'm using the 'trick' to have my requirements.txt simply contain . (to pick up dependencies from setup.py). When working on the project, we can then clone it and pip install -r requirements.txt.

The problem I'm having with this is that this also seems to end up installing the actual project itself (presumably due to going through setup.py?)

Is there an option I can use with pip install to prevent this? Or some other way to work around it without ending up installing the project itself?

  • 1
    "The problem I'm having with this is that this also seems to end up installing the actual project itself (presumably due to going through setup.py?)"—no, you are telling pip to do this. That's what `pip install .` does, which you are doing with `.` in your `requirements.txt`. – ChrisGPT was on strike Nov 24 '22 at 12:38
  • 1
    I'm confused: you want your package to be `pip install`ed, but the you say you don't want the package to be installed? – ChrisGPT was on strike Nov 24 '22 at 12:43
  • Yeah - I see where I'm going wrong now - so let me re-phrase: I wan't to install the dependencies of the project I'm working on (so that I can work on it) without installing the project itself, and _ideally_ using the dependencies from setup.py without having to duplicate in requirements.txt – Aconstnull Nov 24 '22 at 13:12
  • 1
    Do the other way around — write all dependencies in `requirements.txt` and read the file in `setup.py`. You can do simple line splitting like in https://stackoverflow.com/a/14399775/7976758 or complex parsing like in https://stackoverflow.com/a/16624700/7976758 . Found in https://stackoverflow.com/search?q=%5Bsetuptools%5D+%22install_requires%22+%22requirements.txt%22 – phd Nov 24 '22 at 13:15
  • Thanks very much! Yup I'll try that. I now also finally understand what putting '.' in the requirements file actually means - so this has been super helpful! – Aconstnull Nov 24 '22 at 13:25
  • 2
    Ah, so you're concerned about development, not production. Assuming the issue is that you want to be able to edit and run your project without installing it again, try installing in editable mode: [`pip install -e .`](https://stackoverflow.com/q/35064426/354577). You can put `-e .` into your `requirements.txt` file to do the same. – ChrisGPT was on strike Nov 24 '22 at 13:28
  • Yes, sounds like what you want is the "editable installation"... -- It seems like you do not need any `requirements.txt` file at all here. -- But it is hard to say from reading your question. Maybe a bit of "XY problem" here... – sinoroc Nov 24 '22 at 15:50
  • yup - thanks. For now I'm going with just having `-e .` in my requirements file - and everything is working nicely in my setup now – Aconstnull Nov 25 '22 at 16:16

0 Answers0