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

[WIP] API changes for Julia bindings #1016

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

abussy
Copy link
Collaborator

@abussy abussy commented Aug 8, 2024

This PR brings some changes to the API, in order to facilitate the creation of Julia bindings for SIRIUS in a future SIRIUS.jl package.

Apart from the additions of new functions to sirius_api.cpp (necessary for the DFTK integration), the main addition consists of a header file for the API: sirius_c_headers.h. It turns out that having a header file drastically simplifies the process of creating Julia bindings for a C/C++ library.

As things stand, this header file is generated by a script (generate_c_headers.py), in the same spirit as the Fortran API. As a result, it is not used for compilation, but only as source material for the automatic generation of Julia bindings.

The above point is why this PR is marked as WIP. I believe we might want to have a discussion as to whether we follow this direction, or if we decide to have a proper header file that we also use for compilation.

@abussy abussy mentioned this pull request Aug 8, 2024
5 tasks
@toxa81 toxa81 self-requested a review August 19, 2024 12:23
Copy link
Collaborator

@toxa81 toxa81 left a comment

Choose a reason for hiding this comment

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

To me this looks fine. There are no breaking changes, and .h file serves its purpose for Julia bindings. Later we can get back to a discussion how to improve it.

@toxa81 toxa81 requested a review from simonpintarelli August 19, 2024 14:42
@abussy
Copy link
Collaborator Author

abussy commented Aug 19, 2024

Any opinion on this @simonpintarelli, @mtaillefumier ?

@mtaillefumier
Copy link
Collaborator

No major objections especially if the header file generated automatically.

@simonpintarelli
Copy link
Collaborator

The docstrings are now duplicated in the header and in sirius_api.cpp. This can be cleaned up, docstrings should be in the header and then the rest adapted accordingly to generate sirius.f90 from the header. Fine for me to do it in a future PR.

@toxa81
Copy link
Collaborator

toxa81 commented Aug 20, 2024

The docstrings are now duplicated in the header and in sirius_api.cpp. This can be cleaned up, docstrings should be in the header and then the rest adapted accordingly to generate sirius.f90 from the header. Fine for me to do it in a future PR.

Good catch @simonpintarelli ! However, I would still use sirius_api.cpp as a source of truth for the documentation and a bare header file only for Julia bindings. @abussy will it be possible to cleanup .h file from the doc. comments?

@abussy
Copy link
Collaborator Author

abussy commented Aug 20, 2024

My script to generate Julia bindings makes use of the docstrings. I am also not sure I could get the data from sirius_api.cpp, as it is not shipped in the include folder of the library (and putting it there would be akward).

@toxa81 toxa81 merged commit 14bf6e0 into electronic-structure:develop Aug 20, 2024
3 checks passed
abussy added a commit to abussy/SIRIUS that referenced this pull request Oct 9, 2024
This PR brings some changes to the API, in order to facilitate the creation of Julia bindings for SIRIUS in a future SIRIUS.jl package.

Apart from the additions of new functions to sirius_api.cpp (necessary for the DFTK integration), the main addition consists of a header file for the API: sirius_c_headers.h. It turns out that having a header file drastically simplifies the process of creating Julia bindings for a C/C++ library.

As things stand, this header file is generated by a script (generate_c_headers.py), in the same spirit as the Fortran API. As a result, it is not used for compilation, but only as source material for the automatic generation of Julia bindings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants