Fun fun times writing setup.py

This commit is contained in:
Stephen Diehl
2012-05-26 18:24:48 -04:00
parent 817166ba03
commit 318d7ba678
6 changed files with 146 additions and 47 deletions
+8
View File
@@ -35,6 +35,14 @@ develop-eggs
coverage.xml
nosetests.xml
# C Extensions
*.o
*.so
*.out
# git add -f if needed
*.c
# Vim
*.swp
*.swo
+1 -1
View File
@@ -30,7 +30,7 @@ To run tests::
$ nosetests
To build documentation::
$ paver apidocs html
# outputs to docs/_build/html
+8 -3
View File
@@ -1,7 +1,12 @@
#zeromq related
pyzmq==2.1.11
gevent-zeromq==0.2.2
msgpack-python==0.1.12
humanhash==0.0.1
ujson==1.18
iso8601==0.1.4
# ZeroMQ
pyzmq==2.1.11
gevent-zeromq==0.2.2
# Packaging
distribute==0.6.27
setuptools==0.6c11
+123 -40
View File
@@ -1,22 +1,56 @@
import os, sys
import time
import os
import re
import platform
import sys
import glob
import time
from distutils.dep_util import newer
#from distutils.extension import Extension
from setuptools.extension import Extension
from paver.easy import options, Bunch, task, needs, path, info
from paver.setuputils import install_distutils_tasks, \
find_packages, find_package_data
from subprocess import call
install_distutils_tasks()
from paver.easy import *
from paver.doctools import *
from paver.setuputils import *
# =========
# Compilers
# =========
from paved import *
from paved.util import *
from paved.pycheck import *
try:
from Cython.Compiler.Main import compile
from Cython.Distutils import build_ext
have_cython = True
except ImportError:
have_cython = False
#add setuputils tasks
paver.setuputils.install_distutils_tasks()
try:
import numpy as np
have_numpy = True
except:
have_numpy = False
operating_system = platform.system()
# ===================
# 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
@@ -35,39 +69,92 @@ def parse_requirements(file_name):
requirements.append(line)
return requirements
version='dev'
install_requires = parse_requirements('./etc/requirements.txt') + parse_requirements('./etc/requirements_sci.txt')
example = Extension(
"zipline/example", ["zipline/example.pyx"],
include_dirs=[np.get_include()],
)
# ============
# 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
# ========
if have_numpy and have_cython:
cext = [example]
else:
cext = []
options(
sphinx=Bunch(
sphinx = Bunch(
builddir="_build",
sourcedir=""
),
setup = Bunch(name='zipline',
version = version,
classifiers = [],
packages = find_packages(),
package_data = find_package_data("zipline", package="zipline",
only_in_packages=False),
install_requires = install_requires,
tests_require = tests_require,
test_suite = 'nose.collector',
include_package_data = True,
zip_safe = False,
),
setup = Bunch(
name = PACKAGE,
version = VERSION,
packages = find_packages(),
package_data = find_package_data(
SRC_PATH,
package = PACKAGE,
only_in_packages = False
),
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',
],
ext_modules = cext,
cmdclass = {'build_ext': build_ext},
),
)
options.paved.clean.patterns.extend([
#'*.swp', # vim related
#'*.swo', # vim related
'nosetests.xml',
'.coverage',
',coverage',
'*.lprof',
'*.prof',
])
# ============
# C Extensions
# ============
@task
def build_cython():
for fn in glob.glob(os.path.join(SRC_PATH, '*.pyx')):
p = path(fn)
modname = p.splitext()[0].basename()
dest = p.splitext()[0] + '.c'
if newer(p.abspath(), dest.abspath()):
info('cythoning %s to %s'%(p, dest.basename()))
compile(p.abspath(), full_module_name=modname)
@task
@needs(['build_cython', 'setuptools.command.build_ext'])
def build_ext():
pass
# ======
# Tasks
# ======
# Because I'm lazy
stuff_i_want_in_my_debug_shell = [
@@ -75,10 +162,6 @@ stuff_i_want_in_my_debug_shell = [
('zmq', 'zmq', []),
]
# ======
# Tasks
# ======
@task
def coverage():
"""
+6 -3
View File
@@ -193,9 +193,12 @@ class PerformanceTracker(object):
return self.cumulative_performance.to_ndict()
def open(self, context):
sock = context.socket(zmq.PUSH)
sock.connect(self.results_addr)
self.results_socket = sock
if self.results_addr:
sock = context.socket(zmq.PUSH)
sock.connect(self.results_addr)
self.results_socket = sock
else:
LOGGER.warn("Not streaming results because no results socket given")
def publish_to(self, results_addr):
"""
View File