@Petras_Vestartas Ok I got it to work but the solution is quite complicated:
Important Notes:
compas_wooddepends onwood_pybind11.cp39-win_amd64.pydthat has its own list of dependencies.
The command dumpbin /dependents C:\Users\ein\compas_wood\src\wood_pybind11.cp39-win_amd64.pyd provides a list of dlls that the .pyd depends on. We need to make sure python can find these dlls.
File Type: DLL
Image has the following dependencies:
liblapack.dll
libblas.dll
python39.dll
libcblas.dll
KERNEL32.dll
VCRUNTIME140.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
-
.pyd is compiled against your conda env python which means that python.exe can easily find these aforementioned dlls.
-
The
compas_woodpackages is also installed there which meansLibs/site-packages/easy-install.pthfile points the python runtime to wherecompas_woodmodules is located.
Now to get the python in Rhino to load the package installed in a conda environment, we need to:
#! python 3
import os
import os.path as op
import sys
import ctypes
CONDA_ENV = r'C:\Users\ein\.conda\envs\wood-dev'
COMPAS_WOOD_PATH = r'C:\Users\ein\compas_wood\src'
# add the paths of site-packages in conda environment so other packages that compas_wood
# depend on can be found e.g. compas
sys.path.append(op.join(CONDA_ENV, r"Lib\site-packages"))
# add the location of compas_wood source so we can import this
sys.path.append(COMPAS_WOOD_PATH)
# tell python where it can find dlls. this is required to find all other .dll files that
# are installed as part of the other packages in the conda environment e.g. fblas
os.add_dll_directory(op.join(CONDA_ENV, r'Library\bin'))
# tell python where the wood_pybind11*.pyd is located
os.add_dll_directory(COMPAS_WOOD_PATH)
# now we can import the module and test
from compas_wood.joinery import test
print(test)
test()
I also added a ticket to possibly improve this:
RH-80486 Investigate loading a conda environment directly in Rhino