how to create a pip package

Wolodja Wentland wentland at cl.uni-heidelberg.de
Wed Nov 11 04:25:05 EST 2009


On Tue, Nov 10, 2009 at 20:25 -0800, Phlip wrote:
> On Nov 10, 3:11 pm, Wolodja Wentland <wentl... at cl.uni-heidelberg.de>
> wrote:
> 
> > The pip requirement file would contain the following line:

> > -e git+git://example.com/repo.git#egg=rep

> Let me ask it like this. What happens when a user types..?

>    sudo pip install repo

pip will check for 'repo' on pypi, find nothing and stop processing.

> Is github one of the default sites pip scans?

No.

> If so, will it rip a requirements file in the root of repo.git? 

No.

>If so, what file name should that have?

You can choose any name you like. I think I have to explain a bit
more.

The requirement file is basically a list of *all installed
distributions* in a Python environment and is usually created by 'pip
freeze'. It is merely a way to tell pip later which distributions it
should try to install.

The basic way of working with requirement files if this:

1. Create virtual environment [1]

2. Install *your* package and all of its dependencies within the virtual
   environment

3. Run 'pip freeze' to get the list of installed distributions and write
   it to a file. This file is the requirement file.

4. Give the requirement file to someone else

5. Create a virtual environment

6. Run 'pip install -r requirement_file.txt' to install all
   distributions 'frozen' in the requirements file

7. PROFIT!!!

A requirements file is not really meant to state the dependencies of a
single distribution, but rather describe the complete state an
environment is in *so it can be reconstructed later* exactly like is has
been before. This is quite important if you want to deploy application
and you want to make sure that only tested versions of you dependency
get installed.

I think of it rather in the terms of:

    pip freeze              --> dpkg --get-selections
    pip install -r r.txt    --> dpkg --set-selections
                                aptitude install

AFAIK you can also host the distribution on another site than pypi, but
I am not sure how to tell pip to check there for distributions as well.
You might want to ask this on the virtualenv list.

--
  .''`.     Wolodja Wentland    <wentland at cl.uni-heidelberg.de> 
 : :'  :    
 `. `'`     4096R/CAF14EFC 
   `-       081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 853 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20091111/c1b4d301/attachment.sig>


More information about the Python-list mailing list