python install package as sub-package of another package -
i developing program ("homie") in python 2.7 eclipse / pydev contains several interfaces external api providers. inherit genric interface-class located inside __init__.py
inside homie.interfaces
all interfaces should contained in sub-packages of homie.interfaces
, such homie.interfaces.foo
, homie.interfaces.bar
. following divide-and-conquer concept created new projects each interface implementation, containing respective packages, such foo
, respectively bar
.
the problem now, setup.py
script of course not find package myprogram.interfaces.foo
during setup. example: worknet
interface
#! /usr/bin/env python distutils.core import setup setup( name='worknet-dbs interface', version='0.1-indev', author='richard neumann', author_email='mail@richard-neumann.de', packages=['homie.interfaces.worknet'], data_files=[], license=open('license.txt').read(), description='interface implementation worknet apis', long_description=open('readme.txt').read(), )
will produce:
[neumannr@neumann-homeinfo worknet.tmp]$ python ./setup.py install running install running build running build_py error: package directory 'homie/interfaces/worknet' not exist [neumannr@neumann-homeinfo worknet.tmp]$
if specify worknet
instead of homie.interfaces.worknet
of course install userbase instad of homie.interfaces
. how can tell script install worknet
package homie.interfaces
, path homie.interfaces.worknet
?
point package directory package_dir
package_dir
parameter can provide information find packages.
pointing existing worknet
directory
assuming, worknet
directory directly in project root, shall dd parameter package_dir
setup
call
package_dir = {'homie.interfaces': ''}
moving package subdirectory homie/interfaces
another option is, reorganize code directories. e.g .you creat path homie/interfaces/
, move existing worknet
subdirectory.
in such case, add
package_dir = {'homie.interfaces': 'homie/interfaces'}
Comments
Post a Comment