views:

2392

answers:

5

The simplest way to deal with python package installations, so far, to me, has been to check out the source from the source control system and then add a symbolic link in the python dist-packages folder.

Clearly since source control provides the complete control to downgrade, upgrade to any branch, tag, it works very well.

Is there a way using one of the Package installers (easy_install or pip or other), one can achieve the same.

easy_install obtains the tar.gz and install them using the setup.py install which installs in the dist-packages folder in python2.6. Is there a way to configure it, or pip to use the source version control system (SVN/GIT/Hg/Bzr) instead.

A: 

Hello becomingGuru,

I don't develop in Python but í've founded this tutorial: http://peak.telecommunity.com/DevCenter/EasyInstall , it's the best thing that i have found, I hope you find the correct answer.Sorry about my english

Nathan Campos
+7  A: 

If you download or check out the source distribution of a package — the one that has its "setup.py" inside of it — then if the package is based on the "setuptools" (which also power easy_install), you can move into that directory and say:

$ python setup.py develop

and it will create the right symlinks in dist-packages so that the .py files in the source distribution are the ones that get imported, rather than copies installed separately (which is what "setup.py install" would do — create separate copies that don't change immediately when you edit the source code to try a change).

As the other response indicates, you should try reading the "setuptools" documentation to learn more. "setup.py develop" is a really useful feature! Try using it in combination with a virtualenv, and you can "setup.py develop" painlessly and without messing up your system-wide Python with packages you are only developing on temporarily:

http://pypi.python.org/pypi/virtualenv
Brandon Craig Rhodes
+1: virtualenv is essential when doing python development
codeape
virtualenv is essential <3
skyl
+1  A: 

easy_install has support for downloading specific versions. For example:

easy_install python-dateutil==1.4.0

Will install v1.4, while the latest version 1.4.1 would be picked if no version was specified.

There is also support for svn checkouts, but using that doesn't give you much benefits from your manual version. See the manual for more information above.

Being able to switch to specific branches is rarely useful unless you are developing the packages in question, and then it's typically not a good idea to install them in site-packages anyway.

Lennart Regebro
should it not be python-dateutil==1.4.0 (double equals)?
Typeoneerror
yes it should. I fixed it.
David Cournapeau
A: 

easy_install accepts a URL for the source tree too. Works at least when the sources are in Subversion.

Heikki Toivonen
+11  A: 

Using pip this is quite easy. For instance:

pip install -e hg+http://bitbucket.org/andrewgodwin/south/#egg=South

Pip will automatically clone the source repo and run "setup.py develop" for you to install it into your environment (which hopefully is a virtualenv). Git, Subversion, Bazaar and Mercurial are all supported.

You can also then run "pip freeze" and it will output a list of your currently-installed packages with their exact versions (including, for develop-installs, the exact revision from the VCS). You can put this straight into a requirements file and later run

pip install -r requirements.txt

to install that same set of packages at the exact same versions. Very nice for repeatable deployments.

Carl Meyer
This is a pretty old question. I personally figured all these well enough now. But I am sure, it will help others that stumble here.
Lakshman Prasad
Infact I currently use the pip trunk, that comes with uninstall as well, that you wrote.
Lakshman Prasad
Great. Yep, I figured you had this under control, but wanted to make sure this answer was available to anyone else coming across the question.
Carl Meyer