Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stubgen autogeneration #453

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,26 @@ jobs:
echo ${CCACHE_BASEDIR}
ccache -s
fi


- name: Generate stubfiles
shell: bash
run: |

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

#Setup env
echo "PYTHONPATH=$WORKSPACE_ARTIFACT_PATH/lib/python3/site-packages" | tee -a $GITHUB_ENV

if [[ "$RUNNER_OS" == "Windows" ]]; then
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
&& cd /d ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/ \
&& bash ${{ env.WORKSPACE_SRC_PATH }}/scripts/generate_stubs.sh ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/"
else
cd ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/
/bin/bash ${{ env.WORKSPACE_SRC_PATH }}/scripts/generate_stubs.sh ${{ env.WORKSPACE_INSTALL_PATH }}/lib/python3/site-packages/
fi

- name: Set env vars for artifacts
shell: bash
run: |
Expand Down
24 changes: 24 additions & 0 deletions scripts/generate_stubs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

usage() {
echo "Usage: generate_stubs.sh <sofa-python3-site-packages-dir> "
echo "This script automatically generates stub files for SofaPython3 modules"
}

if [ "$#" -eq 1 ]; then
WORK_DIR=$1
else
usage; exit 1
fi

cd $WORK_DIR


for module_name in *; do
echo "Generating stubgen for $module_name"
stubgen -v -p $module_name --include-docstrings --inspect-mode --ignore-errors
if [ -d "./out/$module_name/" ]; then
rsync -a ./out/$module_name/ ./$module_name/
fi
rm -rf ./out
done
Loading