473,505 Members | 14,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to properly package/distribute a pure python module?

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)
Jul 18 '05 #1
3 2049
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/

Jul 18 '05 #2
Ma******@HeyAnita.com (Matt Shomphe) wrote in message news:<5a**************************@posting.google. com>...
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
Jul 18 '05 #3
Ma******@HeyAnita.com (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
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3452
by: Noah | last post by:
I would like to package my main script and all the modules it imports into a single script that will run just as the collection would. It should not need to package standard Python lib modules --...
2
3201
by: 63q2o4i02 | last post by:
Hi, I'm using python 2.4 and windows XP. I have two packages in the windows version of python in site-packages. They are PyVisa and ctypes, and both live in c:\python24\lib\site-packages ...
2
1995
by: Jean-Paul Calderone | last post by:
On Mon, 16 Jun 2008 08:39:52 +1000, Ben Finney <bignose+hates-spam@benfinney.id.auwrote: Maybe. I'm no expert on Debian packaging. However, exarkun@boson:~$ ls -l...
7
2173
by: alito | last post by:
Hi all, I am new to using packages to group my modules. I can't figure out how to run a module that uses relative imports without writing a wrapper that imports that module. Everything I try...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.