Skip to content

Commit 33d92b4

Browse files
gmarullcarlescufi
authored andcommitted
doc: getting_started: remove global Python setup
As it was already outlined, installing Python dependencies at a system level or user level can be dangerous. For this reason, the default setup instructions already pointed users to use Python virtual environments. On newer Ubuntu installations (23.04 onwards) system-level pip installs are not allowed. Let's make Zephyr _Python-safe_ as well by removing dangerous instructions. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent f20ac87 commit 33d92b4

File tree

1 file changed

+94
-216
lines changed

1 file changed

+94
-216
lines changed

doc/develop/getting_started/index.rst

+94-216
Original file line numberDiff line numberDiff line change
@@ -207,298 +207,176 @@ Get Zephyr and install Python dependencies
207207

208208
Next, clone Zephyr and its :ref:`modules <modules>` into a new :ref:`west
209209
<west>` workspace named :file:`zephyrproject`. You'll also install Zephyr's
210-
additional Python dependencies.
210+
additional Python dependencies in a `Python virtual environment`_.
211211

212-
213-
.. note::
214-
215-
It is easy to run into Python package incompatibilities when installing
216-
dependencies at a system or user level. This situation can happen,
217-
for example, if working on multiple Zephyr versions or other projects
218-
using Python on the same machine.
219-
220-
For this reason it is suggested to use `Python virtual environments`_.
221-
222-
.. _Python virtual environments: https://docs.python.org/3/library/venv.html
212+
.. _Python virtual environment: https://docs.python.org/3/library/venv.html
223213

224214
.. tabs::
225215

226216
.. group-tab:: Ubuntu
227217

228-
.. tabs::
229-
230-
.. group-tab:: Install within virtual environment
231-
232-
#. Use ``apt`` to install Python ``venv`` package:
233-
234-
.. code-block:: bash
235-
236-
sudo apt install python3-venv
237-
238-
#. Create a new virtual environment:
239-
240-
.. code-block:: bash
241-
242-
python3 -m venv ~/zephyrproject/.venv
243-
244-
#. Activate the virtual environment:
245-
246-
.. code-block:: bash
247-
248-
source ~/zephyrproject/.venv/bin/activate
249-
250-
Once activated your shell will be prefixed with ``(.venv)``. The
251-
virtual environment can be deactivated at any time by running
252-
``deactivate``.
253-
254-
.. note::
255-
256-
Remember to activate the virtual environment every time you
257-
start working.
218+
#. Use ``apt`` to install Python ``venv`` package:
258219

259-
#. Install west:
260-
261-
.. code-block:: bash
262-
263-
pip install west
220+
.. code-block:: bash
264221
265-
#. Get the Zephyr source code:
222+
sudo apt install python3-venv
266223
267-
.. code-block:: bash
224+
#. Create a new virtual environment:
268225

269-
west init ~/zephyrproject
270-
cd ~/zephyrproject
271-
west update
226+
.. code-block:: bash
272227
273-
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
274-
automatically load boilerplate code required for building Zephyr
275-
applications.
228+
python3 -m venv ~/zephyrproject/.venv
276229
277-
.. code-block:: bash
230+
#. Activate the virtual environment:
278231

279-
west zephyr-export
232+
.. code-block:: bash
280233
281-
#. Zephyr's ``scripts/requirements.txt`` file declares additional Python
282-
dependencies. Install them with ``pip``.
234+
source ~/zephyrproject/.venv/bin/activate
283235
284-
.. code-block:: bash
236+
Once activated your shell will be prefixed with ``(.venv)``. The
237+
virtual environment can be deactivated at any time by running
238+
``deactivate``.
285239

286-
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt
240+
.. note::
287241

288-
.. group-tab:: Install globally
242+
Remember to activate the virtual environment every time you
243+
start working.
289244

290-
#. Install west, and make sure :file:`~/.local/bin` is on your
291-
:envvar:`PATH` :ref:`environment variable <env_vars>`:
245+
#. Install west:
292246

