Skip to content

Commit 8b5b7ca

Browse files
d4l3kfacebook-github-bot
authored andcommitted
multipy: use primary python instead of newest (#218)
Summary: When cmake minimum version was switched in 8c7e487 it changed the default FIND_STRATEGY from LOCATION to VERSION. This explicitly switches it back so it'll prefer the active python from virtualenv/conda instead of from system even if it's newer. https://cmake.org/cmake/help/latest/module/FindPython3.html#hints Pull Request resolved: #218 Test Plan: ``` python setup.py develop ``` Reviewed By: PaliC Differential Revision: D40536560 Pulled By: d4l3k fbshipit-source-id: f78faaba4a8f24c2685018cb9bd20800b4a7a646
1 parent cbb67b2 commit 8b5b7ca

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ RUN rm -r multipy/runtime/build; mkdir multipy/runtime/build && \
102102
source ~/venvs/multipy/bin/activate && \
103103
cmake -DLEGACY_PYTHON_PRE_3_8=ON ..; \
104104
else \
105-
cmake -DLEGACY_PYTHON_PRE_3_8=OFF -DPython3_EXECUTABLE="$(which python3)" ..; \
105+
cmake -DLEGACY_PYTHON_PRE_3_8=OFF ..; \
106106
fi && \
107107
cmake --build . --config Release -j && \
108108
cmake --install . --prefix "." && \
@@ -117,7 +117,7 @@ RUN cd examples && \
117117
else \
118118
source /opt/conda/bin/activate; \
119119
fi && \
120-
cmake -S . -B build/ -DMULTIPY_PATH=".." -DPython3_EXECUTABLE="$(which python3)" && \
120+
cmake -S . -B build/ -DMULTIPY_PATH=".." && \
121121
cmake --build build/ --config Release -j
122122

123123
ENV PYTHONPATH=. LIBTEST_DEPLOY_LIB=multipy/runtime/build/libtest_deploy_lib.so

multipy/runtime/utils.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7+
# prefer the active Python version instead of the latest -- only works on cmake
8+
# 3.15+
9+
# https://cmake.org/cmake/help/latest/module/FindPython3.html#hints
10+
set(Python3_FIND_STRATEGY LOCATION)
11+
712
find_package (Python3 COMPONENTS Interpreter Development)
813
set(PYTORCH_ROOT "${Python3_SITELIB}")
914

0 commit comments

Comments
 (0)