from __future__ import print_function
from setuptools import setup, find_packages
import os
import shutil

here = os.path.abspath(os.path.dirname(__file__))

check_fpath = os.path.join("_swigfaiss.so")
if not os.path.exists(check_fpath):
    print("Could not find {}".format(check_fpath))
    print("Have you run `make` and `make -C python`?")

# make the faiss python package dir
shutil.rmtree("faiss", ignore_errors=True)
os.mkdir("faiss")
shutil.copytree("contrib", "faiss/contrib")
shutil.copyfile("__init__.py", "faiss/__init__.py")
shutil.copyfile("loader.py", "faiss/loader.py")
shutil.copyfile("swigfaiss.py", "faiss/swigfaiss.py")
shutil.copyfile("_swigfaiss.so", "faiss/_swigfaiss.so")
try:
    shutil.copyfile("swigfaiss_avx2.py", "faiss/swigfaiss_avx2.py")
    shutil.copyfile("_swigfaiss_avx2.so", "faiss/_swigfaiss_avx2.so")
except:
    pass

long_description="""
Faiss is a library for efficient similarity search and clustering of dense
vectors. It contains algorithms that search in sets of vectors of any size,
 up to ones that possibly do not fit in RAM. It also contains supporting
code for evaluation and parameter tuning. Faiss is written in C++ with
complete wrappers for Python/numpy. Some of the most useful algorithms
are implemented on the GPU. It is developed by Facebook AI Research.
"""
setup(
    name='faiss',
    version='1.6.3',
    description='A library for efficient similarity search and clustering of dense vectors',
    long_description=long_description,
    url='https://github.com/facebookresearch/faiss',
    author='Matthijs Douze, Jeff Johnson, Herve Jegou, Lucas Hosseini',
    author_email='matthijs@fb.com',
    license='MIT',
    keywords='search nearest neighbors',

    install_requires=['numpy'],
    packages=['faiss', 'faiss.contrib'],
    package_data={
        'faiss': ['*.so'],
    },

)

@@ -103,245 +103,23 @@
 til%0A
-%0Ahere = os.path.abspath(os.path.dirname(__file__))%0A%0Acheck_fpath = os.path.join(%22_swigfaiss.so%22)%0Aif not os.path.exists(check_fpath):%0A    print(%22Could not find %7B%7D%22.format(check_fpath))%0A    print(%22Have you run %60make%60 and %60make -C python%60?%22)
+import platform
 %0A%0A# 
@@ -407,24 +407,140 @@
 gfaiss.py%22)%0A
+if platform.system() == 'Windows':%0A    shutil.copyfile(%22Release/_swigfaiss.pyd%22, %22faiss/_swigfaiss.pyd%22)%0A%0Aelse:%0A    
 shutil.copyf
@@ -587,13 +587,21 @@
 o%22)%0A
+    
 try:%0A
+    
     
@@ -664,16 +664,20 @@
 x2.py%22)%0A
+    
     shut
@@ -742,16 +742,20 @@
 o%22)%0A
+    
 except:%0A
     
@@ -750,16 +750,20 @@
 except:%0A
+    
     pass
@@ -1740,16 +1740,25 @@
  %5B'*.so'
+, '*.pyd'
 %5D,%0A    %7D

Fix setup.py for Windows. (#1365)