I would like to automatically generate Python stubs with MyPy stubgen for a pybind11 project. Ideally, I want to make this part of the build process so that I don’t need to worry about reprocessing it manually.
But there’s a slight problem. As far as I can tell, it seems like stubgen can only process .pyd modules if they are properly installed and can be found by their respective Python interpreter – otherwise, stubgen will just complain it can’t find the module. And therein lies the issue. To be installed, the Wheels need to have finished generating and packaging. But I would like the .pyi stub files to be included in the Wheels.
I’ve seen people suggesting that, as part of a Github Actions workflow, I should create and package the wheels, install them, generate the stubs, unpack the wheels, and repack them with the extra .pyi files. This is a compromise I’m willing to make, but it would cause the stubs to only properly generate for builds generated through my CI process, not if someone does a “pip install .” after cloning the repo. So I want to know if there’s really no other way.
submitted by /u/joaovbs96
[link] [comments]
r/learnpython I would like to automatically generate Python stubs with MyPy stubgen for a pybind11 project. Ideally, I want to make this part of the build process so that I don’t need to worry about reprocessing it manually. But there’s a slight problem. As far as I can tell, it seems like stubgen can only process .pyd modules if they are properly installed and can be found by their respective Python interpreter – otherwise, stubgen will just complain it can’t find the module. And therein lies the issue. To be installed, the Wheels need to have finished generating and packaging. But I would like the .pyi stub files to be included in the Wheels. I’ve seen people suggesting that, as part of a Github Actions workflow, I should create and package the wheels, install them, generate the stubs, unpack the wheels, and repack them with the extra .pyi files. This is a compromise I’m willing to make, but it would cause the stubs to only properly generate for builds generated through my CI process, not if someone does a “pip install .” after cloning the repo. So I want to know if there’s really no other way. submitted by /u/joaovbs96 [link] [comments]
I would like to automatically generate Python stubs with MyPy stubgen for a pybind11 project. Ideally, I want to make this part of the build process so that I don’t need to worry about reprocessing it manually.
But there’s a slight problem. As far as I can tell, it seems like stubgen can only process .pyd modules if they are properly installed and can be found by their respective Python interpreter – otherwise, stubgen will just complain it can’t find the module. And therein lies the issue. To be installed, the Wheels need to have finished generating and packaging. But I would like the .pyi stub files to be included in the Wheels.
I’ve seen people suggesting that, as part of a Github Actions workflow, I should create and package the wheels, install them, generate the stubs, unpack the wheels, and repack them with the extra .pyi files. This is a compromise I’m willing to make, but it would cause the stubs to only properly generate for builds generated through my CI process, not if someone does a “pip install .” after cloning the repo. So I want to know if there’s really no other way.
submitted by /u/joaovbs96
[link] [comments]