Skip to content

Commit

Permalink
Add python3.7 support (#2211)
Browse files Browse the repository at this point in the history
* init support for py37

* Add CI jobs for 3.7

* workaround for py37 & travis

* revert back pyemd (finger cross)

* temporary supress deprecation from numpy
  • Loading branch information
menshikh-iv authored Oct 4, 2018
1 parent 367bdbd commit 6a97463
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@ matrix:
- python: '3.6'
env: TOXENV="py36-linux"

- python: '3.7'
env:
- TOXENV="py37-linux"
- BOTO_CONFIG="/dev/null"
dist: xenial
sudo: true


install: pip install tox
script: tox -vv
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ environment:
PYTHON_ARCH: "64"
TOXENV: "py36-win"

- PYTHON: "C:\\Python37-x64"
PYTHON_VERSION: "3.7.0"
PYTHON_ARCH: "64"
TOXENV: "py37-win"

init:
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"
- "ECHO \"%APPVEYOR_SCHEDULED_BUILD%\""
Expand Down
4 changes: 3 additions & 1 deletion gensim/models/utils_any2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ def add_word(word, weights):
if ch != b'\n': # ignore newlines in front of words (some binary files have)
word.append(ch)
word = utils.to_unicode(b''.join(word), encoding=encoding, errors=unicode_errors)
weights = fromstring(fin.read(binary_len), dtype=REAL).astype(datatype)
with utils.ignore_deprecation_warning():
# TODO use frombuffer or something similar
weights = fromstring(fin.read(binary_len), dtype=REAL).astype(datatype)
add_word(word, weights)
else:
for line_no in xrange(vocab_size):
Expand Down
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,14 @@ def finalize_options(self):
'Morfessor==2.0.2a4',
]

linux_testenv = win_testenv + [
'annoy',
'tensorflow <= 1.3.0',
'keras >= 2.0.4, <= 2.1.4',
]
linux_testenv = win_testenv[:]

if sys.version_info < (3, 7):
linux_testenv.extend([
'tensorflow <= 1.3.0',
'keras >= 2.0.4, <= 2.1.4',
'annoy',
])

ext_modules = [
Extension('gensim.models.word2vec_inner',
Expand Down
15 changes: 13 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 2.0
envlist = {py27,py35,py36}-{win,linux}, flake8, docs, docs-upload, download-wheels, upload-wheels, test-pypi
envlist = {py27,py35,py36,py37}-{win,linux}, flake8, docs, docs-upload, download-wheels, upload-wheels, test-pypi
skipsdist = True
platform = linux: linux
win: win64
Expand All @@ -23,9 +23,19 @@ addopts = -rfxEXs --durations=20 --showlocals --reruns 3 --reruns-delay 1
recreate = True

; rackcdn host only for windows wheels (numpy, scipy)
install_command = pip install --timeout=60 --trusted-host 28daf2247a33ed269873-7b1aad3fab3cc330e1fd9d109892382a.r6.cf2.rackcdn.com --find-links http://28daf2247a33ed269873-7b1aad3fab3cc330e1fd9d109892382a.r6.cf2.rackcdn.com/ {opts} numpy==1.11.3 scipy==0.18.1 {packages}
install_command = pip install --timeout=60 --trusted-host 28daf2247a33ed269873-7b1aad3fab3cc330e1fd9d109892382a.r6.cf2.rackcdn.com --find-links http://28daf2247a33ed269873-7b1aad3fab3cc330e1fd9d109892382a.r6.cf2.rackcdn.com/ {env:TOX_PIP_OPTS:} {opts} {packages}

deps =
py37: numpy==1.14.5
py37: scipy==1.1.0

py27: numpy==1.11.3
py27: scipy==0.18.1
py35: numpy==1.11.3
py35: scipy==0.18.1
py36: numpy==1.11.3
py36: scipy==0.18.1

linux: .[test]
win: .[test-win]

Expand All @@ -36,6 +46,7 @@ setenv =
DTM_PATH={env:DTM_PATH:}
MALLET_HOME={env:MALLET_HOME:}
SKIP_NETWORK_TESTS={env:SKIP_NETWORK_TESTS:}
BOTO_CONFIG={env:BOTO_CONFIG:}
PYTHONHASHSEED=1

commands =
Expand Down

0 comments on commit 6a97463

Please sign in to comment.