293-
.. code-block:: bash
247+
.. code-block:: bash
294248
295-
pip3 install --user -U west
296-
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
297-
source ~/.bashrc
249+
pip install west
298250
299-
#. Get the Zephyr source code:
251+
#. Get the Zephyr source code:
300252

301-
.. code-block:: bash
253+
.. code-block:: bash
302254
303-
west init ~/zephyrproject
304-
cd ~/zephyrproject
305-
west update
255+
west init ~/zephyrproject
256+
cd ~/zephyrproject
257+
west update
306258
307-
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
308-
automatically load boilerplate code required for building Zephyr
309-
applications.
259+
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
260+
automatically load boilerplate code required for building Zephyr
261+
applications.
310262

311-
.. code-block:: bash
263+
.. code-block:: bash
312264
313-
west zephyr-export
265+
west zephyr-export
314266
315-
#. Zephyr's ``scripts/requirements.txt`` file declares additional Python
316-
dependencies. Install them with ``pip3``.
267+
#. Zephyr's ``scripts/requirements.txt`` file declares additional Python
268+
dependencies. Install them with ``pip``.
317269

318-
.. code-block:: bash
270+
.. code-block:: bash
319271
320-
pip3 install --user -r ~/zephyrproject/zephyr/scripts/requirements.txt
272+
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt
321273
322274
.. group-tab:: macOS
323275

324-
.. tabs::
325-
326-
.. group-tab:: Install within virtual environment
327-
328-
#. Create a new virtual environment:
329-
330-
.. code-block:: bash
331-
332-
python3 -m venv ~/zephyrproject/.venv
333-
334-
#. Activate the virtual environment:
335-
336-
.. code-block:: bash
337-
338-
source ~/zephyrproject/.venv/bin/activate
339-
340-
Once activated your shell will be prefixed with ``(.venv)``. The
341-
virtual environment can be deactivated at any time by running
342-
``deactivate``.
343-
344-
.. note::
276+
#. Create a new virtual environment:
345277

346-
Remember to activate the virtual environment every time you
347-
start working.
348-
349-
#. Install west:
350-
351-
.. code-block:: bash
352-
353-
pip install west
354-
355-
#. Get the Zephyr source code:
356-
357-
.. code-block:: bash
358-
359-
west init ~/zephyrproject
360-
cd ~/zephyrproject
361-
west update
278+
.. code-block:: bash
362279
363-
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
364-
automatically load boilerplate code required for building Zephyr
365-
applications.
280+
python3 -m venv ~/zephyrproject/.venv
366281
367-
.. code-block:: bash
282+
#. Activate the virtual environment:
368283

369-
west zephyr-export
284+
.. code-block:: bash
370285
371-
#. Zephyr's ``scripts/requirements.txt`` file declares additional Python
372-
dependencies. Install them with ``pip``.
286+
source ~/zephyrproject/.venv/bin/activate
373287
374-
.. code-block:: bash
288+
Once activated your shell will be prefixed with ``(.venv)``. The
289+
virtual environment can be deactivated at any time by running
290+
``deactivate``.
375291

376-
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt
292+
.. note::
377293

378-
.. group-tab:: Install globally
294+
Remember to activate the virtual environment every time you
295+
start working.
379296

380-
#. Install west:
297+
#. Install west:
381298

382-
.. code-block:: bash
299+
.. code-block:: bash
383300
384-
pip3 install -U west
301+
pip install west
385302
386-
#. Get the Zephyr source code:
303+
#. Get the Zephyr source code:
387304

388-
.. code-block:: bash
305+
.. code-block:: bash
389306
390-
west init ~/zephyrproject
391-
cd ~/zephyrproject
392-
west update
307+
west init ~/zephyrproject
308+
cd ~/zephyrproject
309+
west update
393310
394-
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
395-
automatically load boilerplate code required for building Zephyr
396-
applications.
311+
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
312+
automatically load boilerplate code required for building Zephyr
313+
applications.
397314

398-
.. code-block:: bash
315+
.. code-block:: bash
399316
400-
west zephyr-export
317+
west zephyr-export
401318
402-
#. Zephyr's ``scripts/requirements.txt`` file declares additional Python
403-
dependencies. Install them with ``pip3``.
319+
#. Zephyr's ``scripts/requirements.txt`` file declares additional Python
320+
dependencies. Install them with ``pip``.
404321

