So I got single 3rd party dependencies working in ...
# general
w
So I got single 3rd party dependencies working in our monorepo which I’m pretty excited about. However, the development experience seems problematic. Setting PYTHONPATH and using an exported venv isn’t sufficient in some cases. For example, flask requires a package install (it can be editable) in order to run a debug server. However,
python_distribution
doesn’t really help here because installed packages are not editable. This requires having a duplicate
setup.py
or
pyproject.toml
in the monorepo modules, as well as several steps to install dependent modules in editable mode. Additionally the exported venv doesn’t have pip, so that has to be added before doing any of the above Any other approaches I’m missing?
h
I'm no Flask expert, but Django has a similar debug server, and you can use Pants's own file watching to restart it (instead of relying on the debug server's less accurate file watching) with:
pants --loop run helloworld/service/frontend/manage.py -- runserver --noreload
So maybe something similar works with Flask?
Note that this requires Pants 2.16.0a0
And also, you must set
restartable=True
on
helloworld/service/frontend/manage.py
(via
overrides={'manage.py': {'restartable': True}}
on its
python_sources
for example)
The
--noreload
tells Django not to use its own filewatching. The example Django repo has an example of how we set this automatically
So maybe there is an effective Flask equivalent of all of this
It would be great to have an
example-flask
repo to go along with
example-django
!
w
thanks! I’ll take a look
h
I will send a PR to update that repo to 2.16.0rc0 so that I can demonstrate this properly
I think you don't need
--loop
actually
Since the server never exits unless restarted