Skip to content

Commit

Permalink
BLD: Build zipline conda package from source
Browse files Browse the repository at this point in the history
  • Loading branch information
richafrank committed Dec 31, 2015
1 parent 7a6ba4f commit 9896c3c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 25 deletions.
33 changes: 21 additions & 12 deletions conda/zipline/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
{% set data = load_setuptools() %}

package:
name: zipline
version: 0.8.3
version: {{ environ.get('GIT_DESCRIBE_TAG', '')}}

build:
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
{% if environ.get('GIT_DESCRIBE_NUMBER', '0') == '0' %}string: py{{ environ.get('PY_VER').replace('.', '') }}_0
{% else %}string: py{{ environ.get('PY_VER').replace('.', '') }}_{{ environ.get('GIT_BUILD_STR', 'GIT_STUB') }}{% endif %}


source:
fn: zipline-0.8.3.tar.gz
url: https://pypi.python.org/packages/source/z/zipline/zipline-0.8.3.tar.gz
md5: 042ffcee614d2279add9a1bfd27a33cf
git_url: ../../

requirements:
build:
- python
- setuptools
- cython
- cython ==0.22.1
- numpy ==1.9.2
run:
- python
- pytz
- requests
- numpy
- pandas
- scipy
- matplotlib
- logbook
{% for req in data.get('install_requires', []) -%}
- {{req}}
{% endfor %}

test:
{# When we include the tests module in the zipline package, we can use this:
requires:
{% for req in data.get('extras_require', {}).get('dev', []) -%}
- {{req}}
{% endfor %}
#}
# Python imports
imports:
- zipline
Expand Down
42 changes: 29 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import os
import re
import sys
from operator import lt, gt, eq, le, ge
Expand Down Expand Up @@ -133,7 +133,16 @@ def _with_bounds(req):
return ''.join(with_bounds)


def read_requirements(path, strict_bounds):
def _conda_format(req):
return re.sub(
'([^=<>]+)([=<>]{1,2})',
lambda m: '%s %s' % (m.group(1).lower(), m.group(2)),
req,
1,
)


def read_requirements(path, strict_bounds, conda_format=False):
"""
Read a requirements.txt file, expressed as a path relative to Zipline root.
Expand All @@ -144,20 +153,25 @@ def read_requirements(path, strict_bounds):
with open(real_path) as f:
reqs = _filter_requirements(f.readlines())

if strict_bounds:
return list(reqs)
else:
return list(map(_with_bounds, reqs))
if not strict_bounds:
reqs = map(_with_bounds, reqs)

if conda_format:
reqs = map(_conda_format, reqs)

return list(reqs)


def install_requires(strict_bounds=False):
def install_requires(strict_bounds=False, conda_format=False):
return read_requirements('etc/requirements.txt',
strict_bounds=strict_bounds)
strict_bounds=strict_bounds,
conda_format=conda_format)


def extras_requires():
def extras_requires(conda_format=False):
dev_reqs = read_requirements('etc/requirements_dev.txt',
strict_bounds=True)
strict_bounds=True,
conda_format=conda_format)
talib_reqs = ['TA-Lib==0.4.9']
return {
'dev': dev_reqs,
Expand All @@ -171,7 +185,7 @@ def module_requirements(requirements_path, module_names):
found = set()
module_lines = []
parser = re.compile("([^=<>]+)([<=>]{1,2})(.*)")
for line in read_requirements(requirements_path, strict_bounds=False):
for line in read_requirements(requirements_path, strict_bounds=True):
match = parser.match(line)
if match is None:
raise AssertionError("Could not parse requirement: '%s'" % line)
Expand Down Expand Up @@ -214,6 +228,7 @@ def pre_setup():

pre_setup()

conda_build = os.path.basename(sys.argv[0]) == 'conda-build'

setup(
name='zipline',
Expand Down Expand Up @@ -241,7 +256,8 @@ def pre_setup():
'Topic :: Scientific/Engineering :: Information Analysis',
'Topic :: System :: Distributed Computing',
],
install_requires=install_requires(),
extras_require=extras_requires(),
install_requires=install_requires(strict_bounds=conda_build,
conda_format=conda_build),
extras_require=extras_requires(conda_format=conda_build),
url="http://zipline.io",
)

0 comments on commit 9896c3c

Please sign in to comment.