-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[libclang/python] Add LIBCLANG_LIBRARY_PATH and LIBCLANG_LIBRARY_FILE #170201
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
base: main
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-clang Author: Thomas Applencourt (TApplencourt) ChangesClose #167421 This PR ad the environment variables Full diff: https://github.com/llvm/llvm-project/pull/170201.diff 2 Files Affected:
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index d352373e85c60..b728a8d8369ad 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -4383,8 +4383,8 @@ def register(item: LibFunc) -> None:
class Config:
- library_path = None
- library_file: str | None = None
+ library_path: str | None = os.environ.get("LIBCLANG_LIBRARY_PATH")
+ library_file: str | None = os.environ.get("LIBCLANG_LIBRARY_FILE")
compatibility_check = True
loaded = False
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9f8d781c93021..fb812a21f2f31 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -170,6 +170,9 @@ Clang Python Bindings Potentially Breaking Changes
ElaboratedTypes. The value becomes unused, and all the existing users should
expect the former underlying type to be reported instead.
- Remove ``AccessSpecifier.NONE`` kind. No libclang interfaces ever returned this kind.
+- Added the environment variables ``LIBCLANG_LIBRARY_PATH`` and ``LIBCLANG_LIBRARY_FILE``,
+ which allow users to specify the directory path and the exact library file that
+ should be used to locate libclang.
What's New in Clang |release|?
==============================
|
|
For more rational on the change see the issue #167421. The PR is currently in the "minimal" stage. I can:
Curious what do people thinks (previous |
DeinAlptraum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in the release note that people should migrate to LIBCLANG_LIBRARY_PATH
I don't think that's necessary since this is only used by the tests and they are not part of the interface we offer.
Where this should be adapted however is the clang/bindings/python/README.md
Add tests.
Yes please. You can create an additional test file for this, where you set the environment variable from the code, and then import cindex. Then this shouldn't be an issue. I think...
All in favor of removing the old setting CLANG_LIBRARY_PATH at the top of all the test files. Note that the current cmake build flow requires this, so you will need to change the variable name in clang/bindings/python/tests/CMakeLists.txt
Additionally, in get_cindex_library, an error message is returned that refers to the methods to set the library file. This should be adapted to also mention the environment variables.
|
CC @Endilll |
Co-authored-by: Jannick Kremer <[email protected]>
|
✅ With the latest revision this PR passed the Python code formatter. |
|
Ok, so:
Sorry I failed my Erf, I run |
9deaa3f to
6e158e8
Compare
6e158e8 to
d124b43
Compare
DeinAlptraum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor cleanup, otherwise LGTM!
| from clang.cindex import AccessSpecifier, Config | ||
|
|
||
| if "CLANG_LIBRARY_PATH" in os.environ: | ||
| Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config should now be unused in most (all?) test files, so you can remove the import as well
| import os | ||
|
|
||
|
|
||
| def reset_import_and_get_frech_config(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def reset_import_and_get_frech_config(): | |
| def reset_import_and_get_fresh_config(): |
Close #167421
This PR ad the environment variables
LIBCLANG_LIBRARY_PATHandLIBCLANG_LIBRARY_FILE, which allow users to specify the directory path and the exact library file that should be used to locate libclang.