From 220a71e0c3e2fa544ee5e224f915c8d5e4150993 Mon Sep 17 00:00:00 2001 From: Caleb Donovick Date: Sat, 1 Jun 2019 09:56:00 -0700 Subject: [PATCH] Make dependencies optional --- .travis.yml | 4 +--- hwtypes/__init__.py | 22 +++++++++++++++++----- requirements.txt | 1 - setup.py | 19 ++++++++++++++++--- 4 files changed, 34 insertions(+), 12 deletions(-) delete mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index adf791c..40f6b23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,7 @@ addons: python: - '3.6' install: -- pip install -r requirements.txt -- pip install pytest-cov -- pip install -e . +- pip install -e .[TEST] jobs: include: - stage: test diff --git a/hwtypes/__init__.py b/hwtypes/__init__.py index eca7ea7..34e9ff0 100644 --- a/hwtypes/__init__.py +++ b/hwtypes/__init__.py @@ -1,8 +1,20 @@ -from .bit_vector import * -from .bit_vector_abc import * from .adt import * -from .smt_bit_vector import * -from .z3_bit_vector import * +from .bit_vector_abc import * +from .bit_vector import * from .fp_vector_abc import * -from .fp_vector import * from .modifiers import * + +try: + from .fp_vector import * +except ImportError: + pass + +try: + from .smt_bit_vector import * +except ImportError: + pass + +try: + from .z3_bit_vector import * +except ImportError: + pass diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 4cb8cfb..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pysmt diff --git a/setup.py b/setup.py index a2c7bc6..3bef11b 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,12 @@ with open("README.md", "r") as fh: long_description = fh.read() +FP_requries = ['gmpy2'] +SMT_requires = ['pysmt'] +Z3_requries = ['z3-solver'] +ALL_requires = FP_requries+SMT_requires+Z3_requries +TEST_requires = ALL_requires+['pytest-cov'] + setup( name='hwtypes', url='https://github.com/leonardt/hwtypes', @@ -26,8 +32,15 @@ packages=[ "hwtypes", ], - install_requires=['pysmt', 'z3-solver', 'gmpy2'], + install_requires=[], + extras_require={ + 'FP' : FP_requries, + 'SMT' : SMT_requires, + 'Z3' : Z3_requries, + 'ALL' : ALL_requires, + 'TEST': TEST_requires, + }, long_description=long_description, - long_description_content_type="text/markdown" - # python_requires='>=3.6' + long_description_content_type="text/markdown", + python_requires='>=3.6', )