简体   繁体   中英

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?

No, if you just want the whole package, specifying its name (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM