@@ -547,37 +547,40 @@ in a single pull request, so that regressions are not unwittingly introduced.
547
547
548
548
The workflow looks like this:
549
549
550
- - Install [ `uv `]( https://docs.astral.sh/uv/getting-started/installation/) and
551
- `docker `
550
+ - Install `uv < https://docs.astral.sh/uv/getting-started/installation/ >`_ and
551
+ `` docker ` `
552
552
- Create the temp build directory, cd into it, and run `cmake /path/to/source `
553
- - Run `cmake --build . --target pystubs ` to generate updated stubs in
554
- `src/bindings/python/stubs/__init__.pyi `
553
+ - Run `` cmake --build . --target pystubs ` ` to generate updated stubs in
554
+ `` src/bindings/python/stubs/__init__.pyi ` `
555
555
- Commit the new stubs and push to Github
556
- - In CI, the stubs will be included in the wheels built by `cibuildwheel `, as
557
- defined in `.github/workflows/wheel_workflow.yml `
558
- - In CI, one of the `cibuildwheel ` Github actions will rebuild the stubs to a
556
+ - In CI, the stubs will be included in the wheels built by `` cibuildwheel ` `, as
557
+ defined in `` .github/workflows/wheel_workflow.yml ` `
558
+ - In CI, one of the `` cibuildwheel ` ` Github actions will rebuild the stubs to a
559
559
temp location and verify that they match what has been committed to the repo.
560
560
This step ensures that if changes to the C++ source code and bindings results
561
561
in a change to the stubs, developers are notified of the need to regenerate
562
- the stubs, so that changes can be reviewed and the rules in `generate_stubs.py `
562
+ the stubs, so that changes can be reviewed and the rules in `` generate_stubs.py ` `
563
563
can be updated, if necessary.
564
564
565
- Note that if you can't (or don't want to) build the stubs locally, you can
566
- download an artifact containing the wheel and `__init__.pyi ` file from any job
567
- that fails the stub validation.
568
-
569
565
If you want to bypass the use of docker, you can use the following steps to
570
- build the python bindings and run the stub generator directly:
571
-
572
- ```
573
- python -m venv .venv
574
- . .venv/bin/activate
575
- mkdir build
576
- cd build
577
- cmake -DPython_EXECUTABLE=$(which python) -DCMAKE_INSTALL_PREFIX=../dist ..
578
- cmake --build . --target=install
579
- # extract the deps from the pyproject.toml and install them
580
- pip install $(yq -r '.tool.cibuildwheel.overrides.[0].test-requires' -oy ../pyproject.toml)
581
- PY_VER=$(python -c "import sys;print(f'{sys.version_info[0]}.{sys.version_info[1]}')")
582
- PYTHONPATH=../dist/lib/python$PY_VER/site-packages python ../src/bindings/python/stubs/generate_stubs.py --out-path ../src/bindings/python/stubs/
583
- ```
566
+ build the python bindings and run the stub generator directly (requires python
567
+ 3.11+):
568
+
569
+ .. code-block :: bash
570
+
571
+ python -m venv .venv
572
+ . .venv/bin/activate
573
+ mkdir build
574
+ cd build
575
+ cmake -DPython_EXECUTABLE=$( which python) -DCMAKE_INSTALL_PREFIX=../dist ..
576
+ cmake --build . --target=install
577
+ # extract the deps from the pyproject.toml and install them into the virtualenv
578
+ PY_DEPS=$( python -c " import tomllib;print(tomllib.load(open('../pyproject.toml', 'rb'))['tool']['cibuildwheel']['overrides'][0]['test-requires'])" )
579
+ pip install ${PY_DEPS}
580
+ PY_VER=$( python -c " import sys;print(f'{sys.version_info[0]}.{sys.version_info[1]}')" )
581
+ # generate stubs
582
+ PYTHONPATH=../dist/lib/python$PY_VER /site-packages python ../src/bindings/python/stubs/generate_stubs.py
583
+
584
+ If all else fails and you can't build the stubs locally, you can push changes
585
+ to CI and download an artifact containing the wheel and ``__init__.pyi `` file from
586
+ any job that fails the stub validation.
0 commit comments