JCF: on James Paul Turner's recommendation, generate pybind11-stubgen… - #172
Conversation
… output files when that tool is installed
|
Thank you @jcfreeman2, I can confirm that having this branch with a local copy of Following this change I have a few questions
|
|
Thanks for taking a look @PawelPlesniak :
|
|
Sorry for the delay with the response. To implement this, I ran However, when running, I ended up not getting stubs when using Note the above is from your suggested changes, but ran manually |
|
I've now installed pybind11-stubgen in the externals on /cvmfs and there's now a test build available, EXTFD_DEV_260721_A9, which (1) will load it in when you set up the environment and (2) has daq-cmake installed from this feature branch. You can, e.g., build conffwk to see what happens with this setup to test this feature branch. |
|
I can confirm that when executing the following commands, with work as normal, with the last Looking inside the path In both of these releases, the version of |
|
|
||
| _daq_define_exportname() | ||
| install(TARGETS ${libname} EXPORT ${DAQ_PROJECT_EXPORTNAME} DESTINATION ${destdir}) | ||
| install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python/${PROJECT_NAME}/ DESTINATION ${destdir} OPTIONAL FILES_MATCHING PATTERN "*.pyi") |
There was a problem hiding this comment.
I have a request for a change here, to include the following pattern in the new install line:
PATTERN "py.typed"
There are two ways that signatures can be checked:
- The source code is written in python (which is the case for repositories that contain both C++ and python), and both the function arguments and return types are specified following the PEP 561 standards. The use of
py.typedsignifies this compliance, and will get installed for packages that both have this file and are ready for the signature checking. - The source code is written in C++, and python code is allowed to use it through
pybind11. This PR allows for the stub files (*.pyi) to be generated, which allows for the function signatures to be inspected.
As it currently stands, the inclusion of *.pyi only will only allow for the stubs of the pybind11 generated code to be checked, not of the native python code that has signatures specified. An example of where we will need this is in this conffwk PR, which requires checking of both the pybind11 stubs as well as the native python code.
|
I have one thing to discuss, which I have left in the comment, after which I will be happy for this PR to go in |
… output files when that tool is installed
Description
Basically, if
pybind11-stubgenis available and a package callsdaq_add_python_bindings,pybind11-stubgenwill be called to generate*.pyifiles to sit alongside the other files in the relevant install directory (e.g.,$DBT_AREA_ROOT/install/conffwk/lib64/python/conffwk).I'm adding this change since Pawel and James wish to use
pybind11-stubgento install a kind of type checking in Python.To test, create a work area, and clone
daq-cmakeon this feature branch in $DBT_AREA_ROOT/sourcecode. Also clone one (or more) packages with Python bindings. See what happens when you rundbt-build, both with and withoutpybind11-stubgenlocally installed.Type of change
Testing checklist
These are inapplicable to daq-cmake.
dbt-build --unittest)pytest -s minimal_system_quick_test.py)dunedaq_integtest_bundle.sh)python -m pytest)pre-commit run --all-files)Comments here on the testing
Further checks
dbt-build --lint, and/or see https://dune-daq-sw.readthedocs.io/en/latest/packages/styleguide/)(Indicate issue here: # (issue))