[Distutils] walking for sub-packages

David Abrahams dave at boost-consulting.com
Sat Sep 27 11:58:58 EDT 2003


I just added the following to a setup.py:

    #
    # Find all the sub-packages of Synopsis
    #
    def add_package(found_packages, directory, local_names):
        if '__init__.py' in local_names:
            found_packages.append(
                re.sub('.*Synopsis', 'Synopsis', directory)
                .replace(os.path.sep, '.')
                )
        else:
            local_names = []


    py_packages = []
    os.path.walk('Synopsis', add_package, py_packages)

    # sanity check
    assert 'Synopsis.Core' in py_packages

Then naturally, I call setup with packages=py_packages.  Is something
like that capability built into distutils?  If not, shouldn't it be?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Distutils-SIG mailing list