We use werkzeug as router component of trytond. Everything worked on previous versions but since 0.15 (concretly after #1416 was merged), running the server from an package script and activating the reloader causes the following error:
Traceback (most recent call last):
File "/home/pokoli/.virtualenvs/kaialde/bin/trytond", line 4, in <module>
File "/home/pokoli/.virtualenvs/kaialde/lib/python3.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
File "/home/pokoli/.virtualenvs/kaialde/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1453, in run_script
exec(code, namespace, namespace)
File "/home/pokoli/.virtualenvs/kaialde/lib/python3.7/site-packages/trytond-5.0.9-py3.7.egg/EGG-INFO/scripts/trytond", line 47, in <module>
File "/home/pokoli/.virtualenvs/kaialde/lib/python3.7/site-packages/werkzeug/serving.py", line 1007, in run_simple
run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File "/home/pokoli/.virtualenvs/kaialde/lib/python3.7/site-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
File "/home/pokoli/.virtualenvs/kaialde/lib/python3.7/site-packages/werkzeug/_reloader.py", line 159, in restart_with_reloader
args = _get_args_for_reloading()
File "/home/pokoli/.virtualenvs/kaialde/lib/python3.7/site-packages/werkzeug/_reloader.py", line 76, in _get_args_for_reloading
if __main__.__package__ is None:
AttributeError: module '__main__' has no attribute '__package__'
The text was updated successfully, but these errors were encountered:
Could you be more specific about what you mean by "a package script"? I'm fine with the fix, but I want to understand under what circumstances __main__ does not have a __package__ attribute. For example, the flask command is an entry point, and it does not seem to have this issue.
This only occurs when you do python setup.py develop, not pip install -e ., because develop uses setuptools to do the install, and that results in eggs being installed. On the other hand, pip always installs packages unzipped.
I think setuptools maintainers are trying to move away from setuptools being the thing that manages the environment, in favor of pip, so you'll probably have a better compatibility experience in general by using pip install -e . going forward. That said, eggs should still be supported for now, so I'll merge the fix.