Skip to content

Commit

Permalink
Fix setup.py not installing the fast FIM module for Windows machines (N…
Browse files Browse the repository at this point in the history
…euralEnsemble#213)

* Fixed setup.py to also fetch the pyd files for FIM

* Fixed issue where platform module was not imported

* Added missing line to copy the pyd file

* Moved warning message about not having fim.so/fim.pyd to a less annoying location

* fim.so load failure could also be related to the Python version
  • Loading branch information
mdenker committed Apr 17, 2019
1 parent f2f332f commit 839e25d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
8 changes: 5 additions & 3 deletions elephant/spade.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@
HAVE_FIM = True
except ImportError: # pragma: no cover
HAVE_FIM = False
warnings.warn(
'fim.so not found in elephant/spade_src folder,' +
'you are using the python implementation of fast fca')


def spade(data, binsize, winlen, min_spikes=2, min_occ=2, max_spikes=None,
Expand Down Expand Up @@ -510,6 +507,11 @@ def concepts_mining(data, binsize, winlen, min_spikes=2, min_occ=2,
return mining_results, rel_matrix
# Otherwise use fast_fca python implementation
else:
warnings.warn(
'Optimized C implementation of FCA (fim.so/fim.pyd) not found ' +
'in elephant/spade_src folder, or not compatible with this ' +
'Python version. You are using the pure Python implementation ' +
'of fast fca.')
# Return output
mining_results = _fast_fca(
context,
Expand Down
37 changes: 23 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from setuptools import setup
import os
import sys
import platform
try:
from urllib.request import urlretrieve
except ImportError:
Expand All @@ -19,21 +20,28 @@
# spade specific
is_64bit = sys.maxsize > 2 ** 32
is_python3 = float(sys.version[0:3]) > 2.7

if is_python3:
if is_64bit:
urlretrieve('http://www.borgelt.net/bin64/py3/fim.so',
'elephant/spade_src/fim.so')
else:
urlretrieve('http://www.borgelt.net/bin32/py3/fim.so',
'elephant/spade_src/fim.so')
if platform.uname()[0] == "Windows":
oext = ".pyd"
elif platform.uname()[0] == "Linux":
oext = ".so"
else:
if is_64bit:
urlretrieve('http://www.borgelt.net/bin64/py2/fim.so',
'elephant/spade_src/fim.so')
oext = None

if oext:
if is_python3:
if is_64bit:
urlretrieve('http://www.borgelt.net/bin64/py3/fim' + oext,
'elephant/spade_src/fim' + oext)
else:
urlretrieve('http://www.borgelt.net/bin32/py3/fim' + oext,
'elephant/spade_src/fim' + oext)
else:
urlretrieve('http://www.borgelt.net/bin32/py2/fim.so',
'elephant/spade_src/fim.so')
if is_64bit:
urlretrieve('http://www.borgelt.net/bin64/py2/fim' + oext,
'elephant/spade_src/fim' + oext)
else:
urlretrieve('http://www.borgelt.net/bin32/py2/fim' + oext,
'elephant/spade_src/fim' + oext)

setup(
name="elephant",
Expand All @@ -46,7 +54,8 @@
os.path.join('current_source_density_src', '*.py'),
os.path.join('spade_src', '*.py'),
os.path.join('spade_src', 'LICENSE'),
os.path.join('spade_src', '*.so')
os.path.join('spade_src', '*.so'),
os.path.join('spade_src', '*.pyd')
]},

install_requires=install_requires,
Expand Down

0 comments on commit 839e25d

Please sign in to comment.