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

[tools] generate stubfiles during packaging #5222

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bakpaul
Copy link
Contributor

@bakpaul bakpaul commented Jan 15, 2025

Add a script that is launched right after CPack copied the install files and before the package is built.
This has one consequences : the target file structure is dependent on the generator. This is why it is passed as an argument.

You can also see that the source directory is passed as a relative path to the script location : this is because the CMake context is not the same as during installation when the script is executed : CMAKE_SOURCE_DIR doesn't exist anymore.

This currently works perfectly for :

  • Ubuntu with ZIP and IFW
  • Macos with ZIP and IFW (I had to add a rpath manually to libs depending on Python to make it work)
  • Windows with NSIS

--> it doesn't work for Windows with ZIP and I really don't know why... This is the easiest generator because the tree is the same as the install tree. The error is that Sofa is not found by python although the PYTHONPATH seems to be correctly set.

Here is the output :

Generate stubfiles...
Inputs are
- SRC_DIR       :/j/0/src
- INSTALL_DIR   :/j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64
- SYSTEM_NAME   :Windows:ZIP
PATH=/j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64/lib:/j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64/bin:/j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64/plugins/SofaPython3/lib:/j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64/plugins/SofaPython3/bin:/c/Python312/Lib:/c/Python312:/c/Python312/DLLs:/c/Python312/Lib:[...]
SOFA_ROOT=/j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64
PYTHONPATH=/j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64/plugins/SofaPython3/lib/python3/site-packages:
Launching the stub generation with 'C:/Python312/python.exe /j/0/src/applications/plugins/SofaPython3/scripts/generate_stubs.py -d /j/0/build/_CPack_Packages/win64/ZIP/SOFA_v24.12.00_Win64/plugins/SofaPython3/lib/python3/site-packages -m Sofa --use_pybind11'
Traceback (most recent call last):
  File "J:\0\src\applications\plugins\SofaPython3\scripts\generate_stubs.py", line 3, in <module>
    from utils import generate_module_stubs, generate_component_stubs
  File "J:\0\src\applications\plugins\SofaPython3\scripts\utils.py", line 4, in <module>
    from sofaStubgen import load_component_list, create_sofa_stubs
  File "J:\0\src\applications\plugins\SofaPython3\scripts\sofaStubgen.py", line 13, in <module>
    import Sofa
ModuleNotFoundError: No module named 'Sofa'
Generate stubfiles: done.

Any help is welcome !

PS: as a recal the stubgen script is in SofaPython3 sources : https://github.com/sofa-framework/SofaPython3/tree/master/scripts


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@bakpaul bakpaul added pr: status to review To notify reviewers to review this pull-request pr: backport todo This PR will be backported into the release preceeding its milestone. labels Jan 15, 2025
@bakpaul bakpaul requested review from alxbilger and fredroy January 15, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: backport todo This PR will be backported into the release preceeding its milestone. pr: status to review To notify reviewers to review this pull-request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant