Hi, I'm trying to set up pants for a mono repo. Th...
# general
e
Hi, I'm trying to set up pants for a mono repo. The apps are written python and using the flask framework. I have a directory called
apps
and for now a single app in a subdirectory
sample
in this a
app.py
When executing
./pants run apps/sample/app.py
pants. build as expected but, I'm not able to run flask in debug mode.
Copy code
if __name__ == "__main__":
   app.run(host='localhost', port=7002, debug=True)
Then, I get the following error message:
Copy code
No module named apps.__main__; 'apps' is a package and cannot be directly executed
It runs without errors when:
Copy code
if __name__ == "__main__":
   app.run(host='localhost', port=7002)
I've tried googling for this issue, but with no luck. Hence now reaching out. It would be nice not having to
ctr-c
and re-run whenever changes are made to the app when developing. Hope to hear from you! BR Alex
h
Hello Alex, welcome! Good find and pardon if this was difficult to figure out what the issues was. Indeed, it's an issue with Flask's file watcher not playing nicely with Pex for some reason. I opened https://github.com/pantsbuild/pex/issues/1172 just now to track this FYI you may be able to use
debug=True, use_reloader=False
to still get debug benefits, but you unfortunately wouldn't get the rewatcher Would you have an interest in trying out #1172? We're happy to help, it'd be the quickest way to get the fix in sooner Also let us know if we can help with anything else with Pants or if you have feedback!
w
related: https://github.com/pantsbuild/pants/issues/9462 … we’re planning to work on this general problem soon.
e
@echoing-nightfall-72095 I've updated the issue Eric filed above - but this is a generic problem with Flask and zipapps - Pex happens to create a zipapp; so Pex doesn't work with Flask. I'll do a bit more work on that issue to help show a workaround that Pex gives you over and above what a zipapp can do. Pants should probably just be creating Pexes with that workaround or an option to do so on pex_binary targets.
πŸ‘ 2
Looks like the original workaround (using
--unzip
) was not in fact a workaround, but using
--venv
is a workaround. That's on master and ships in the upcomping Pex 2.1.25 release. So Pants will have support soon.
πŸ‘ 2
e
Awesome @enough-analyst-54434, then we will go with pants as build tool. It is a very nice tool, but the developer experience will be poor without hot-reloading. Yes @hundreds-father-404 I would like to try out #1172 πŸ˜„
I just read the issue and will wait for next release instead πŸ™‚
Is there a planned release date?
e
The Pex 2.1.25 release should happen early next week. The next Pants release to use it will likely be the weekly Friday dev release on 1/22.