views:

69

answers:

3

I have read the documentation but I don't understand.

Why do I have to use distutils to install python modules ?

Why do I just can't save the modules in python path ?

+1  A: 

You don't have to use distutils to get your own modules working on your own machine; saving them in your python path is sufficient.

When you decide to publish your modules for other people to use, distutils provides a standard way for them to install your modules on their machines. (The "dist" in "distutils" means distribution, as in distributing your software to others.)

Forest
+4  A: 

You don't have to use distutils. You can install modules manually, just like you can compile a C++ library manually (compile every implementation file, then link the .obj files) or install an application manually (compile, put into its own directory, add a shortcut for launching). It just gets tedious and error-prone, as every repetive task done manually. Moreover, the manual steps I listed for the examples are pretty optimistic - often, you want to do more. For example, PyQt adds the .ui-to-.py-compiler to the path so you can invoke it via command line. So you end up with a stack of work that could be automated. This alone is a good argument.

Also, the devs would have to write installing instructions. With distutils etc, you only have to specify what your project consists of (and fancy extras if and only if you need it) - for example, you don't need to tell it to put everything in a new folder in site-packages, because it already knows this.

So in the end, it's easier for developers and for users.

delnan
+2  A: 

what python modules ? for installing python package if they exist in pypi you should do :

 pip install <name_of_package> 

if not, you should download them .tar.gz or what so ever and see if you find a setup.py and run it like this :

  python setup.py install 

or if you want to install it in development mode (you can change in package and see the result without installing it again ) :

  python setup.py develop

this is the usual way to distribute python package (the setup.py); and this setup.py is the one that call disutils.

to summarize this distutils is a python package that help developer create a python package installer that will build and install a given package by just running the command setup.py install.

so basically what disutils does (i will sit only important stuff):

  • it search dependencies of the package (install dependencies automatically).
  • it copy the package modules in site-packages or just create a sym link if it's in develop mode
  • you can create an egg of you package.
  • it can also run test over your package.
  • you can use it to upload your package to pypi.

if you want more detail see this http://docs.python.org/library/distutils.html

singularity