bottle
bottle copied to clipboard
Bottle fails to start with reloader=True when using absolute import
I'm using bottle v0.12.7 and I have the following project structure:
test
├── api
│ ├── hello.py
│ └── __init__.py
├── config
│ ├── config.py
│ └── __init__.py
└── __init__.py
The hello.py file is:
import sys
import bottle
from test.config import config
@bottle.post('/hello')
def hello():
return config.MESSAGE
def main(argv):
app = bottle.Bottle()
reloader = '--reloader' in argv
print('Starting with reloader={}'.format(reloader))
app.run(host='0.0.0.0', port=8080, debug=True, reloader=reloader)
if __name__ == '__main__':
main(sys.argv)
and the config.py is simply
MESSAGE = 'Hello!'
When I run api.py with reloader=False (python -m test.api.hello) the api starts correctly. If I run it with reloader=True (python -m test.api.hello --reloader) it fails with:
Starting with reloader=True
Traceback (most recent call last):
File "/home/kostas/Code/Python/test/test/api/hello.py", line 3, in <module>
from test.config import config
ImportError: No module named config