Skip to content

Commit

Permalink
multipy: use primary python instead of newest (#218)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
d4l3k authored and facebook-github-bot committed Oct 20, 2022
1 parent cbb67b2 commit 8b5b7ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ RUN rm -r multipy/runtime/build; mkdir multipy/runtime/build && \
source ~/venvs/multipy/bin/activate && \
cmake -DLEGACY_PYTHON_PRE_3_8=ON ..; \
else \
cmake -DLEGACY_PYTHON_PRE_3_8=OFF -DPython3_EXECUTABLE="$(which python3)" ..; \
cmake -DLEGACY_PYTHON_PRE_3_8=OFF ..; \
fi && \
cmake --build . --config Release -j && \
cmake --install . --prefix "." && \
Expand All @@ -117,7 +117,7 @@ RUN cd examples && \
else \
source /opt/conda/bin/activate; \
fi && \
cmake -S . -B build/ -DMULTIPY_PATH=".." -DPython3_EXECUTABLE="$(which python3)" && \
cmake -S . -B build/ -DMULTIPY_PATH=".." && \
cmake --build build/ --config Release -j

ENV PYTHONPATH=. LIBTEST_DEPLOY_LIB=multipy/runtime/build/libtest_deploy_lib.so
Expand Down
5 changes: 5 additions & 0 deletions multipy/runtime/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# prefer the active Python version instead of the latest -- only works on cmake
# 3.15+
# https://cmake.org/cmake/help/latest/module/FindPython3.html#hints
set(Python3_FIND_STRATEGY LOCATION)

find_package (Python3 COMPONENTS Interpreter Development)
set(PYTORCH_ROOT "${Python3_SITELIB}")

Expand Down

0 comments on commit 8b5b7ca

Please sign in to comment.