how to create a pip package

Discussion in 'Python' started by Phlip, Nov 10, 2009.

  1. Phlip

    Phlip Guest

    Py hont:

    I have a single file that I need my crew to pip install.

    When I Google for "how to create a pip package" I don't hit anything.
    Of course that info is out there; I can't seem to pick up the trail of
    breadcrumbs to it.

    While I'm looking, could someone push the link in here? Purely for
    posterity? Thanks!

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand
     
    Phlip, Nov 10, 2009
    #1
    1. Advertising

  2. En Tue, 10 Nov 2009 00:48:26 -0300, Phlip <> escribió:

    > I have a single file that I need my crew to pip install.
    >
    > When I Google for "how to create a pip package" I don't hit anything.
    > Of course that info is out there; I can't seem to pick up the trail of
    > breadcrumbs to it.


    See http://pip.openplans.org/
    You're looking for the "freeze" command.

    --
    Gabriel Genellina
     
    Gabriel Genellina, Nov 10, 2009
    #2
    1. Advertising

  3. On Mon, 9 Nov 2009 19:48:26 -0800 (PST), Phlip <>
    declaimed the following in gmane.comp.python.general:
    > I have a single file that I need my crew to pip install.
    >

    And what is "pip"?

    My vague memory has it as either the CP/M or DEC PDP-11 command
    equivalent to Xerox CP/V PCL (Peripheral Conversion Language -- the
    program used for generic copy, rename, and print of files)

    > When I Google for "how to create a pip package" I don't hit anything.


    Okay, I find http://pypi.python.org/pypi/pip on googling for "pip
    package"... Based upon that, I'd conclude you are asking the wrong
    question -- PIP being a limited substitute for an "easy-install"
    package, so you need to create a package that easy-install can work
    with, but which doesn't use any of the features PIP doesn't support
    (so... no "egg" format, for example).
    --
    Wulfraed Dennis Lee Bieber KD6MOG
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Nov 10, 2009
    #3
  4. On Mon, Nov 09, 2009 at 19:48 -0800, Phlip wrote:
    > I have a single file that I need my crew to pip install.


    Where do you plan to host this file? Will it be available on PiPy?

    > When I Google for "how to create a pip package" I don't hit anything.
    > Of course that info is out there; I can't seem to pick up the trail of
    > breadcrumbs to it.


    As has already been noted in this thread you do not create a file
    specifically for pip, but rather use the standard (or soon to be) way of
    distributing Python distributions outlined in:

    http://docs.python.org/library/distutils.html#module-distutils
    http://packages.python.org/distribute/

    If you do not plan to host your "file" on pypi you can easily create a
    pip requirements file that references a VCS of your choice. Read how to
    do this in the pip documentation on "editable" packages:

    http://pypi.python.org/pypi/pip/

    kind regards

    Wolodja

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.10 (GNU/Linux)

    iQIcBAEBCAAGBQJK+TheAAoJEIt/fTDK8U78tD4QAJyvwxMZww8cQaqwzCEQ3J/i
    kkcKmmDkmOiUVyllJrWlzFRNaVB4BTLqn47fsQKB9r/myVejB9nsUdMRUXgaktiT
    m2mKi+crlBUtcJkh6aNOFew79JsKrm2D2F99VJ6H63ScNQZ2dmb9ap63auBm1x4Q
    TrfEhYjVy2qZE/lWdgeleOi8PQqDazxvlVBl4L7cXoHdHhI+F8L9/i4jlpxPyX+C
    UBMgVc0/x4TA41rUmiF2o7UUIBra+x3OLkJiGE+xaH9T3aJ6QtZvyDgJFrPaJYnS
    5LRsTw9V8HceFyS7ny98l5fy8EthBlUy9a1l1USUTCBpXOWI1L3iwQMVWjbZOy+2
    d3KagRapHb/abmuCR5a7ui7atDXLCIKNP3vWP1LFr5zMLQghiCPbgL82LNGxHt0Q
    S9rCK2THbuUD7YYyUe172p389jUFS2lgy0+ZRgVcuxQ3JRMKTdE4WmP63lBs6KFU
    gKYtn8twBvwmtq1KLLyXXlc+CHPzEV2NgvVdRRXhCylavw2LeEJVNJN1V4AEw0Qw
    NmfbXWroeXHXoWupqPoLc0Ff9MxITISkdjReZhVTOkato92/eP+MktLDQ2bQVLBK
    VxwKreXicBisqgRzMYB20x4Vg+kyipSNCSkckrXTDpmiLJkUd2/JhYg/HafjSW94
    dWYbQBTnQCQ99oHtgHGC
    =4tM+
    -----END PGP SIGNATURE-----
     
    Wolodja Wentland, Nov 10, 2009
    #4
  5. Phlip

    Phlip Guest

    On Nov 10, 1:54 am, Wolodja Wentland <-heidelberg.de>
    wrote:

    > http://docs.python.org/library/distutils.html#module-distutils
    > http://packages.python.org/distribute/


    ktx... now some utterly retarded questions to prevent false starts.

    the distutils page starts with "from distutils.core import setup".

    but a sample project on github, presumably a pippable project, starts
    with:

    from setuptools import setup, find_packages

    (and it also has ez_setup())

    I don't foresee my project growing larger than one* file any time
    soon. 'pip freeze' prob'ly won't write a setup.py. What is the
    absolute simplest setup.py to stick my project on the PYTHONPATH, and
    be done with it?

    [*but rest assured it has a developer test suite and a customer test
    script!]

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand
     
    Phlip, Nov 10, 2009
    #5
  6. On Tue, Nov 10, 2009 at 06:30 -0800, Phlip wrote:
    > On Nov 10, 1:54 am, Wolodja Wentland <-heidelberg.de>
    > wrote:
    >
    > > http://docs.python.org/library/distutils.html#module-distutils
    > > http://packages.python.org/distribute/

    >
    > ktx... now some utterly retarded questions to prevent false starts.


    > the distutils page starts with "from distutils.core import setup".


    [..]

    > from setuptools import setup, find_packages


    It will be enough to use the method outlined in the distutils
    documentation. Setuptools is a third-party library that used to be the
    de-facto standard for Python packaging. I don't want to go into detail
    why setuptools might not be the best choice for a project and leave that
    to [1] and [2].

    The Distribute project was started in order to fix several bugs in
    setuptools which was essentially unmaintained for a year and provides a
    backward compatible fork in the 0.6 branch.

    kind regards

    Wolodja

    [1] http://www.b-list.org/weblog/2008/dec/14/packaging/
    [2] http://blog.ianbicking.org/2008/12/14/a-few-corrections-to-on-packaging/

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.10 (GNU/Linux)

    iQIcBAEBCAAGBQJK+YNKAAoJEIt/fTDK8U78l/AP/1vS9VkxGq512Q/8U9xLE9Fq
    1vTyCCuHJqZ+GpVaf+GKr+0QmtG7/WN/EFA6jKSBFaGJfunYcUbfDNcqcRUGEQYd
    vGY15QzcyZKJ9RviwmBiQEu2HuaEz6DR0XgPbc7P1bdfsXNXV5QAr/SHCkvWPNny
    jteThaW9Tz3WgEJDQfTB4U9+TomvMx7e10G90FwNJ+c7+cow+WXITL8i86L/7Izq
    aLTNZ/S1p0MmIOewxjRzNcDgZ3H5j4PGwYb8dtcduAcVStDkM5xEcBfkZtWJqGkr
    CKzYkJp2848evw0EXA0qpPdzMu28qfqPs8sZomGR2QcTz5c8XehDiTOMujjCHFx6
    QDSeRpwUBVvfM2bCfvEwzzG+r8JEE58oukGEdhVq6FarY31JFVHT0oXOtQxYbNYo
    w9BXf5UDWgu/hbhScHXl997Cwjf4IvCNrh7/2IQ8rsX6SdI0MkmimhLZa0sL/VP8
    N2BTEpmvoogg7Y4WaFt+gy4Z9KexjDxbk3kp8U1ztq8kWKjP1wtQDDvUlNP9Wbm3
    uNJgqwPJrlk2DvXFuW/gAmQkocJ47csajf2sftJJoDqnecsFXnJIAkM7bEQ3eINQ
    dxGdrTyBajwVQVdpZl9UmzU4sV832fEv8hmLMvVFXWfajwRdFCwICSz9d2nAYVp2
    UvK74mibzbuT9S2OjqXu
    =3Nkg
    -----END PGP SIGNATURE-----
     
    Wolodja Wentland, Nov 10, 2009
    #6
  7. On Nov 10, 2:30 pm, Phlip <> wrote:
    > On Nov 10, 1:54 am, Wolodja Wentland <-heidelberg.de>
    > wrote:
    >
    > >http://docs.python.org/library/distutils.html#module-distutils
    > >http://packages.python.org/distribute/

    >
    > ktx... now some utterly retarded questions to prevent false starts.
    >
    > the distutils page starts with "from distutils.core import setup".
    >
    > but a sample project on github, presumably a pippable project, starts
    > with:
    >
    >     from setuptools import setup, find_packages
    >
    > (and it also has ez_setup())
    >
    > I don't foresee my project growing larger than one* file any time
    > soon. 'pip freeze' prob'ly won't write a setup.py. What is the
    > absolute simplest setup.py to stick my project on the PYTHONPATH, and
    > be done with it?


    Do what the distutils page says, setuptools tries to extend distutils
    with many fancy things but if you don't need those (and that's what it
    sounds like) then sticking to distutils is better as you only require
    the python stdlib.

    Regards
    Floris
     
    Floris Bruynooghe, Nov 10, 2009
    #7
  8. Phlip

    Phlip Guest

    > >     from setuptools import setup, find_packages
    >
    > It will be enough to use the method outlined in the distutils
    > documentation. Setuptools is a third-party library that used to be the
    > de-facto standard for Python packaging. I don't want to go into detail
    > why setuptools might not be the best choice for a project...


    Good - thanks, all! Those were the exact details I sought to avoid...
     
    Phlip, Nov 10, 2009
    #8
  9. Phlip

    Phlip Guest

    except...

    will pip pull from a simple GitHub repo? or do I need to package
    something up and put it in a pythonic repository somewhere?
     
    Phlip, Nov 10, 2009
    #9
  10. On Tue, Nov 10, 2009 at 13:09 -0800, Phlip wrote:
    > will pip pull from a simple GitHub repo? or do I need to package
    > something up and put it in a pythonic repository somewhere?


    I don't quite understand, but would say: both ;-)

    You can't tell pip to pull from arbitrary git repositories, but only
    from those that contain the packaging code as outlined in the distutils
    documentation.

    These git repositories do *not* have to be hosted on pypi. You should
    however be able to do the following:

    $ git clone git://example.com/repo.git
    $ cd repo
    $ python setup.py install

    The pip requirement file would contain the following line:

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

    I hope this answers your questions :-D

    --
    .''`. Wolodja Wentland <-heidelberg.de>
    : :' :
    `. `'` 4096R/CAF14EFC
    `- 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.10 (GNU/Linux)

    iQIcBAEBCAAGBQJK+fM9AAoJEIt/fTDK8U78/28P/0kiDBnzPjW2QKkbSSuAnS+X
    /inKhndhGg43Ky614Ayv+InkEpLlo9Lc+eu+5MEPmVjAdAQSPuO4Z9+FXUMJNmLn
    uMkWMmh0kux56Q8ZAxh/XdNaQJU+q3pEHqxVRLJxuEg2LNsIl+UCqkzPKEfd3sRZ
    M+8RDNziN7OD0jHUHPEMWcWxMKpE7VERMBi5d3jsWwEj+Ob/Yy36m7xHfngPT+t+
    A3CC+QzCX/o9eam/x8Hu8/1n+Jj3CAsxG7nAQTG3v0scl7yYno7R09p/oxIdpMu+
    wiYBMIEqof8gkl4ddjPs4JcIuBZpkQywIG615Q0zEQjCfgDP4WE6eIQsStMpBM82
    95aOvFm/xeBKl6GaF2JPwmXgphPwG5bbTO13LCj4agfHdcViiX8A6KnxxvDkh4gP
    LNhbbUJx96Gj8VBKbtAWJg1lQpJljmmoxOLrLxfCWtTJy3ntvwKyFm2zKtcs1VRi
    XdDD0wR9zCFDqIfDLnGX056x4kOnLjoCq03zXyIshViA2tBZVCDk6V48dABh+Err
    utDD5saWFHsq2QknaWmWwjixG0gU9vrsau5tp+WtfIVwZBwuZd4vqdbrqx0vEmgE
    6uZrGT8sE8rYAF7sbjYh6bXC1jqg98JCpgM3Amm1rhpVgCIrwPc/xT3myFu8RQ2J
    y2FNrPAVYKg47qJIZQOW
    =cmuU
    -----END PGP SIGNATURE-----
     
    Wolodja Wentland, Nov 10, 2009
    #10
  11. Phlip

    Phlip Guest

    On Nov 10, 3:11 pm, Wolodja Wentland <-heidelberg.de>
    wrote:

    > The pip requirement file would contain the following line:
    >
    > -e git+git://example.com/repo.git#egg=rep


    I thought pip didn't do eggs. did I read a stale blog?

    > I hope this answers your questions :-D


    oooo we are so close! Pages like this...

    http://blog.ianbicking.org/2008/12/16/using-pip-requirements/

    ....are answering the question "what if I have ten billion
    requirements?"

    I have one, Python. What's the simplest pip requirement file?

    I will post here if I figure it out first.
     
    Phlip, Nov 11, 2009
    #11
  12. Phlip

    Phlip Guest

    On Nov 10, 3:11 pm, Wolodja Wentland <-heidelberg.de>
    wrote:

    > The pip requirement file would contain the following line:
    >
    > -e git+git://example.com/repo.git#egg=rep
    >
    > I hope this answers your questions :-D


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

    sudo pip install repo

    Is github one of the default sites pip scans?

    If so, will it rip a requirements file in the root of repo.git? If so,
    what file name should that have?

    All the pages I'm reading start at the complex end of the requirements
    file concept. They don't seem to mention simple things like the name
    of the file, or how to lead pip to the file.
     
    Phlip, Nov 11, 2009
    #12
  13. Phlip

    Phlip Guest

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

    Okay. -e is an argument to pip install. If anyone said that, I
    overlooked it.

    So, yes I can rip from github, just with a longer command line, for
    now. Tx!
     
    Phlip, Nov 11, 2009
    #13
  14. On Tue, Nov 10, 2009 at 20:25 -0800, Phlip wrote:
    > On Nov 10, 3:11 pm, Wolodja Wentland <-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 <-heidelberg.de>
    : :' :
    `. `'` 4096R/CAF14EFC
    `- 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.10 (GNU/Linux)

    iQIcBAEBCAAGBQJK+oLwAAoJEIt/fTDK8U78ZvEQAJ2HL/MZt63xOBKApHO1nYIz
    dRnYmCo2x6BVTf63HGpz3egKz3xJt4u+Qoisn5E5QUIPcbY+WOvMDyDwbOYI1Oet
    aCnjYfjCxnB/vIeDPZaA9qBtjorRSwoHjc1/byu5pVrjZyLM/2YaHQ45cg4MnT3W
    JtHsyPOH4+gvW2ptEO4jRFbFo4p/iIIsY5AxmuR/7bASGueL7uIK+wrbW3zrO/h2
    JT6851ytdk5N6ZM9iRhfrvzZ01mwhjqEP1ekCRkj2NxQboPoXdT9S7gZ8QGchTq3
    7PIOLHtUkymlwfWiI9kMqWEQNlcfGxbjijH3KH9W/gR3uWouBc5xNVtgZNPsXNPI
    7wzI5r9Yh1ffqDTqPO8EYVHpPXN/kVHUWn7SqBPwR9ZfdEMXiRJeFBGz2VKz2F83
    H+6FmVdz5NQBXD7KsKHezbTfZjmhFIxt1T281LzAtKGsD2XCiR4v6u/DJKr51mvH
    kq9VWeUiaItZxTXrh+IlIWTaMFm1Py8MOiQU+Rmkd9dncxcYWTRz08npueJ7yQCW
    1Z/rZWCV0WvOpRvl0JyCIQwP/71sNJP2MNqHuejB3R1plTAJqxG2O+IJOOQ2fItg
    dLIr1twr3KZV8XfayOMO14Y4xSxQJC9HbM4JzWi5Ex0mAO/tvNFhhVRHjEyE1+Q3
    2cG9RfEPILKBxbV89P7I
    =jkWQ
    -----END PGP SIGNATURE-----
     
    Wolodja Wentland, Nov 11, 2009
    #14
  15. Phlip

    srid Guest

    On Nov 10, 8:25 pm, Phlip <> wrote:
    > On Nov 10, 3:11 pm, Wolodja Wentland <-heidelberg.de>
    > wrote:
    >
    > > The pip requirement file would contain the following line:

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

    >
    > > I hope this answers your questions :-D

    >
    > Let me ask it like this. What happens when a user types..?
    >
    >    sudo pip install repo


    Hey Phlip,

    If you run "pip install repo", it will try to find a package in
    http://pypi.python.org/ named "repo".

    Run the following commands:

    $ pip install pastescript
    $ paster create myapp
    $ cd myapp/
    $ python setup.py sdist register upload

    That's all you need to do .. to have your "myapp" project uploaded to
    PyPI. From now onwards, anyone connected to the internet will be able
    to run "pip install myapp" to get your package.

    For more details, may I suggest you to read the official distutils
    tutorial: http://wiki.python.org/moin/Distutils/Tutorial

    -srid

    PS: Another advantage of using distutils (or setuptools/distribute)
    and uploading your package to PyPI is that you would automatically
    enable other package managers (such as PyPM - http://pypm.activestate.com/
    ) to support your package.
     
    srid, Nov 11, 2009
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Giuseppe Ottaviano
    Replies:
    0
    Views:
    260
    Giuseppe Ottaviano
    May 15, 2009
  2. Phlip
    Replies:
    2
    Views:
    11,737
    Wolodja Wentland
    Nov 16, 2009
  3. Alec Taylor
    Replies:
    0
    Views:
    251
    Alec Taylor
    Sep 14, 2011
  4. Replies:
    0
    Views:
    458
  5. Roy Smith
    Replies:
    10
    Views:
    135
    Mark Lawrence
    Feb 16, 2014
Loading...

Share This Page