Skip to content

Commit a98b00e

Browse files
committed
Merge branch 'add_automatic_stubgen' into add_stubgen_autogeneration
2 parents 1dd6372 + bf70e90 commit a98b00e

File tree

5 files changed

+522
-32
lines changed

5 files changed

+522
-32
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,9 @@ jobs:
8383
#Setup env
8484
echo "PYTHONPATH=$WORKSPACE_ARTIFACT_PATH/lib/python3/site-packages" | tee -a $GITHUB_ENV
8585
86-
if [[ "$RUNNER_OS" == "Windows" ]]; then
87-
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
88-
&& cd /d ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/ \
89-
&& bash ${{ env.WORKSPACE_SRC_PATH }}/scripts/generate_stubs.sh ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/"
90-
else
91-
cd ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/
92-
/bin/bash ${{ env.WORKSPACE_SRC_PATH }}/scripts/generate_stubs.sh ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/
93-
fi
86+
#For now use pybind11. This might be parametrized as an input of this action
87+
${{ steps.sofa.outputs.python_exe }} ${{ env.WORKSPACE_SRC_PATH }}/scripts/generate_stubs.py -d /home/paul/dev/build/sofa/lib/python3/site-packages -m Sofa --use_pybind11
88+
9489
9590
- name: Set env vars for artifacts
9691
shell: bash

scripts/generate_stubs.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import sys
2+
import argparse
3+
from utils import generate_module_stubs, generate_component_stubs
4+
5+
6+
def main(site_package_dir,modules_name,use_pybind11 = False):
7+
8+
work_dir = site_package_dir
9+
modules = modules_name
10+
11+
#Generate stubs using either pybind11-stubgen or mypy version of stubgen
12+
13+
print(f"Generating stubgen for modules: {modules}")
14+
15+
for module_name in modules:
16+
generate_module_stubs(module_name, work_dir,use_pybind11)
17+
18+
#Generate stubs for components using the factory
19+
target_name="Sofa.Component"
20+
generate_component_stubs(work_dir,target_name)
21+
22+
23+
24+
if __name__ == "__main__":
25+
parser = argparse.ArgumentParser(
26+
prog='generate_stubs',
27+
description='Generates python stubs for SOFA modules')
28+
29+
parser.add_argument('--use_pybind11',action='store_true',help='If flag is present, will use pybind11-stubgen instead of mypy stugen')
30+
parser.add_argument('-d','--site_package_dir',nargs=1,help='Path to the site-package folder containing the SOFA modules')
31+
parser.add_argument('-m','--modules_name',nargs='+',help='List of modules names to generate stubs for')
32+
33+
args = parser.parse_args()
34+
35+
main(args.site_package_dir,args.modules_name,args.use_pybind11)

scripts/generate_stubs.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)