Open
Conversation
- Update CMake infrastructure. - Update Python source layout. - Add pyproject.toml. - Add additional instructions. Deferred: - Editable installs are not yet supported because of the way the Python code calls `ctypes`.
eirrgang
commented
Mar 12, 2026
Comment on lines
16
to
56
|
|
||
| def __init__(self, lib_dir=""): | ||
| if len(lib_dir) > 0: | ||
| current_dir = lib_dir | ||
| else: | ||
| current_dir = os.path.abspath(os.path.dirname(__file__)) | ||
|
|
||
| if _platform == "linux" or _platform == "linux2": | ||
| import readline | ||
| from ctypes import cdll | ||
|
|
||
| fullPath = os.path.join(current_dir, 'libxrayphysics.so') | ||
| fullPath_backup = os.path.join(current_dir, '../build/lib/libxrayphysics.so') | ||
|
|
||
| if os.path.isfile(fullPath): | ||
| self.libxrayphysics = cdll.LoadLibrary(fullPath) | ||
| elif os.path.isfile(fullPath_backup): | ||
| self.libxrayphysics = cdll.LoadLibrary(fullPath_backup) | ||
| else: | ||
| print('Error: could not find XrayPhysics dynamic library at') | ||
| print(fullPath) | ||
| print('or') | ||
| print(fullPath_backup) | ||
| self.libxrayphysics = None | ||
|
|
||
| elif _platform == "win32": | ||
| from ctypes import windll | ||
|
|
||
| fullPath = os.path.join(current_dir, 'libxrayphysics.dll') | ||
| fullPath_backup = os.path.join(current_dir, r'..\win_build\bin\Release\libxrayphysics.dll') | ||
|
|
||
| if os.path.isfile(fullPath): | ||
| try: | ||
| self.libxrayphysics = windll.LoadLibrary(fullPath) | ||
| except: | ||
| self.libxrayphysics = ctypes.CDLL(fullPath, winmode=0) | ||
| elif os.path.isfile(fullPath_backup): | ||
| try: | ||
| self.libxrayphysics = windll.LoadLibrary(fullPath_backup) | ||
| except: | ||
| self.libxrayphysics = ctypes.CDLL(fullPath_backup, winmode=0) |
Author
There was a problem hiding this comment.
This could be cleaned up in terms of importlib.metadata.files and related utilities, but the existing code still works (unless the package is run directly from a zipped package, which we would not expect).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deferred:
ctypes. See Support getting files in the build tree from editable installs scikit-build/scikit-build-core#808 and related conversations.Resolves #5