This page discusses a small project called ekrProject created so I can explore issues relating to python packages. This project has clarified many confusing issues for me.

The ekrProject has the following organization:

ekrProject/ # top-level folder.  not a package.
    ekrProject/ # The ekrProject package.
        core # The ekrProject/core package.
   # a module
   # a module
        plugins # The ekrProject/plugins package.
    dist/ # Created by sdist.

Here is the contents of ekrProject/

from distutils.core import setup
long_description = '''Project to test distribution issues for Leo.'''
version='0.0.1' # No spaces and no trailing comma.
setup (
    author='Edward K. Ream',
    # py_modules=['ekrProj','core','plugins'],
    packages = ['ekrProj','ekrProj.core','ekrProj.plugins'],
    description = 'ekrProj',
    long_description = long_description,

With the above organization, I can create a distribution in a completely standard way, and users can also install the distributed file in a standard way. The result is a leo package in Python's site-packages folders.

In detail, the steps are as follows.

  1. The distributor (me) runs:

    python sdist

This creates in the ekrProject/dist folder.

  1. Typically the user will download and unpack to <some folder>.

  2. Now the user runs this script from <some folder>ekrProj-0.0.1:

    python install

The point of this page is that this will create a leo package in the python/Lib/site-packages folder as we want.

Yes, all this seems pretty simple, but getting to this point took me a lot of thought.

Important: presently specifies files simply by listing the packages to be included. This probably won't work for the real Leo distribution: a proper file will probably have to be generated as is done at present.