I have created a setup.py script for a gui application and a runner script myapp.
The runner script contains:
#!/usr/bin/env python3
import myapp
myapp.gui_mode()
The application can be run from command line with python3 myapp.py
Here is how myapp.py looks like:
#!/usr/bin/evn python3
def gui_mode():
run_app()
def main():
print("Starting UI")
gui_mode()
if __name__ == '__main__':
main()
After I install the app with sudo python3 setup.py install and attemp to run it from console with myapp, I receive the following message:
AttributeError: module 'myapp' has no attribute 'gui_mode'
Ok, I start python3 interpreter and check:
import myapp
print(dir(myapp))
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
I wonder, why is myapp getting imported without its own functions?
UPDATE
In [4]: print(myapp.__file__)
/home/tastyminerals/dev/NEFI2/nefi2/__init__.py
Here is the project structure:
APP2/
setup.py
myapp/myapp.py
myapp/bin/run_myapp <-- renamed runner file
myapp/__init__.py
myapp/data
Critical part of setup.py:
packages=['myapp'],
scripts=[
'myapp/bin/run_myapp'
],