python - Package import creates a module, submodules still importable -


i've been working on python package , turn small rpm distribution. package includes few modules, 1 of executable. can create rpm-package python setup.py bdist_rpm , install on fedora box rpm.

at point have desired command myscript , works charm. when try import package in ipython, run strange. can following

from myscript import sdf import myscript.mol2 

both work flawlessly, but

import myscript myscript.sdf 

throws

attributeerror: 'module' object has no attribute 'sdf' 

i've been working while no avail. there's plenty of questions of import problems, haven't found answer 1 yet.

what should change make work?

the current folder structure is:

myscript/  #project root   setup.py   src/     myscript/       __init__.py       functions.py       sdf.py       mol2.py       runner.py   bin/     myscript  #symbolic link src/myscript/runner.py 

setup.py is:

from distutils.core import setup setup(name = 'myscript',       version = '0.75',       author ='me',       requires = ['numpy'],        packages = ['myscript'],       package_dir = {'myscript':'src/myscript'},       scripts = ['bin/myscript']       ) 

and __init__.py is:

__all__ = ['functions','sdf','mol2','runner'] 

this normal behavior. if want submodules imported must import them in module.

# myscript/__init__.py  . import sdf 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -