From 74cf86ba2b7c77f23a27f1a9dd29a70acbb719d4 Mon Sep 17 00:00:00 2001 From: Kushal Chakrabarti Date: Tue, 19 Jan 2016 12:39:58 -0800 Subject: [PATCH 1/6] Fixed missing numpy headers in OS X build. --- setup.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 301e4c7..c604755 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ from Cython.Build import cythonize from distutils.core import setup from distutils.extension import Extension +import numpy as np import os.path import re import sys @@ -50,12 +51,10 @@ def readme(): requires=["sklearn"], ) -# For these actions, NumPy is not required. We want them to succeed without, -# for example when pip is used to install seqlearn without NumPy present. -NO_NUMPY_ACTIONS = ('--help-commands', 'egg_info', '--version', 'clean') -if not ('--help' in sys.argv[1:] - or len(sys.argv) > 1 and sys.argv[1] in NO_NUMPY_ACTIONS): - import numpy - setup_options['include_dirs'] = [numpy.get_include()] +# NOTE: See https://github.com/hmmlearn/hmmlearn/issues/43. However, +# cythonize doesn't pass include_path to Extension either, so we're +# hacking it directly. +for em in setup_options["ext_modules"]: + em.include_dirs = [np.get_include()] setup(**setup_options) From 5bad69728dc78670380b4b68678172495e273368 Mon Sep 17 00:00:00 2001 From: Kushal Chakrabarti Date: Wed, 27 Jan 2016 21:53:59 -0800 Subject: [PATCH 2/6] Possible buildfix for Heroku --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c604755..33d608a 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def readme(): "seqlearn/_decode/viterbi.pyx", "seqlearn/_utils/ctrans.pyx", "seqlearn/_utils/safeadd.pyx"]), - requires=["sklearn"], + requires=["sklearn", "Cython"], ) # NOTE: See https://github.com/hmmlearn/hmmlearn/issues/43. However, From 72984381a415be922c56e25e5dc8b5cc4a6a45a1 Mon Sep 17 00:00:00 2001 From: Kushal Chakrabarti Date: Wed, 27 Jan 2016 22:15:10 -0800 Subject: [PATCH 3/6] Hacked Cython dependency for Heroku PIP --- setup.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 33d608a..ce9ff2f 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -from Cython.Build import cythonize from distutils.core import setup from distutils.extension import Extension import numpy as np @@ -44,10 +43,10 @@ def readme(): "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", ], - ext_modules=cythonize(["seqlearn/_decode/bestfirst.pyx", - "seqlearn/_decode/viterbi.pyx", - "seqlearn/_utils/ctrans.pyx", - "seqlearn/_utils/safeadd.pyx"]), + ext_modules=["seqlearn/_decode/bestfirst.pyx", + "seqlearn/_decode/viterbi.pyx", + "seqlearn/_utils/ctrans.pyx", + "seqlearn/_utils/safeadd.pyx"], requires=["sklearn", "Cython"], ) @@ -56,5 +55,22 @@ def readme(): # hacking it directly. for em in setup_options["ext_modules"]: em.include_dirs = [np.get_include()] + +# FIXME: Cython doesn't exist on Heroku before pip runs. And this depends +# on Cython. But we can't declare that we depend on Cython because we try +# to import Cython before it exists and promptly exception out. So, we declare +# the dependency above (when pip presumably first loads it to check dependencies) +# and then backtrack and add back the cythonize call after Cython is installed by +# pip and it calls us again to actually install us. This is a glorious, GLORIOUS +# hack but fuck it. It's 01-27 and we're launching in 4 days. JFDI, bitch. +# +# -@kushalc (2016-01-27) +# +# P.S. I hope some interns get a laugh out of this someday. +try: + from Cython.Build import cythonize + setup_options["ext_modules"] = cythonize(setup_options["ext_modules"]) +except ImportError: + pass setup(**setup_options) From 9311034fe44e97db971f7d5105fd2622f644002c Mon Sep 17 00:00:00 2001 From: Kushal Chakrabarti Date: Wed, 27 Jan 2016 22:19:20 -0800 Subject: [PATCH 4/6] Hacked numpy headers for Heroku PIP --- setup.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index ce9ff2f..1539045 100644 --- a/setup.py +++ b/setup.py @@ -50,12 +50,6 @@ def readme(): requires=["sklearn", "Cython"], ) -# NOTE: See https://github.com/hmmlearn/hmmlearn/issues/43. However, -# cythonize doesn't pass include_path to Extension either, so we're -# hacking it directly. -for em in setup_options["ext_modules"]: - em.include_dirs = [np.get_include()] - # FIXME: Cython doesn't exist on Heroku before pip runs. And this depends # on Cython. But we can't declare that we depend on Cython because we try # to import Cython before it exists and promptly exception out. So, we declare @@ -70,6 +64,16 @@ def readme(): try: from Cython.Build import cythonize setup_options["ext_modules"] = cythonize(setup_options["ext_modules"]) + + # NOTE: See https://github.com/hmmlearn/hmmlearn/issues/43. However, + # cythonize doesn't pass include_path to Extension either, so we're + # hacking it directly. + # + # NOTE: This needs to be done after the above cythonize call since + # they're just strings otherwise. + for em in setup_options["ext_modules"]: + em.include_dirs = [np.get_include()] + except ImportError: pass From 96e75e12b11479fdb55e8a42f5b6bd26878fc303 Mon Sep 17 00:00:00 2001 From: Kushal Chakrabarti Date: Wed, 27 Jan 2016 22:35:39 -0800 Subject: [PATCH 5/6] Fixed requires => install_requires misnaming bug. --- setup.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 1539045..81ddb1e 100644 --- a/setup.py +++ b/setup.py @@ -43,11 +43,7 @@ def readme(): "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", ], - ext_modules=["seqlearn/_decode/bestfirst.pyx", - "seqlearn/_decode/viterbi.pyx", - "seqlearn/_utils/ctrans.pyx", - "seqlearn/_utils/safeadd.pyx"], - requires=["sklearn", "Cython"], + install_requires=["sklearn", "Cython"], ) # FIXME: Cython doesn't exist on Heroku before pip runs. And this depends @@ -63,7 +59,10 @@ def readme(): # P.S. I hope some interns get a laugh out of this someday. try: from Cython.Build import cythonize - setup_options["ext_modules"] = cythonize(setup_options["ext_modules"]) + setup_options["ext_modules"] = cythonize(["seqlearn/_decode/bestfirst.pyx", + "seqlearn/_decode/viterbi.pyx", + "seqlearn/_utils/ctrans.pyx", + "seqlearn/_utils/safeadd.pyx"]) # NOTE: See https://github.com/hmmlearn/hmmlearn/issues/43. However, # cythonize doesn't pass include_path to Extension either, so we're @@ -73,7 +72,7 @@ def readme(): # they're just strings otherwise. for em in setup_options["ext_modules"]: em.include_dirs = [np.get_include()] - + except ImportError: pass From 50d3bf9b9ebc7abc298cc4ed0cb6b53320065231 Mon Sep 17 00:00:00 2001 From: Kushal Chakrabarti Date: Thu, 28 Jan 2016 20:27:25 -0800 Subject: [PATCH 6/6] Switched to setup_requires() for setup --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 81ddb1e..e68293a 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def readme(): "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", ], - install_requires=["sklearn", "Cython"], + setup_requires=["sklearn", "Cython"], ) # FIXME: Cython doesn't exist on Heroku before pip runs. And this depends