Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make python setuptools find top level modules

I have a package with a structure that would (simplified) look like:

mypackage/
    __init__.py
    setup.py
    module1.py
    module2.py
    mysubpackage/
        __init__.py
        mysubmodule1.py
        mysubmodule2.py

I'm using a configuration for setup.py like this:

from setuptools import setup, find_packages

setup(
    name = "mypackage",
    version = "0.1",
    author = "Foo",
    author_email = "[email protected]",
    description = ("My description"),
    packages=find_packages(),
)

The default where argument for find_packages() is '.', but it doesn't include my top-level modules (module1.py nor module2.py). However, all child submodules and subpackages are added when running python setup.py build.

How could I get top-level Python modules added too, without moving setup.py one level higher?

like image 763
Caumons Avatar asked Feb 17 '15 23:02

Caumons


1 Answers

Thank you all for your responses.

Finally, I added a directory (not Python package) containing mypackage and the setup.py module. The structure now looks as follows:

myapp/
    setup.py
    mypackage/
        __init__.py
        module1.py
        module2.py
        mysubpackage/
            __init__.py
            mysubmodule1.py
            mysubmodule2.py

Now using find_packages() works as expected. Thanks!

like image 90
Caumons Avatar answered Sep 28 '22 17:09

Caumons