Python package install using pip or easy_install from repos

Question!

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.



Answers

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



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.



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


This video can help you solving your question :)
By: admin