405-
.. code-block:: bash
322+
.. code-block:: bash
406323
407-
pip3 install -r ~/zephyrproject/zephyr/scripts/requirements.txt
324+
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt
408325
409326
.. group-tab:: Windows
410327

411-
.. tabs::
412-
413-
.. group-tab:: Install within virtual environment
414-
415-
#. Open a ``cmd.exe`` terminal window **as a regular user**
416-
417-
#. Create a new virtual environment:
418-
419-
.. code-block:: bat
420-
421-
cd %HOMEPATH%
422-
python -m venv zephyrproject\.venv
423-
424-
#. Activate the virtual environment:
328+
#. Open a ``cmd.exe`` terminal window **as a regular user**
425329

426-
.. code-block:: bat
330+
#. Create a new virtual environment:
427331

428-
zephyrproject\.venv\Scripts\activate.bat
429-
430-
Once activated your shell will be prefixed with ``(.venv)``. The
431-
virtual environment can be deactivated at any time by running
432-
``deactivate``.
433-
434-
.. note::
435-
436-
Remember to activate the virtual environment every time you
437-
start working.
438-
439-
#. Install west:
440-
441-
.. code-block:: bat
442-
443-
pip install west
444-
445-
#. Get the Zephyr source code:
446-
447-
.. code-block:: bat
448-
449-
west init zephyrproject
450-
cd zephyrproject
451-
west update
452-
453-
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
454-
automatically load boilerplate code required for building Zephyr
455-
applications.
456-
457-
.. code-block:: bat
332+
.. code-block:: bat
458333
459-
west zephyr-export
334+
cd %HOMEPATH%
335+
python -m venv zephyrproject\.venv
460336
461-
#. Zephyr's ``scripts\requirements.txt`` file declares additional Python
462-
dependencies. Install them with ``pip``.
337+
#. Activate the virtual environment:
463338

464-
.. code-block:: bat
339+
.. code-block:: bat
465340
466-
pip install -r %HOMEPATH%\zephyrproject\zephyr\scripts\requirements.txt
341+
zephyrproject\.venv\Scripts\activate.bat
467342
468-
.. group-tab:: Install globally
343+
Once activated your shell will be prefixed with ``(.venv)``. The
344+
virtual environment can be deactivated at any time by running
345+
``deactivate``.
469346

470-
#. Open a ``cmd.exe`` terminal window **as a regular user**
347+
.. note::
471348

472-
#. Install west:
349+
Remember to activate the virtual environment every time you
350+
start working.
473351

474-
.. code-block:: bat
352+
#. Install west:
475353

476-
pip3 install -U west
354+
.. code-block:: bat
477355
478-
#. Get the Zephyr source code:
356+
pip install west
479357
480-
.. code-block:: bat
358+
#. Get the Zephyr source code:
481359

482-
cd %HOMEPATH%
483-
west init zephyrproject
484-
cd zephyrproject
485-
west update
360+
.. code-block:: bat
486361
487-
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
488-
automatically load boilerplate code required for building Zephyr
489-
applications.
362+
west init zephyrproject
363+
cd zephyrproject
364+
west update
490365
491-
.. code-block:: bat
366+
#. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
367+
automatically load boilerplate code required for building Zephyr
368+
applications.
492369

493-
west zephyr-export
370+
.. code-block:: bat
494371
495-
#. Zephyr's ``scripts\requirements.txt`` file declares additional Python
496-
dependencies. Install them with ``pip3``.
372+
west zephyr-export
497373
498-
.. code-block:: bat
374+
#. Zephyr's ``scripts\requirements.txt`` file declares additional Python
375+
dependencies. Install them with ``pip``.
499376

500-
pip3 install -r %HOMEPATH%\zephyrproject\zephyr\scripts\requirements.txt
377+
.. code-block:: bat
501378
379+
pip install -r %HOMEPATH%\zephyrproject\zephyr\scripts\requirements.txt
502380
503381
Install the Zephyr SDK
504382
**********************

0 commit comments

Comments
 (0)