Search code examples
pythonsetuptools

Is it possible to give multiple source dir to find_packages() using setuptools?


I have a python project which want to be distributed by using setuptools.

I want to use find_packages() function. The python source packages located in multiple directory:

proj
  +--src1
  |    +--pkg1
  |    |    +-- (__init__.py and sources)
  |    +--pkg2
  |    |    +-- (__init__.py and sources)
  +--src2
       +--pkg3
       |    +-- (__init__.py and sources)
       +--pkg4
            +-- (__init__.py and sources)

If I use find_packages('proj/src1') the pkg3 and pkg4 wont be packed into the distribution.

If I use find_packages('proj') the no packages will be listed at all.

Is it possible to use multiple source directories and find_packages() together?


Solution

  • find_packages() returns a list. You can call it a few times and combine the lists:

    find_packages('proj/src1') + find_packages('proj/src2')