Skip to content

Commit e6ff9fc

Browse files
committed
remove annoy dependency
Annoy currently doesn't build on windows ("fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory"). Make optional
1 parent 1130a7d commit e6ff9fc

File tree

7 files changed

+21
-12
lines changed

7 files changed

+21
-12
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ before_install:
1515
- pip install -U pip setuptools wheel
1616

1717
install:
18-
- travis_wait travis_retry pip install -r requirements.txt flake8 isort cpplint
18+
- travis_wait travis_retry pip install -r requirements.txt flake8 isort cpplint annoy
1919
- travis_retry python setup.py build install
2020

2121
script:

implicit/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
from . import nearest_neighbours
44
from . import als
55

6-
__version__ = '0.2.4'
6+
__version__ = '0.2.5'
77

88
__all__ = [alternating_least_squares, als, nearest_neighbours, __version__]

implicit/annoy_als.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
approximate neighbours from an ALS Matrix factorization model
33
"""
44
import itertools
5+
import logging
56

6-
import annoy
77
import numpy
88

99
from implicit.als import AlternatingLeastSquares
1010

11+
try:
12+
import annoy
13+
has_annoy = True
14+
except ImportError:
15+
has_annoy = False
16+
logging.warning("Annoy isn't installed")
17+
1118

1219
class MaximumInnerProductIndex(object):
1320
""" This class uses an Annoy Index to return the top related items by

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
scipy>=0.16.0
22
Cython>=0.22.0
3-
annoy>=1.8.0

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from setuptools import Extension, setup
88

99
NAME = 'implicit'
10-
VERSION = '0.2.4'
10+
VERSION = '0.2.5'
1111
SRC_ROOT = 'implicit'
1212

1313
try:

tests/annoy_als_test.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
import unittest
44

5-
from implicit.annoy_als import AnnoyAlternatingLeastSquares
5+
from implicit.annoy_als import AnnoyAlternatingLeastSquares, has_annoy
66

77
from .recommender_base_test import TestRecommenderBaseMixin
88

9-
10-
class AnnoyALSTest(unittest.TestCase, TestRecommenderBaseMixin):
11-
def _get_model(self):
12-
return AnnoyAlternatingLeastSquares(factors=3, regularization=0)
13-
9+
if has_annoy:
10+
# Annoyingly, 'annoy' doesn't seem to build on windows
11+
# don't bother testing with this
12+
class AnnoyALSTest(unittest.TestCase, TestRecommenderBaseMixin):
13+
def _get_model(self):
14+
return AnnoyAlternatingLeastSquares(factors=3, regularization=0)
1415

1516
if __name__ == "__main__":
1617
unittest.main()

tox.ini

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ envlist = py27, py35, style
33

44
[testenv]
55
commands = {envpython} setup.py test
6-
deps = -rrequirements.txt
6+
deps =
7+
-rrequirements.txt
8+
annoy
79

810
[testenv:style]
911
deps =

0 commit comments

Comments
 (0)