File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -565,3 +565,19 @@ The workflow looks like this:
565565Note that if you can't (or don't want to) build the stubs locally, you can
566566download an artifact containing the wheel and `__init__.pyi ` file from any job
567567that fails the stub validation.
568+
569+ 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+ ```
Original file line number Diff line number Diff line change @@ -258,6 +258,7 @@ install(TARGETS PyOpenColorIO
258258 LIBRARY DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR}
259259)
260260
261+ install (FILES package/__init__.py DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR} )
261262install (FILES stubs/PyOpenColorIO/__init__.pyi DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR} )
262263install (FILES stubs/PyOpenColorIO/py.typed DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR} )
263264
Original file line number Diff line number Diff line change 22Script to generate pyi stubs by patching and calling mypy's stubgen tool.
33
44There are two entry-points which are designed to call this script:
5- - `make pystubs` is called during local development to generate the
5+ - `cmake --build . --target pystubs` is called during local development to generate the
66 stubs and copy them into the git repo to be committed and reviewed.
77 - in CI, the cibuildwheel action is used to validate that the stubs match what
88 has been committed to the repo.
@@ -117,7 +117,6 @@ def main() -> None:
117117 parser = argparse .ArgumentParser ()
118118 parser .add_argument (
119119 "--out-path" ,
120- default = "out" ,
121120 help = "Directory to write the stubs."
122121 )
123122 parser .add_argument (
@@ -127,7 +126,10 @@ def main() -> None:
127126 "contents differ."
128127 )
129128 args = parser .parse_args ()
130- out_path = pathlib .Path (args .out_path )
129+ if not args .out_path :
130+ out_path = pathlib .Path (sys .modules [__name__ ].__file__ ).parent
131+ else :
132+ out_path = pathlib .Path (args .out_path )
131133 print (f"Stub output directory: { out_path } " )
132134
133135 # perform import so we can see the traceback if it fails.
You can’t perform that action at this time.
0 commit comments