Skip to content

Update python wrappers #495

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

Merged
merged 6 commits into from
Jun 20, 2025
Merged

Update python wrappers #495

merged 6 commits into from
Jun 20, 2025

Conversation

Sichao25
Copy link
Collaborator

The Python wrappers have been out of date for some time and were only compatible with older versions of PUMI. This PR addresses several related issues:

  • Updates deprecated APIs in the interface files.
  • Comment out a few lines in the preprocessor to avoid a parsing problem in SWIG (other workarounds may also be possible).
  • Updates the Python test scripts accordingly.
  • Adds a .smd file as an alternative to .x_t to adapt to different versions of Simmetrix.
  • Adds a new CI workflow that builds and runs the Python test script without requiring Simmetrix.

@cwsmith
Copy link
Contributor

cwsmith commented Jun 13, 2025

Thank you @Sichao25 . Regarding the pre-processor issue, does the following SO post help?
https://stackoverflow.com/questions/11403520/preprocessor-macro-in-swig

@Sichao25
Copy link
Collaborator Author

Sichao25 commented Jun 19, 2025

Unfortunately, that SO doesn't work on my side. However, I was able to get things working by ignoring the SWIG unrecognized code during compilation and implementing it in another way in the SWIG interface file. (Thanks to Aiden for the idea and resources!)

I've added the required template initialization to the PR. I could also implement a similar DebugPrint function in the SWIG interface. For example:

%extend pcu::PCU{
  void DebugPrint(FILE *f, const char *format, ...) {
    va_list args;
    va_start(args, format);
    vfprintf(f, format, args);
    fflush(f);
    va_end(args);
  }
}

But I'm not sure if it's worth the effort, since I feel like it would be relatively straightforward to achieve the same functionality in Python.

Do you think it makes sense to skip the DebugPrint feature in the wrapped Python API, especially since it wasn't included in the older version either?

@jacobmerson
Copy link
Contributor

My opinion is skip DebugPrint whomever is using the python interface is just going to directly call print anyways.

@jacobmerson
Copy link
Contributor

The changes look good to me and the example is pretty clean.

@Sichao25 Sichao25 marked this pull request as ready for review June 20, 2025 18:01
@Sichao25
Copy link
Collaborator Author

@cwsmith Does the comment make sense to you?

Copy link
Contributor

@cwsmith cwsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you.

@jacobmerson jacobmerson merged commit a1df7b8 into develop Jun 20, 2025
33 checks passed
@cwsmith cwsmith deleted the yus/update_python_wrapper branch June 20, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants