From f8c3f10589f6de0c1f788ccf4db970c633b42792 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 3 Oct 2012 15:13:20 -0400 Subject: [PATCH 1/5] Strips out use of pavement in generating our setup.py Working towards making the project distributable on PyPI. Looked at a lot of the projects that we want to emulate, and none use pavement. --- pavement.py | 225 ---------------------------------------------------- setup.py | 43 ++++++++-- 2 files changed, 36 insertions(+), 232 deletions(-) delete mode 100644 pavement.py diff --git a/pavement.py b/pavement.py deleted file mode 100644 index e46e5cc5..00000000 --- a/pavement.py +++ /dev/null @@ -1,225 +0,0 @@ -import os -import re -import sys -import time - -from paver.easy import options, Bunch, task, path -from paver.setuputils import install_distutils_tasks, \ - find_packages, find_package_data -from subprocess import call -install_distutils_tasks() - -# =================== -# Release Information -# =================== - -PACKAGE = 'zipline' -SRC_PATH = 'zipline' - -MAJOR = 0 -MINOR = 1 -MICRO = 0 -DEVELOPMENT = True - -if DEVELOPMENT: - VERSION = '%d.%d.%d dev' % (MAJOR, MINOR, MICRO) -else: - VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) - -# The PyPi page -DESCRIPTION = open('README.md').read() -EMAIL='dev@quantopian.com' - -# =========== -# Setuputils -# =========== - -def parse_requirements(file_name): - requirements = [] - for line in open(file_name, 'r').read().split('\n'): - if re.match(r'(\s*#)|(\s*$)', line): - continue - if re.match(r'\s*-e\s+', line): - requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line)) - elif re.match(r'\s*-f\s+', line): - pass - else: - requirements.append(line) - return requirements - -# ============ -# Dependencies -# ============ - -install_requires = ( - parse_requirements('./etc/requirements.txt') + - parse_requirements('./etc/requirements_sci.txt') -) -tests_require = install_requires + parse_requirements('./etc/requirements_dev.txt') - -# ======== -# seutp.py -# ======== - -options( - sphinx = Bunch( - builddir="_build", - sourcedir="" - ), - setup = Bunch( - name = PACKAGE, - version = VERSION, - packages = find_packages(), - package_data = find_package_data( - SRC_PATH, - package = PACKAGE, - only_in_packages = False - ), - long_description = DESCRIPTION, - install_requires = install_requires, - tests_require = tests_require, - test_suite = 'nose.collector', - include_package_data = True, - zip_safe = False, - classifiers = [ - 'Development Status :: 2 - Pre-Alpha', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: C', - 'Programming Language :: Cython', - 'Operating System :: OS Independent', - 'Intended Audience :: Science/Research', - 'Topic :: Office/Business :: Financial', - 'Topic :: Scientific/Engineering :: Information Analysis', - 'Topic :: System :: Distributed Computing', - ], - entry_points = { - 'console_scripts': [ - 'zipline = zipline.core.interpreter:main', - ] - }, - ), -) - -# ====== -# Tasks -# ====== - -# Because I'm lazy -stuff_i_want_in_my_debug_shell = [ - ('qutil', 'zipline.util', []), -] - -@task -def coverage(): - """ - Run the devsever under the coverage reporter, generate the - coverage report. - """ - call('nosetests zipline', shell=True) - call('coverage html', shell=True) - call('chromium %s/cover/index.html' % (os.path.abspath(".")), shell=True) - -@task -def profile(): - """ - Runtime profiling using cProfile, use pStats to find heavy - calls. Or use python -m pstats to get more granular - statistics about runtimes. - """ - try: - call('python -m cProfile -o zipline.prof qexec/web/devserver.py --hostsettings', shell=True) - except KeyboardInterrupt: - pass - import pstats - time.sleep(1) # wait for disk io - - p = pstats.Stats('zipline.prof') - # Print the hundred heaviest function calls - p.sort_stats('time').print_stats(100) - -@task -def lineprofile(): - """ - Line by line profiler. Find hotspots in your code using the - @profile decorator . - """ - path('devserver.py.lprof').remove() - try: - call('kernprof.py -l qexec/web/devserver.py --hostsettings', shell=True) - except KeyboardInterrupt: - pass - time.sleep(1) # wait for disk io - call('python -m line_profiler devserver.py.lprof', shell=True) - -def magic_shell(): - sys.path.append(path()) - imported_objects = {} - for mod in find_packages(): - imported_objects[mod] = __import__(mod) - - for name, mod, defs in stuff_i_want_in_my_debug_shell: - imported_objects[name] = __import__(mod, globals(), locals(), defs) - - return imported_objects - -@task -def shell(): - """ - Run a bpython shell with all your desired modules right at - your fingertips. - """ - from bpython import embed - embed(magic_shell()) - -@task -def ishell(): - """ - Run a ipython shell with all your desired modules right at - your fingertips. - """ - from IPython.frontend.terminal.embed import InteractiveShellEmbed - shell = InteractiveShellEmbed(user_ns=magic_shell()) - #shell.extensiosn = ['line_profiler',] - shell() - -@task -def findbugs(): - """ - Google's bug prediction algorithm. Algorithmically find - hotspots in your code where bugs are likely to occur based on - their git history. - """ - call('bugspot.py zipline', shell=True) - -@task -def findtodos(): - """ - Grep for TODO - """ - call('grep TODO zipline/*/*.py -C 3 ', shell=True) - -@task -def findpdb(): - """ - find references to debugger - """ - call('grep "import pdb; pdb.set_trace()" zipline/*/*.py -C 3 ', shell=True) - -@task -def guppy(): - """ - Guppy heap analyzer - """ - pass - -@task -def apidocs(): - """ - Recursively autogenerate the Sphinx autodoc for the module and - its submodules. - """ - call('rm docs/zipline*.rst', shell=True) - call('sphinx-apidoc -o docs/ zipline', shell=True) diff --git a/setup.py b/setup.py index f3fbd848..341d2d8f 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,38 @@ -import os -from setuptools import setup, find_packages +#!/usr/bin/env python -if os.path.exists("paver-minilib.zip"): - import sys - sys.path.insert(0, "paver-minilib.zip") +from distutils.core import setup -import paver.tasks -paver.tasks.main() +setup(name='zipline', + version='0.1', + description='A backtester for financial algorithms.', + author='Quantopian Inc.', + author_email='opensource@quantopian.com', + packages=['zipline'], + long_description=open('README.md').read(), + license='BSD', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'License :: OSI Approved :: BSD License', + 'Natural Language :: English', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: C', + 'Programming Language :: Cython', + 'Operating System :: OS Independent', + 'Intended Audience :: Science/Research', + 'Topic :: Office/Business :: Financial', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: System :: Distributed Computing', + ], + install_requires=[ + 'msgpack-python', + 'humanhash', + 'iso8601', + 'Logbook', + 'blist', + 'pytz', + 'numpy', + 'Cython', + 'pandas' + ] +) From b6af686392db1bab906dbb4e635a03137677ed9a Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 5 Oct 2012 14:31:51 -0400 Subject: [PATCH 2/5] Updates version to initial release version in setup.py --- setup.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 341d2d8f..54e19430 100644 --- a/setup.py +++ b/setup.py @@ -3,21 +3,19 @@ from distutils.core import setup setup(name='zipline', - version='0.1', + version='0.5.0', description='A backtester for financial algorithms.', author='Quantopian Inc.', author_email='opensource@quantopian.com', packages=['zipline'], long_description=open('README.md').read(), - license='BSD', + license='Apache 2.0', classifiers=[ 'Development Status :: 2 - Pre-Alpha', - 'License :: OSI Approved :: BSD License', + 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: C', - 'Programming Language :: Cython', 'Operating System :: OS Independent', 'Intended Audience :: Science/Research', 'Topic :: Office/Business :: Financial', @@ -26,13 +24,11 @@ setup(name='zipline', ], install_requires=[ 'msgpack-python', - 'humanhash', 'iso8601', 'Logbook', 'blist', 'pytz', 'numpy', - 'Cython', 'pandas' ] ) From fd2d66f53e931c909e9a91093c77cd8645dcd1b3 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 5 Oct 2012 14:58:11 -0400 Subject: [PATCH 3/5] Removes unused library of messagepack. --- etc/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/requirements.txt b/etc/requirements.txt index 196a2588..b123eee4 100644 --- a/etc/requirements.txt +++ b/etc/requirements.txt @@ -1,5 +1,4 @@ msgpack-python==0.1.12 -humanhash==0.0.1 iso8601==0.1.4 # Logging From 013ab86321d149d269ae5d23a3b00b6496272a7d Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 5 Oct 2012 14:58:38 -0400 Subject: [PATCH 4/5] Adds ordered_pip script back in. The pandas dependency on numpy was causing pandas installation to fail. Reviving the ordered_pip script in since it helps explicitly install numpy before pandas. --- etc/ordered_pip.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 etc/ordered_pip.sh diff --git a/etc/ordered_pip.sh b/etc/ordered_pip.sh new file mode 100755 index 00000000..fc1a210b --- /dev/null +++ b/etc/ordered_pip.sh @@ -0,0 +1,11 @@ +#!/bin/bash -e + +a=0 +while read line +do + if [[ -n "$line" && "$line" != \#* ]] ; then + pip install $line + fi + ((a = a + 1)) +done < $1 +echo "$0: Final package count is $a"; From df9fb66736af21922ac6981c563dc5199228b7da Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 5 Oct 2012 15:03:06 -0400 Subject: [PATCH 5/5] Updates development status to Beta. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 54e19430..756a0313 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup(name='zipline', long_description=open('README.md').read(), license='Apache 2.0', classifiers=[ - 'Development Status :: 2 - Pre-Alpha', + 'Development Status :: 4 - Beta', 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', 'Programming Language :: Python',