Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,41 @@ jobs:
echo ${CCACHE_BASEDIR}
ccache -s
fi



- name: Set env vars for stubfiles
shell: bash
run: |
#Setup env
# Set env vars for tests
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "$WORKSPACE_INSTALL_PATH/lib" >> $GITHUB_PATH
echo "$WORKSPACE_INSTALL_PATH/bin" >> $GITHUB_PATH
elif [[ "$RUNNER_OS" == "macOS" ]]; then
echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV
else # Linux
echo "LD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV
fi

echo "PYTHONPATH=$WORKSPACE_INSTALL_PATH/lib/python3/site-packages" | tee -a $GITHUB_ENV

- name: Generate stubfiles
shell: bash
run: |

#Install stubgen
${{ steps.sofa.outputs.python_exe }} -m pip install mypy pybind11-stubgen

#For now use pybind11. This might be parametrized as an input of this action
echo "Launching the stub generation with '${{ steps.sofa.outputs.python_exe }} ${{ env.WORKSPACE_SRC_PATH }}/scripts/generate_stubs.py -d $WORKSPACE_INSTALL_PATH/lib/python3/site-packages -m Sofa --use_pybind11'"

${{ steps.sofa.outputs.python_exe }} ${{ env.WORKSPACE_SRC_PATH }}/scripts/generate_stubs.py -d "$WORKSPACE_INSTALL_PATH/lib/python3/site-packages" -m Sofa --use_pybind11

#Go back to previous env
echo "PYTHONPATH=" | tee -a $GITHUB_ENV



- name: Set env vars for artifacts
shell: bash
run: |
Expand Down
35 changes: 35 additions & 0 deletions scripts/generate_stubs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sys
import argparse
from utils import generate_module_stubs, generate_component_stubs


def main(site_package_dir,modules_name,use_pybind11 = False):

work_dir = site_package_dir[0]
modules = modules_name

#Generate stubs using either pybind11-stubgen or mypy version of stubgen

print(f"Generating stubgen for modules: {modules}")

for module_name in modules:
generate_module_stubs(module_name, work_dir,use_pybind11)

#Generate stubs for components using the factory
target_name="Sofa.Component"
generate_component_stubs(work_dir,target_name)



if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog='generate_stubs',
description='Generates python stubs for SOFA modules')

parser.add_argument('--use_pybind11',action='store_true',help='If flag is present, will use pybind11-stubgen instead of mypy stugen')
parser.add_argument('-d','--site_package_dir',nargs=1,help='Path to the site-package folder containing the SOFA modules')
parser.add_argument('-m','--modules_name',nargs='+',help='List of modules names to generate stubs for')

args = parser.parse_args()

main(args.site_package_dir,args.modules_name,args.use_pybind11)
Loading
Loading