How to properly package/distribute a pure python module?

Discussion in 'Python' started by Matt Shomphe, Jul 28, 2003.

  1. Matt Shomphe

    Matt Shomphe Guest

    Are there any guidelines for packaging a pure python module?
    Specifically, say I have a set of 10 functions, all of varying
    behaviors (no unifying theme to bind them together into clear
    subsets), that I would like to make available to others. What is the
    best structure for the distributed module? A single file called
    "functions.py" that people can put in "site-packages"[1]? A
    subdirectory called "MyFunctions" with an "__init__.py" and the
    "functions.py" files[2]? Or should the functions be broken out into
    individual files[3]?

    I'm sure it depends on some other factorsbut are there general rules
    for constructing a nice, logical package for others to use?

    [1] site-packages/functions.py (from functions import f1)
    [2] site-packages/MyFunctions/functions.py, __init__.py (from
    MyFunctions.functions import f1)
    [3] site-packages/MyFunctions/__init__.py, f1.py, f2.py, f3.py (from
    MyFunctions.f1 import f1)
     
    Matt Shomphe, Jul 28, 2003
    #1
    1. Advertising

  2. Matt Shomphe

    Andy Todd Guest

    Matt Shomphe wrote:
    > Are there any guidelines for packaging a pure python module?
    > Specifically, say I have a set of 10 functions, all of varying
    > behaviors (no unifying theme to bind them together into clear
    > subsets), that I would like to make available to others. What is the
    > best structure for the distributed module? A single file called
    > "functions.py" that people can put in "site-packages"[1]? A
    > subdirectory called "MyFunctions" with an "__init__.py" and the
    > "functions.py" files[2]? Or should the functions be broken out into
    > individual files[3]?
    >
    > I'm sure it depends on some other factorsbut are there general rules
    > for constructing a nice, logical package for others to use?
    >
    > [1] site-packages/functions.py (from functions import f1)
    > [2] site-packages/MyFunctions/functions.py, __init__.py (from
    > MyFunctions.functions import f1)
    > [3] site-packages/MyFunctions/__init__.py, f1.py, f2.py, f3.py (from
    > MyFunctions.f1 import f1)


    I'd suggest you look at the distribution utilities for Python;

    http://www.python.org/sigs/distutils-sig/doc/

    Specifically the documentation on distrbuting Python modules;

    http://www.python.org/doc/current/dist/

    The documentation can be a little confusing at first but stick with it
    and if you have any questions please ask them here or on the
    distutils-sig mailing list.

    Regards,
    Andy
    --
    --------------------------------------------------------------------------------
    From the desk of Andrew J Todd esq - http://www.halfcooked.com/
     
    Andy Todd, Jul 29, 2003
    #2
    1. Advertising

  3. (Matt Shomphe) wrote in message news:<>...
    > Are there any guidelines for packaging a pure python module?
    > Specifically, say I have a set of 10 functions, all of varying
    > behaviors (no unifying theme to bind them together into clear
    > subsets), that I would like to make available to others. What is the
    > best structure for the distributed module? A single file called
    > "functions.py" that people can put in "site-packages"[1]? A
    > subdirectory called "MyFunctions" with an "__init__.py" and the
    > "functions.py" files[2]? Or should the functions be broken out into
    > individual files[3]?
    >
    > I'm sure it depends on some other factorsbut are there general rules
    > for constructing a nice, logical package for others to use?
    >
    > [1] site-packages/functions.py (from functions import f1)
    > [2] site-packages/MyFunctions/functions.py, __init__.py (from
    > MyFunctions.functions import f1)
    > [3] site-packages/MyFunctions/__init__.py, f1.py, f2.py, f3.py (from
    > MyFunctions.f1 import f1)



    Do a google search for the distutils module. For examples, look at
    any python project (ZSI or SOAPpy for example), and take a look at the
    setup.py.

    The gist of it is that you define a setup.py module that defines which
    modules are to be included in the distro. A user, when they download
    your tarball, goes into your directory and (as root): "python setup.py
    install".

    Once you have your app in distutils compatible format, you can use
    distutils to generate .exe installs, rpm installs, tarball downloads,
    etc etc etc.

    So definitely take a look at distutils. :)


    -c
     
    Christopher Blunck, Jul 29, 2003
    #3
  4. Matt Shomphe

    John J. Lee Guest

    (Matt Shomphe) writes:

    > Are there any guidelines for packaging a pure python module?
    > Specifically, say I have a set of 10 functions, all of varying
    > behaviors (no unifying theme to bind them together into clear
    > subsets), that I would like to make available to others. What is the
    > best structure for the distributed module? A single file called
    > "functions.py" that people can put in "site-packages"[1]? A


    If it's "the simplest thing that could possibly work" (TM), I'd say
    yes, do that.


    John
     
    John J. Lee, Jul 29, 2003
    #4
    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. Todd Aspeotis
    Replies:
    3
    Views:
    469
    Kanenas
    May 30, 2005
  2. Replies:
    4
    Views:
    798
    Ben C
    Mar 29, 2008
  3. Allen
    Replies:
    1
    Views:
    467
    David Cournapeau
    Dec 5, 2008
  4. David Moss
    Replies:
    2
    Views:
    222
    David Moss
    Feb 2, 2009
  5. Vince Forgetta
    Replies:
    0
    Views:
    195
    Vince Forgetta
    Feb 2, 2012
Loading...

Share This Page