0

Is there a way to import all the modules in the django project itself instead of setting up again and again in all the systems. I would have used gem freeze or something like that in a rails project.

Prabesh Shrestha
  • 2,732
  • 4
  • 29
  • 44

4 Answers4

3

There's a bit of a terminology confusion here: "modules" refers to individual .py files within a Python package. And importing is what you do within code, to bring modules into the current namespace.

I think what you're asking is how to install Python packages on deployment. The answer to that is, use pip with the freeze command, in conjunction with virtualenv.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Acutally I just want to deploy a single app so I don't want to go through virtualenv at the moment. I just want to replicate the installed module from my development to the staging/production server. – Prabesh Shrestha Aug 11 '11 at 09:44
  • 2
    Prabesh, even if you deploy a single "app" (you'd say "a site with one app"), it have dependencies, that you install. They are not "modules" but "packages". You use `pip` to install them. Also the best way for you to clarify dependencies is by using a bare virtualenv locally, in which you just install the strictly required packages: `virtualenv myenv --no-site-packages`, so once your app is working, `pip freeze > requirements.txt` will store the list, and `pip install -r requirements.txt` will install them again. – rewritten Aug 11 '11 at 10:27
1

Instead of

gem freeze

Try to use

pip bundle

I found this solution here: Django equivalent to "rake rails:freeze:gems" and "rake gems:unpack"

Community
  • 1
  • 1
Nikolay Fominyh
  • 8,946
  • 8
  • 66
  • 102
1

First of all you should be using virtualenv. This way the python path of your django app only has stuff relevant to it. This also allows you to run several separate django / python apps on the same server without them bumping heads.

When you have a virtualenv with your django app running in it you need to generate a requirements file.

pip freeze -E virtualenv_path > stable-req.txt

You can then use this file to generate a bundle.

pip bundle mybundle.bundle -r stable-req.txt

This bundle can then be used to deploy with.

0

Is there a reason you want to import all modules?

It's a good practice to import only those modules, classes etc. which are needed...

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
  • Actually I am missing io module in my staging server which I have in my local system. I am using python 2.5.2 in the server and couldn't find a way to install io module there. So, I though I could push the io module from my development server to the production. – Prabesh Shrestha Aug 11 '11 at 09:21