I have the feeling I am missing some point here, and googling didn't get me far.
I am using setuptools
for a command line script. All goes fine but after installation my own files are not "seen" by the automatically generated script of the entry-point. Imagine the following case:
file a.py
contains:
a = 12
file __main__.py
contains:
from a import a
def main():
print(a)
if __name__ == '__main__':
main()
file __init__.py
is empty. File setup.py
contains:
from setuptools import setup, find_packages
setup(
name='tep',
packages=find_packages(),
version='0.0.1',
entry_points={
'console_scripts': [
'tep = tep.__main__:main'
]
},
)
all are properly located in the directory structure:
Locally all works well. But after installation:
sudo -H python setup.py install
and invoking from a different shell either by using tep
or by using python -m tep
, I get the following error:
ImportError: No module named 'a'
So the file a.py
is not visible in the scope after installation . Any ideas?
thanks.
That happens because you haven't specified an absolute path of the a
module. Remember, a
is in package tep
. So you need to import like this in __main__.py
:
from tep.a import a