Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

python - Conditional pip install requirements on Heroku for Django app

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...