Closed mrquincle closed 2 years ago
This commit does actually do a nice job in complaining to the user that they are not using a venv
when running make, however, it is itself not using it!
When e.g. bluenet_logs
is installed through ExternalProject_Add
it starts a separate shell to do the pip installation. Also, when we would move this to a cmake
script and call it through a -P
flag, it can access e.g. the environmental variables in the existing shell, but needs to use execute_process
to call pip
and will then again use a (sub)shell.
The last remark might be true, but it's possible to use execute_process
in a separate cmake
file. Just make sure that python3
is used and not an absolute path to the binary!
python3 -m pip install bluenet-logs
will work, but for example
/usr/bin/python3.8 -m pip install bluenet-logs
will use global python installation.
Would be fixed by https://github.com/crownstone/bluenet/pull/141
The recommended way to install python tools is described at https://github.com/crownstone/crownstone-lib-python-core/blob/master/docs/TUTORIAL_VENV_SETUP.md.
The parent https://github.com/crownstone/bluenet/blob/master/CMakeLists.txt file removes some of the burden of a first-time developer of the bluenet code.
For example, when
-DDOWNLOAD_NRFUTIL=ON
there's annrfutil
target created through the use ofExternalProject_Add
that uses plainpython3 -m pip install ...
to install this utility.It has now been the responsibility of the user to first create a virtual environment before running
cmake
. After this, commands likepython3 -m pip install ...
are fine.Recommended steps:
cmake
flag that allows a user to set this up on their system (e.g.-DPYTHON_SETUP_VENV=ON
, it isOFF
by default).sudo apt install python3-venv
.cmake
a warning if no virtual environment is used.FindPython3
to findpython3
itself. Same withpip
. That's the proper cross-platform way to do this.Note, all this is only done if developers use
cmake
options like-DDOWNLOAD_NRFUTIL=ON
etc. If developers have their own way to install the (python) tools aroundbluenet
, that's fine as well. There's not even python required if developers only want to cross-compile thebluenet
firmware itself and we shouldn't bother such developers.