Conditional pip install requirements on Heroku for Django app

前端 未结 3 1088
深忆病人
深忆病人 2020-12-10 18:00

Let me start by saying, that I don\'t think there is a way to do this... but, there are a lot of clever people out there and so I thought I would ask! :)

I found a

相关标签:
3条回答
  • 2020-12-10 18:37

    I had similar needs in buildout and implemented it there. Now that I am migrating from buildout to pip, I came out with this script to use some various requirements files based on some conditions, that can based on os/arch or some environment variable or anything you like. Crude but effective for me.

    See https://gist.github.com/pombredanne/72130ee6f202e89c13bb

    0 讨论(0)
  • 2020-12-10 18:41

    Have you looked into this?

    If your Python application contains a setup.py file but excludes a requirements.txt file, python setup.py develop will be used to install your package and resolve your dependencies. This works best with distribute or setuptools. Projects that use distutils directly will be installed, but not linked. The module won’t get updated until there’s a version bump. If you already have a requirements file but would like to utilize this feature, you can add the following to your requirements file:

    -e .
    

    and then follow on the recommendations in Conditionally installing importlib on python2.6

    0 讨论(0)
  • 2020-12-10 18:41

    Yes, it's wishful thinking. The pip requirements file is very simple. Literally, all pip does is just prepend pip install to each line in the file, so conditionals and such are a no-go. Having separate requirement files for each environment is a nice idea, but the question becomes why not just have a version for your Dev/QA site as well?

    That said, I think this is all a bit academic anyways. Simply having a package installed doesn't hurt anything. For instance, it doesn't matter if you have the django-debug-toolbar package installed even in production, your production instance won't actually use it, so aside from the few kilobytes of drive space it takes up, it's not a problem.

    Personally, I always just have one requirements file, and in there, I only put requirements, i.e. these are packages that the site literally cannot run without. Things like django-debug-toolbar, ipython, etc. I just install manually when I need them.

    0 讨论(0)
提交回复
热议问题