annoy
/
setup.py
109 строк · 3.9 Кб
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Copyright (c) 2013 Spotify AB
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may not
7# use this file except in compliance with the License. You may obtain a copy of
8# the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations under
16# the License.
17
18from setuptools import setup, Extension19import codecs20import os21import platform22import sys23
24readme_note = """\25.. note::
26
27For the latest source, discussion, etc, please visit the
28`GitHub repository <https://github.com/spotify/annoy>`_\n\n
29
30.. image:: https://img.shields.io/github/stars/spotify/annoy.svg
31:target: https://github.com/spotify/annoy
32
33"""
34
35with codecs.open('README.rst', encoding='utf-8') as fobj:36long_description = readme_note + fobj.read()37
38# Various platform-dependent extras
39extra_compile_args = ['-D_CRT_SECURE_NO_WARNINGS', '-fpermissive']40extra_link_args = []41if platform.machine() == 'ppc64le':42extra_compile_args += ['-mcpu=native',]43
44if platform.machine() == 'x86_64':45# do not apply march on Intel Darwin46if platform.system() != 'Darwin':47# Not all CPUs have march as a tuning parameter48extra_compile_args += ['-march=native',]49
50if os.name != 'nt':51extra_compile_args += ['-O3', '-ffast-math', '-fno-associative-math']52
53# Add multithreaded build flag for all platforms using Python 3 and
54# for non-Windows Python 2 platforms
55python_major_version = sys.version_info[0]56if python_major_version == 3 or (python_major_version == 2 and os.name != 'nt'):57extra_compile_args += ['-DANNOYLIB_MULTITHREADED_BUILD']58
59if os.name != 'nt':60extra_compile_args += ['-std=c++14']61
62# #349: something with OS X Mojave causes libstd not to be found
63if platform.system() == 'Darwin':64extra_compile_args += ['-mmacosx-version-min=10.12']65extra_link_args += ['-stdlib=libc++', '-mmacosx-version-min=10.12']66
67# Manual configuration, you're on your own here.
68manual_compiler_args = os.environ.get('ANNOY_COMPILER_ARGS', None)69if manual_compiler_args:70extra_compile_args = manual_compiler_args.split(',')71manual_linker_args = os.environ.get('ANNOY_LINKER_ARGS', None)72if manual_linker_args:73extra_link_args = manual_linker_args.split(',')74
75setup(name='annoy',76version='1.17.3',77description='Approximate Nearest Neighbors in C++/Python optimized for memory usage and loading/saving to disk.',78packages=['annoy'],79package_data={'annoy': ['__init__.pyi', 'py.typed']},80ext_modules=[81Extension(82'annoy.annoylib', ['src/annoymodule.cc'],83depends=['src/annoylib.h', 'src/kissrandom.h', 'src/mman.h'],84extra_compile_args=extra_compile_args,85extra_link_args=extra_link_args,86)87],88long_description=long_description,89author='Erik Bernhardsson',90author_email='mail@erikbern.com',91url='https://github.com/spotify/annoy',92license='Apache License 2.0',93classifiers=[94'Development Status :: 5 - Production/Stable',95'Programming Language :: Python',96'Programming Language :: Python :: 2.6',97'Programming Language :: Python :: 2.7',98'Programming Language :: Python :: 3.3',99'Programming Language :: Python :: 3.4',100'Programming Language :: Python :: 3.5',101'Programming Language :: Python :: 3.6',102'Programming Language :: Python :: 3.7',103'Programming Language :: Python :: 3.8',104'Programming Language :: Python :: 3.9',105],106keywords='nns, approximate nearest neighbor search',107setup_requires=['nose>=1.0'],108tests_require=['numpy', 'h5py']109)110