0

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?

1
  • 1
    The title of this question is very generic, could you rephrase it to help discoverability? Commented Oct 13, 2012 at 13:40

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Note that submodules in a package are included but not subpackages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.