针对Django应用的Heroku的条件点安装要求 [英] Conditional pip install requirements on Heroku for Django app

查看:77
本文介绍了针对Django应用的Heroku的条件点安装要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我开始说,我不认为有办法做到这一点...但是,有很多聪明的人在那里,所以我以为我会问! :)



我发现Randall Degges在在Heroku上设置一个Django应用程序 Internet Archive链接)。我真的很喜欢他将要求分解成不同的文件(common.txt,dev.txt,prod.txt等)。



这在Heroku上非常出色,但我也在Heroku上维护了Dev / QA网站,而且我还有几个不需要prod的软件包我使用Dev / QA。最好的例子是django-debug-toolbar。目前,我的生产要求为.txt,我动态地决定是否需要通过查看DEBUG设置在runtime.py中将其添加到settings.py中。



哪个工作正常...但是,如果我甚至无法安装它在prod中将是巨大的。我想我想要的是为了能够采取一个要求文件,允许条件包括(为什么不能只需要一个python文件)或Heroku支持一个配置设置,告诉它哪些需求文件使用。有没有人找到实现这个的方法?或者只是一厢情愿的想法?

解决方案

您是否查看了这个



如果你的Python应用程序包含一个setup.py文件,但不包括一个require.txt文件,python setup.py开发将用于安装您的软件包并解决您的依赖关系。
这适用于分发或setuptools。直接使用distutils的项目将被安装,但没有链接。该模块将不会更新,直到有一个版本碰撞。
如果您已经有一个需求文件但想使用此功能,可以将以下内容添加到需求文件中:

  -e。 

然后按照有条件地在python2.6上安装importlib


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 good article/post by Randall Degges on setting up a Django app on Heroku (Internet Archive link). I really like what he has to say about breaking your requirements up into different files (common.txt, dev.txt, prod.txt etc).

This works great on Heroku for production, but I also maintain a Dev/QA site on Heroku, and I have a few packages that I don't really need for prod that I do use for Dev/QA. The best example is django-debug-toolbar. Currently, I do have this in my production requirements.txt, and I dynamically decide if I need to add it to my installed apps, etc in settings.py at runtime by looking at the DEBUG setting.

Which works fine... but, it would be great if I could not even bother about installing it in prod. I guess what I sort of want is for pip to be able to take a requirements file that allows for conditionals includes (why couldn't it just take a python file?) or for Heroku to support a config setting that tells it which requirements file to use. Has anyone found a way of accomplishing this? Or is it just wishful thinking?

解决方案

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

这篇关于针对Django应用的Heroku的条件点安装要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