Organizing a Python project

Jorge Godoy jgodoy at gmail.com
Mon May 19 07:14:16 EDT 2008


A.T.Hofkamp wrote:

> Also, why do you make a distinction between shared and non-shared code?
> You could simply eliminate 'shared' directory, and put its contents
> directly under myproject.

I would go further and make them individual projects, with their own version
control, code repository and then install them as eggs using setuptools.

This has been working fine for me in some projects and has the advantage of
being reusable in different big projects.

Also, using setuptools on each big project I don't have to worry with
dependencies because it downloads and installs everything to me when I
install the main project.

>> Is there a way to set this up that is a bit more self contained? For
>> example, at first I was somewhat hopeful that Python could ascend
>> parent directories until it reached a directory that did not include
>> an __init__.py file, and it could use this as a root for referring to
>> packages and modules from any file contained within. (e.g. in the
>> example project above, any file could refer to myproject.shared.mylib1
>> so long as 'myproject' and all subdirectories contained an
>> __init__.py, and the parent of 'myproject' didn't contain such a
>> file). Evidently this is not the case, but it seems like it could be a
>> useful feature in these situations.

Eggs would solve that as well.  They would behave like any other
installed "library" on your system.

-- 
Jorge Godoy      <jgodoy at gmail.com>




More information about the Python-list mailing list