Allow installation of ML free version.

Add an option to the install script, `--no-ml`, that when given will
install Talon without ML support.

Fixes #96
This commit is contained in:
Umair Khan
2016-07-11 16:03:03 +05:00
parent 35645f9ade
commit 07f68815df
3 changed files with 38 additions and 6 deletions

View File

@@ -1,5 +1,3 @@
recursive-include tests *
recursive-include talon *
recursive-exclude tests *.pyc *~
recursive-exclude talon *.pyc *~
include train.data

View File

@@ -1,4 +1,30 @@
from setuptools import setup, find_packages
from setuptools.command.install import install
class InstallCommand(install):
user_options = install.user_options + [
('no-ml', None, "Don't install without Machine Learning modules."),
]
boolean_options = install.boolean_options + ['no-ml']
def initialize_options(self):
install.initialize_options(self)
self.no_ml = None
def finalize_options(self):
install.finalize_options(self)
if self.no_ml:
dist = self.distribution
dist.packages=find_packages(exclude=[
'tests',
'tests.*',
'talon.signature',
'talon.signature.*',
])
for not_required in ['numpy', 'scipy', 'scikit-learn==0.16.1']:
dist.install_requires.remove(not_required)
setup(name='talon',
@@ -10,7 +36,10 @@ setup(name='talon',
author_email='admin@mailgunhq.com',
url='https://github.com/mailgun/talon',
license='APACHE2',
packages=find_packages(exclude=['tests']),
cmdclass={
'install': InstallCommand,
},
packages=find_packages(exclude=['tests', 'tests.*']),
include_package_data=True,
zip_safe=True,
install_requires=[

View File

@@ -1,7 +1,12 @@
from talon.quotations import register_xpath_extensions
try:
from talon import signature
ML_ENABLED = True
except ImportError:
ML_ENABLED = False
def init():
register_xpath_extensions()
if ML_ENABLED:
signature.initialize()