How do you package and deploy a Python application in your own server?
-
What is the best way to manage dependencies. I might have multiple builds each day and they might be using different versions of a same library. Is it a good idea to build a debian package and install in the server? Should I directly run a script which would install the requirements first and then download the python code and run it?
-
Answer:
Been there, done that. No comments on deb packaging the whole thing. The approach i found out to be good enough so far is to put everything inside a virtualenv http://docs.python-guide.org/en/latest/dev/virtualenvs/ Setup: sudo apt-get install python-pip python-virtualenv Go to a directory where you want your code to be. Create a virtual environment by 1. virtualenv --distribute <env-name> A directory will be created and you can activate the same via 2. source <env-name>/bin/activate Once this is done pull up code, install all the dependencies using pip until your code works. via pip install <package-name>=<version_no> Once you are done with fire this, it's going to list all the dependencies you have pip freeze It's going to list all the dependencies that you need for your code to run. Place this in a requirements.txt file Next time you want to setup this same again quickly Just follow 1 and 2 and run pip install -r requirements.txt You should be fine with this. Let me know if it requires an edit or is not clear.
Bipul Jain at Quora Visit the source
Related Q & A:
- How do I make a python web program that is on a ubuntu server allow access to the server?Best solution by Yahoo! Answers
- How to deploy a server script?Best solution by Stack Overflow
- How to update a python package?Best solution by Stack Overflow
- How can I describe myself on a job application?Best solution by Yahoo! Answers
- How to explain my misdemeanor on a job application?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.