Skip to content

Commit

Permalink
remove dependency on setting EXT_SUFFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Feb 12, 2021
1 parent b67bbe2 commit 87426b6
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .circleci/Dockerfile.faiss_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ COPY . /faiss

WORKDIR /faiss

RUN export EXT_SUFFIX=$(python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))") && \
cmake -B build \
RUN cmake -B build \
-DFAISS_ENABLE_GPU=ON \
-DFAISS_ENABLE_PYTHON=ON \
-DBUILD_TESTING=ON \
Expand Down
2 changes: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
- run:
name: Build faiss library
command: |
export EXT_SUFFIX=$(python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
cmake -B build -DBUILD_TESTING=ON -DFAISS_ENABLE_GPU=OFF \
-DCMAKE_BUILD_TYPE=Release -DBLA_VENDOR=Intel10_64_dyn .
make -C build -j faiss
Expand Down Expand Up @@ -59,7 +58,6 @@ jobs:
- run:
name: Generate Makefiles
command: |
export EXT_SUFFIX=$(/usr/local/bin/python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
cmake -B build -DBUILD_TESTING=ON -DFAISS_ENABLE_GPU=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DPython_EXECUTABLE=/usr/local/bin/python3 .
Expand Down
3 changes: 0 additions & 3 deletions conda/faiss-gpu/build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

set -e

# needed by CMakeLists.txt for correct extension
export EXT_SUFFIX=$(python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
echo "Setting environment variable EXT_SUFFIX to \"${EXT_SUFFIX}\" (from python-sysconfig)"

# Build avx2 version.
cmake -B _build_python_${PY_VER}_avx2 \
Expand Down
4 changes: 0 additions & 4 deletions conda/faiss/build-pkg.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
:: This source code is licensed under the MIT license found in the
:: LICENSE file in the root directory of this source tree.

:: needed by CMakeLists.txt for correct extension
for /f "delims=" %%i in ('python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"') do set "EXT_SUFFIX=%%i"
echo Setting environment variable EXT_SUFFIX to "%EXT_SUFFIX%" (from python-sysconfig)

:: Build vanilla version (no avx).
cmake -B _build_python_%PY_VER% ^
-T v141 ^
Expand Down
3 changes: 0 additions & 3 deletions conda/faiss/build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

set -e

# needed by CMakeLists.txt for correct extension
export EXT_SUFFIX=$(python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
echo "Setting environment variable EXT_SUFFIX to \"${EXT_SUFFIX}\" (from python-sysconfig)"

# Build avx2 version.
cmake -B _build_python_${PY_VER}_avx2 \
Expand Down
7 changes: 4 additions & 3 deletions faiss/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ swig_add_library(swigfaiss
SOURCES swigfaiss.swig
)

# This is set to the value of sysconfig.get_config_var('EXT_SUFFIX') in build-pkg.{bat|sh}
# For example, PyPy does not recognize the plain "so"-extension; see https://github.com/swig/swig/issues/1912
set_target_properties(swigfaiss PROPERTIES SUFFIX $ENV{EXT_SUFFIX})
if(NOT WIN32)
# NOTE: Python does not recognize the dylib extension.
set_target_properties(swigfaiss PROPERTIES SUFFIX .so)
endif()

if(FAISS_ENABLE_GPU)
find_package(CUDAToolkit REQUIRED)
Expand Down
3 changes: 1 addition & 2 deletions faiss/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from __future__ import print_function
from setuptools import setup, find_packages
import os
import shutil
import sysconfig
import platform

Expand All @@ -18,7 +17,7 @@
shutil.copyfile("loader.py", "faiss/loader.py")
shutil.copyfile("swigfaiss.py", "faiss/swigfaiss.py")

ext = sysconfig.get_config_var('EXT_SUFFIX')
ext = ".pyd" if platform.system() == 'Windows' else ".so"
prefix = "Release/" * (platform.system() == 'Windows')
shutil.copyfile(f"{prefix}_swigfaiss{ext}", f"faiss/_swigfaiss{ext}")

Expand Down

0 comments on commit 87426b6

Please sign in to comment.