python - Accessing package root directory from sub-package -


i'm looking best way access root directory of sub-package in order retrieve common configuration files (which in case json files).

as example, directory structure may follows:

| readme | setup.py | proj_name    | __init__.py    | pack_01       | __init__.py       | file_01.py       | file_02.py    | pack_02       | __init__.py       | file_03.py       | file_04.py    | conf       | conf_01.json       | conf_02.json       | conf_03.json 

in example, package config files in proj_name/conf directory.

when importing file_01 using command such import proj_name.pack_01.file_01, attribute __file__ point proj_name/pack_01/file_01.py , line such root_dir=dirname(dirname(__file__)) required; implies knowledge of directory structure when writing sub-package.

is there way access root package (proj_name in case) , directory using variable such __root_package__ or similar? tidiest way achieve in python? , method still work when building egg using setup.py utility?

thank in advance!


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -