taichi-dev / taichi-aot-demo

A demo illustrating how to use Taichi as an AOT shader compiler
Apache License 2.0
71 stars 16 forks source link

How to tell CMake to use Anaconda environment? #126

Open jarmitage opened 1 year ago

jarmitage commented 1 year ago

When I add this to the CMake file:

execute_process (
    COMMAND bash -c "which python"
    OUTPUT_VARIABLE outVar
)

message(STATUS "path: ${outVar}")

I get the correct Python path for my current conda environment.

But, I am getting ModuleNotFoundError: No module named 'taichi' errors when running python ./ci/run_tests.py -l $TAICHI_C_API_INSTALL_DIR.

PENGUINLIONG commented 1 year ago

Someone met the same problem before and it seems old CMake's FindPython.cmake doesn't look for Python in conda environments. Please upgrade your CMake to 3.17 or higher.

jarmitage commented 1 year ago

That's interesting, I am using CMake 3.26.1, but it sounds like it could be a similar issue.

I couldn't find any info about how to possibly intervene with FindPython that might help here though https://cmake.org/cmake/help/latest/module/FindPython3.html

Maybe the 'someone' you mentioned might know? Or do you remember anything else about their issue/solution?

jarmitage commented 1 year ago

Ok, changing this to 3.26 fixed it! Is that what you meant?

https://github.com/taichi-dev/taichi-aot-demo/blob/a6c35b6a8b1cc17768bc66ed628c2b44cf889bf7/CMakeLists.txt#L1

jarmitage commented 1 year ago

Ok, so to run the CI script on macOS using conda and Vulkan only, I had to:

set(CMAKE_PREFIX_PATH "/Users/xxx/.miniconda3/envs/my-env/")
find_package (Python ${MY_PYTHON_VERSION} EXACT REQUIRED)