Skip to content

Commit a3b5d26

Browse files
authored
Use tabs for easier use in WASI and container sections of Setup (#1632)
Also make sure that relevant shell snippets are formatted such they can be copy-and-pasted.
1 parent c04cc69 commit a3b5d26

File tree

1 file changed

+58
-24
lines changed

1 file changed

+58
-24
lines changed

getting-started/setup-building.rst

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,17 @@ The easiest way to get a debug build of CPython for WASI is to use the
409409
``Tools/wasm/wasi.py build`` command (which should be run w/ a recent version of
410410
Python you have installed on your machine):
411411

412-
.. code-block:: shell
412+
.. tab:: CPython 3.14 and newer
413+
414+
.. code-block:: shell
415+
416+
python3 Tools/wasm/wasi build --quiet -- --config-cache --with-pydebug
413417
414-
$ python3 Tools/wasm/wasi build --quiet -- --config-cache --with-pydebug
418+
.. tab:: CPython 3.13
415419

416-
For Python 3.14 and earlier, use ``Tools/wasm/wasi.py`` instead.
420+
.. code-block:: shell
421+
422+
python3 Tools/wasm/wasi.py build --quiet -- --config-cache --with-pydebug
417423
418424
That single command will configure and build both the build Python and the
419425
WASI build in ``cross-build/build`` and ``cross-build/wasm32-wasi``,
@@ -422,36 +428,48 @@ respectively.
422428
You can also do each configuration and build step separately; the command above
423429
is a convenience wrapper around the following commands:
424430

425-
.. code-block:: shell
426431

427-
$ python Tools/wasm/wasi configure-build-python --quiet -- --config-cache --with-pydebug
428-
$ python Tools/wasm/wasi make-build-python --quiet
429-
$ python Tools/wasm/wasi configure-host --quiet -- --config-cache
430-
$ python Tools/wasm/wasi make-host --quiet
432+
.. tab:: CPython 3.14 and newer
433+
434+
.. code-block:: shell
435+
436+
$ python Tools/wasm/wasi configure-build-python --quiet -- --config-cache --with-pydebug
437+
$ python Tools/wasm/wasi make-build-python --quiet
438+
$ python Tools/wasm/wasi configure-host --quiet -- --config-cache
439+
$ python Tools/wasm/wasi make-host --quiet
440+
441+
.. tab:: CPython 3.13
442+
443+
.. code-block:: shell
444+
445+
$ python Tools/wasm/wasi.py configure-build-python --quiet -- --config-cache --with-pydebug
446+
$ python Tools/wasm/wasi.py make-build-python --quiet
447+
$ python Tools/wasm/wasi.py configure-host --quiet -- --config-cache
448+
$ python Tools/wasm/wasi.py make-host --quiet
431449
432450
.. note::
433451

434452
The ``configure-host`` command infers the use of ``--with-pydebug`` from the
435453
build Python.
436454

437-
Running the separate commands after ``wasi.py build`` is useful if you, for example, only want to
438-
run the ``make-host`` step after making code changes.
455+
Running the separate commands after ``wasi build`` is useful if you, for example,
456+
only want to run the ``make-host`` step after making code changes.
439457

440458
Once everything is complete, there will be a
441-
``cross-build/wasm32-wasi/python.sh`` helper file which you can use to run the
459+
``cross-build/wasm32-wasip1/python.sh`` helper file which you can use to run the
442460
``python.wasm`` file (see the output from the ``configure-host`` subcommand):
443461

444462
.. code-block:: shell
445463
446-
$ cross-build/wasm32-wasi/python.sh --version
464+
cross-build/wasm32-wasip1/python.sh --version
447465
448466
You can also use ``Makefile`` targets and they will work as expected thanks to
449467
the ``HOSTRUNNER`` environment variable having been set to a similar value as
450468
used in ``python.sh``:
451469

452470
.. code-block:: shell
453471
454-
$ make -C cross-build/wasm32-wasi test
472+
make -C cross-build/wasm32-wasip1 test
455473
456474
.. note::
457475

@@ -1228,13 +1246,18 @@ are available from the
12281246
To run the container and launch a Bash shell, run one of the following commands
12291247
in a clone of the CPython repository.
12301248

1231-
.. code-block:: bash
1249+
.. tab:: Podman
12321250

1233-
docker run -it --rm --volume $PWD:/workspace --workdir /workspace ghcr.io/python/devcontainer:latest
1251+
.. code-block:: bash
12341252
1235-
.. code-block:: bash
1253+
podman run -it --rm --volume $PWD:/workspace:Z --workdir /workspace ghcr.io/python/devcontainer:latest
1254+
1255+
.. tab:: Docker
1256+
1257+
.. code-block:: bash
1258+
1259+
docker run -it --rm --volume $PWD:/workspace --workdir /workspace ghcr.io/python/devcontainer:latest
12361260
1237-
podman run -it --rm --volume $PWD:/workspace:Z --workdir /workspace ghcr.io/python/devcontainer:latest
12381261
12391262
Note that the container has read/write access to the working directory.
12401263
You may want to use a separate clone of CPython, or run ``make clean``
@@ -1249,11 +1272,17 @@ If you prefer, you can build the container image yourself. In a clone of the
12491272
`cpython-devcontainers repo`_,
12501273
build the container and name it ``cpython-dev``:
12511274

1252-
.. code-block:: bash
1275+
.. tab:: Podman
1276+
1277+
.. code-block:: shell
1278+
1279+
podman build devcontainer/ --tag cpython-dev
12531280
1254-
docker build devcontainer/ --tag cpython-dev
1281+
.. tab:: Docker
12551282

1256-
(Substitute ``podman`` for ``docker`` if you use Podman.)
1283+
.. code-block:: shell
1284+
1285+
docker build devcontainer/ --tag cpython-dev
12571286
12581287
The same command will update any existing ``cpython-dev`` container.
12591288
Run it again from time to time -- especially if the container stops
@@ -1262,13 +1291,18 @@ working for you.
12621291
To run the container and launch a Bash shell, run one of the following commands
12631292
in a clone of the CPython repository.
12641293

1265-
.. code-block:: bash
1294+
.. tab:: Podman
1295+
1296+
.. code-block:: shell
1297+
1298+
podman run -it --rm --volume $PWD:/workspace:Z --workdir /workspace cpython-dev bash
1299+
1300+
.. tab:: Docker
12661301

1267-
docker run -it --rm --volume $PWD:/workspace --workdir /workspace cpython-dev
1302+
.. code-block:: shell
12681303
1269-
.. code-block:: bash
1304+
docker run -it --rm --volume $PWD:/workspace --workdir /workspace cpython-dev bash
12701305
1271-
podman run -it --rm --volume $PWD:/workspace:Z --workdir /workspace cpython-dev
12721306
12731307
The same caveats outlined above when running from a container image from GHCR
12741308
also apply here.

0 commit comments

Comments
 (0)