From cf3beb25a77dabe71fe7647122c7338187ec65d1 Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Mon, 9 Nov 2015 20:52:57 -0500 Subject: [PATCH 1/4] BLD: Don't pin install requirements to exact versions Instead, use those versions as lower bounds, so zipline will work with packages that require other versions. --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2015fdb3..8b07748f 100644 --- a/setup.py +++ b/setup.py @@ -118,13 +118,20 @@ def _filter_requirements(lines_iter): yield requirement -def read_requirements(path): +def read_requirements(path, convert_eq_to_lte=True): """ Read a requirements.txt file, expressed as a path relative to Zipline root. + + Returns requirements with the pinned versions as lower bounds. """ real_path = join(dirname(abspath(__file__)), path) with open(real_path) as f: - return list(_filter_requirements(f.readlines())) + reqs = _filter_requirements(f.readlines()) + + if not convert_eq_to_lte: + return list(reqs) + else: + return [req.replace('==', '>=') for req in reqs] def install_requires(): From be8cf93a36878cdb0158c5708807d13af44350e2 Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Mon, 9 Nov 2015 21:30:58 -0500 Subject: [PATCH 2/4] BLD: Use strict bounds with requirements_dev --- setup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 8b07748f..21c0d347 100644 --- a/setup.py +++ b/setup.py @@ -118,17 +118,18 @@ def _filter_requirements(lines_iter): yield requirement -def read_requirements(path, convert_eq_to_lte=True): +def read_requirements(path, strict_bounds=False): """ Read a requirements.txt file, expressed as a path relative to Zipline root. - Returns requirements with the pinned versions as lower bounds. + Returns requirements with the pinned versions as lower bounds + if `strict_bounds` is falsey. """ real_path = join(dirname(abspath(__file__)), path) with open(real_path) as f: reqs = _filter_requirements(f.readlines()) - if not convert_eq_to_lte: + if strict_bounds: return list(reqs) else: return [req.replace('==', '>=') for req in reqs] @@ -139,7 +140,8 @@ def install_requires(): def extras_requires(): - dev_reqs = read_requirements('etc/requirements_dev.txt') + dev_reqs = read_requirements('etc/requirements_dev.txt', + strict_bounds=True) talib_reqs = ['TA-Lib==0.4.9'] return { 'dev': dev_reqs, From 785966422624602f72194ae597c6897ec38927a2 Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Mon, 9 Nov 2015 22:10:12 -0500 Subject: [PATCH 3/4] BLD: Use strict bounds install for travis with explicit requirements files Need to build extension modules explicitly now that we're not installing zipline Adds support for upper bounds, since we thought newer bcolz didn't work. It just needed newer setuptools. --- .travis.yml | 4 +++- setup.py | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 23df7e87..4d70f7d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,10 @@ install: - source activate testenv - conda install --yes -c https://conda.binstar.org/Quantopian numpy=$NUMPY_VERSION pandas=$PANDAS_VERSION scipy==$SCIPY_VERSION matplotlib Cython patsy statsmodels tornado pyparsing xlrd mock pytz requests six dateutil ta-lib logbook - pip install --upgrade pip coverage - - pip install -e .[dev] + - pip install -r etc/requirements.txt + - pip install -r etc/requirements_dev.txt - pip install -r etc/requirements_blaze.txt + - python setup.py build_ext --inplace before_script: - pip freeze | sort - "flake8 zipline tests" diff --git a/setup.py b/setup.py index 21c0d347..7c6db032 100644 --- a/setup.py +++ b/setup.py @@ -118,7 +118,24 @@ def _filter_requirements(lines_iter): yield requirement -def read_requirements(path, strict_bounds=False): +REQ_UPPER_BOUNDS = { +} + + +def _with_bounds(req): + try: + req, lower = req.split('==') + except ValueError: + return req + else: + with_bounds = [req, '>=', lower] + upper = REQ_UPPER_BOUNDS.get(req) + if upper: + with_bounds.extend([',', upper]) + return ''.join(with_bounds) + + +def read_requirements(path, strict_bounds): """ Read a requirements.txt file, expressed as a path relative to Zipline root. @@ -132,11 +149,12 @@ def read_requirements(path, strict_bounds=False): if strict_bounds: return list(reqs) else: - return [req.replace('==', '>=') for req in reqs] + return list(map(_with_bounds, reqs)) -def install_requires(): - return read_requirements('etc/requirements.txt') +def install_requires(strict_bounds=False): + return read_requirements('etc/requirements.txt', + strict_bounds=strict_bounds) def extras_requires(): @@ -155,7 +173,7 @@ def module_requirements(requirements_path, module_names): found = set() module_lines = [] parser = re.compile("([^=<>]+)([<=>]{1,2})(.*)") - for line in read_requirements(requirements_path): + for line in read_requirements(requirements_path, strict_bounds=False): match = parser.match(line) if match is None: raise AssertionError("Could not parse requirement: '%s'" % line) From 234ab15be34e352d138f8ec04f279782324e077b Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Tue, 10 Nov 2015 17:58:49 -0500 Subject: [PATCH 4/4] DOC: Updated whatsnew --- docs/source/whatsnew/0.8.4.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/whatsnew/0.8.4.txt b/docs/source/whatsnew/0.8.4.txt index fb2a12dd..92d721ce 100644 --- a/docs/source/whatsnew/0.8.4.txt +++ b/docs/source/whatsnew/0.8.4.txt @@ -43,7 +43,7 @@ None Build ~~~~~ -None +* Makes zipline install requirements more flexible (:issue:`825`). Documentation ~~~~~~~~~~~~~