Bogdan
Bogdan

Reputation: 8246

python setup.py question

So I have a folder structure something like this:

pckA - core
     - io
pckB - core
     - io
     - main

Now I have to create a setup.py file for both there packages. My current approach is :

from distutils.core import setup
import setuptools

setup(
    name='ProjectExternals',
    version='0.1dev',
    packages=["pckA","pckA.core","pckA.io","pckB","pckB.core","pckB.io","pckB.main"],
    license='Not decided yet',
    author='',
    author_email='',
    long_description="",
    install_requires=["numpy","quantities"]
)

This setup.py is located in the same folder as pckA and pckB .So my question is : is it necessary to add all the subpackages like pckA.core etc or does setuptools know to install these as well?

Upvotes: 0

Views: 315

Answers (1)

Eli Bendersky
Eli Bendersky

Reputation: 273456

No, if you just want the whole package, specifying its name (i.e. pckA) is enough - no need to list all the modules in it. distutils will recursively discover them.

So in your case:

packages=['pckA', 'pckB'],

Does the trick. Here's a quote from the docs:

The packages option tells the Distutils to process (build, distribute, install, etc.) all pure Python modules found in each package mentioned in the packages list. In order to do this, of course, there has to be a correspondence between package names and directories in the filesystem.


If you don't want whole packages but would rather include only specific modules, use the py_modules option instead.

Upvotes: 3

Related Questions