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

[Feature Suggestion] Python bindings for cmake #444

Open
Andersama opened this issue Jan 27, 2024 · 3 comments
Open

[Feature Suggestion] Python bindings for cmake #444

Andersama opened this issue Jan 27, 2024 · 3 comments

Comments

@Andersama
Copy link

I'm not a python developer, but recently in writing some scripts for a cmake integration into an editor I found this module, however it uses the same mechanism I already was using. Namely by opening a shell via the subprocess module. In testing even with a shorter command like passing --version to cmake, I found there's roughly a ~.1+ second latency while python does the work to open a shell.
Meanwhile with another module which had python bindings there was no such latency (because it's roughly like a function call).

My suggestion, propose actual python bindings to be built into the cmake binary so that you can tap into it via this module, and where possible write a guide how to follow the ide integration guide via python, this way people looking to integrate cmake don't have to reimplement parsing different cmake related json, txt and cache files by hand.

@henryiii
Copy link
Contributor

The fix for this is simple, and I'd like to try it after #312 - we should put cmake in the scripts dir, and then (the tricky part) make the python library find it from there. And make sure it can find its data files. If we can do that, then there wouldn't be an added Python latency, and it would behave exactly correct in all situations.

@jcfr
Copy link
Contributor

jcfr commented Feb 15, 2024

in the scripts dir

That makes sense: That would then be Scripts on Windows, and bin on unix. Is there a variable describing this location ?

make the python library find it from there

Since it would be in the PATH, wouldn't that work without doing any thing special ?

@henryiii
Copy link
Contributor

Is there a variable describing this location?

There's a special folder in the wheel (the bin folder) that gets unpacked to the correct place. In scikit-build-core, it's ${SKBUILD_BIN_DIR}.

Since it would be in the PATH

You don't have to activate a virtual environment. .venv/bin/python -m "import cmake; ..." should continue to work. I think you can get the location of the installed binary, though, IIRC with importlib-metadata.

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

No branches or pull requests

3 participants