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

fix the DLL import issue on python 3.8 or higher on windows #387

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Frontispiece/python_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ A succesfull installation should be able to execute the script at `TIGRE/Python/

6. Try demo 3. If it runs succesfully then you are good to go.

**Note:** It is known that the package cannot be imported using a pure Python 3.8 installation, i.e.
not using a conda environment. Please try a pure installation of Python 3.7 or consider using a
conda environment.

## Linux

### Requirements:
Expand Down
19 changes: 19 additions & 0 deletions Python/tigre/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
from __future__ import division, absolute_import, print_function

# fix for DLL import issue on python 3.8 or higher on windows
# related to:
# https://github.com/CERN/TIGRE/issues/247
# https://github.com/CERN/TIGRE/issues/349
import os

if hasattr(os, "add_dll_directory"):
# Add all the DLL directories manually
# see:
# https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew
# https://stackoverflow.com/a/60803169/19344391
dll_directory = os.path.dirname(__file__)
os.add_dll_directory(dll_directory)

# The user must install the CUDA Toolkit
cuda_bin = os.path.join(os.environ["CUDA_PATH"], "bin")
os.add_dll_directory(cuda_bin)

from .utilities.geometry import geometry
from .utilities.geometry_default import ConeGeometryDefault as geometry_default
from .utilities.Ax import Ax
Expand Down