Skip to content

Support Python wheel packaging.#6

Open
eirrgang wants to merge 1 commit intokylechampley:mainfrom
eirrgang:5-packaging
Open

Support Python wheel packaging.#6
eirrgang wants to merge 1 commit intokylechampley:mainfrom
eirrgang:5-packaging

Conversation

@eirrgang
Copy link

  • Update CMake infrastructure.
  • Update Python source layout.
  • Add pyproject.toml.
  • Add additional instructions.

Deferred:

Resolves #5

- 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`.
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)
Copy link
Author

Choose a reason for hiding this comment

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

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).

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

Successfully merging this pull request may close these issues.

Support modern native Python packaging

1 participant