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

Expose a way to access the PYO3_CONFIG_FILE values #2033

Open
davidhewitt opened this issue Nov 29, 2021 · 2 comments
Open

Expose a way to access the PYO3_CONFIG_FILE values #2033

davidhewitt opened this issue Nov 29, 2021 · 2 comments

Comments

@davidhewitt
Copy link
Member

davidhewitt commented Nov 29, 2021

Some users have specific use cases where they would benefit from being able to access the PYO3_CONFIG_FILE values in some form from the pyo3 crate.

I generally wouldn't advise this, as a lot of these config files (such as library path) are unique to the build environment so wouldn't have any useful meaning in binaries intended to be deployed on other systems.

See original comment from #2000 below.

If anyone has need for this, I'm happy to help review designs and implementation.


It would be nice to have access to the library path from PYO3_CONFIG (or all values) but that is not a problem for me.

E.g. it could be based off the PYO3_CONFIG build mechanism - maybe we could have pyo3_config_var!("lib_path"). Or maybe just pyo3_lib_path!(). I'm open to hearing ideas on what's better.

An alternative could be a module filled with many const values, similar to what built does.

Originally posted by @jonasbb in #2000 (comment)

@aganders3
Copy link
Contributor

This seems related to the request here pyca/cryptography#6695 (comment) as well?

@messense can correct me but it seems they want to compile another static lib with the same version of Python PyO3 is using as part of a build script.

The other piece missing there is that the include path is not part of the pyo3_build_config::InterpreterConfig. It seems weird to add that if pyo3 itself doesn't use it, but I can come up with some alternative ideas:

  1. expose run_python_script (or implement it on InterpreterConfig), which is right now duplicated in that build.rs
  2. create something like Sysconfigdata::from_interpreter_config

@messense
Copy link
Member

messense commented Jan 5, 2022

What we want in pyca/cryptography#6695 are:

  1. A way to get the currently detected Python interpreter for running a Python script file and determining the interpreter kind for example disable ABI3 if it's PyPy.
  2. Get Python include file path from sysconfig

An InterpreterConfig with a run_python_script method sounds reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants