473,543 Members | 1,892 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 "MyFunction s" with an "__init__.p y" 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.fun ctions import f1)
[3] site-packages/MyFunctions/__init__.py, f1.py, f2.py, f3.py (from
MyFunctions.f1 import f1)
Jul 18 '05 #1
3 2054
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 "MyFunction s" with an "__init__.p y" 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.fun ctions 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******@HeyAni ta.com (Matt Shomphe) wrote in message news:<5a******* *************** ****@posting.go ogle.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 "MyFunction s" with an "__init__.p y" 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.fun ctions 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******@HeyAni ta.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
3465
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 -- just my local modules. This is not the same question that would be answered with py2exe or py2app. I don't need to package the script into a binary...
2
3203
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 I'd like to move these to the cygwin version of python on the same system. I tried copying the PyVisa and ctypes directorices (including
2
2006
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 /usr/lib/python2.{4,5}/site-packages/sqlite/main.py lrwxrwxrwx 1 root root 63 2007-12-27 15:29 /usr/lib/python2.4/site-packages/sqlite/main.py...
7
2176
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 it complains that I am attempting a relative import in a non-package. eg ~/python/testpackage$ ls config.py importer.py __init__.py
0
7411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7354
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5888
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5282
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3394
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1824
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.