How do you organize Python modules? [closed]
My advice:
- Read Installing Python Modules.
- Read Distributing Python Modules.
- Start using easy_install from setuptools. Read the documentation for setuptools.
- Always use virtualenv. My site-packages directory contains setuptools and virtualenv only.
- Check out Ian Bicking's new project pyinstall.
- Follow everything Ian Bicking is working on. It is always goodness.
- When creating your own packages, use distutils/setuptools. Consider using
paster create
(see http://pythonpaste.org) to create your initial directory layout.
In addition to PEP8 and easy_install, you should check out virtualenv. Virtualenv allows you to have multiple different python library trees. At work, we use virtualenv with a bootstrapping environment to quickly set up a development/production environment where we are all in sync w.r.t library versions etc. We generally coordinate library upgrades.
There are several families of Python componentry.
The stuff that comes with Python. This takes care of itself.
The stuff that you got with easy_install. This, also, takes care of itself.
The packages that you had to get some other way, either as TARballs or SVN checkouts. Create a
Components
folder. Put the downloads or the SVN's in there first. Every Single Time. Do installs from there.The packages that you wrote that are reusable. I have a
Projects
folder with each project in that folder. If the project is a highly reusable thing, it has asetup.py
and I actually run the install as if I downloaded it. I don't have many of these, but a few. Some of them might become open source projects.The final applications you write. I have a folder in
Projects
with each of these top-level applications. These are usually big, rambling things (like Django sites) and don't havesetup.py
. Why? They're often pretty complex with only a few server installations to manage, and each of those server installations is unique. These generally rely onPYTHONPATH
to identify their parts.
Notice the common theme. Either they're Components you downloaded or they're Projects you're working on.
Also, I keep this separate (to an extent) from the client. I have a master directory of Client folders, each of which has Projects and each project has Sales and Delivery. Not all projects have both sales and delivery.
Maybe PEP8 and easy_install can help you?