Skip to content

Commit

Permalink
re-adding windows support.
Browse files Browse the repository at this point in the history
I wish this could be preserved automatically but it seems to need manually
re-adding everytime we regenerate the C file.
  • Loading branch information
mrjbq7 committed Feb 6, 2017
1 parent 1b6ae4c commit 88a5d4f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions talib/_ta_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,14 @@ static CYTHON_INLINE float __PYX_NAN() {

#define __PYX_HAVE__talib___ta_lib
#define __PYX_HAVE_API__talib___ta_lib
#if defined(WIN32) || defined(MS_WINDOWS)
#include "ta-libc.h"
#else
#include "ta-lib/ta_defs.h"
#include "ta-lib/ta_common.h"
#include "ta-lib/ta_abstract.h"
#include "ta-lib/ta_func.h"
#endif
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
Expand Down

4 comments on commit 88a5d4f

@mckelvin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between the two? Because of the separator in Windows is \ ?

Another solution is:

diff --git a/setup.py b/setup.py
index fc10846..76c91d4 100644
--- a/setup.py
+++ b/setup.py
@@ -27,13 +27,15 @@ for prefix in ['darwin', 'linux', 'bsd', 'sunos']:
     if prefix in sys.platform:
         platform_supported = True
         include_dirs = [
-            '/usr/include',
-            '/usr/local/include',
-            '/opt/include',
-            '/opt/local/include',
+            '/usr/include/ta-lib',
+            '/usr/local/include/ta-lib',
+            '/opt/include/ta-lib',
+            '/opt/local/include/ta-lib',
         ]
         if 'TA_INCLUDE_PATH' in os.environ:
-            include_dirs.append(os.environ['TA_INCLUDE_PATH'])
+            include_dirs.append(
+                os.path.join(os.environ['TA_INCLUDE_PATH'], "ta-lib")
+            )
         lib_talib_dirs = [
             '/usr/lib',
             '/usr/local/lib',
@@ -49,7 +51,7 @@ for prefix in ['darwin', 'linux', 'bsd', 'sunos']:
 if sys.platform == "win32":
     platform_supported = True
     lib_talib_name = 'ta_libc_cdr'
-    include_dirs = [r"c:\ta-lib\c\include"]
+    include_dirs = [r"c:\ta-lib\c\include\ta-lib"]
     lib_talib_dirs = [r"c:\ta-lib\c\lib"]
 
 if not platform_supported:
diff --git a/talib/_ta_lib.pxd b/talib/_ta_lib.pxd
index 60d43a3..346bd6f 100644
--- a/talib/_ta_lib.pxd
+++ b/talib/_ta_lib.pxd
@@ -1,5 +1,5 @@
 
-cdef extern from "ta-lib/ta_defs.h":
+cdef extern from "ta_defs.h":
     ctypedef int TA_RetCode
 
     ctypedef int TA_RetCode
@@ -84,7 +84,7 @@ cdef extern from "ta-lib/ta_defs.h":
     TA_CandleSettingType TA_Equal = 10
     TA_CandleSettingType TA_AllCandleSettings = 11
 
-cdef extern from "ta-lib/ta_common.h":
+cdef extern from "ta_common.h":
     char *TA_GetVersionString()
     char *TA_GetVersionMajor()
     char *TA_GetVersionMinor()
@@ -109,7 +109,7 @@ cdef extern from "ta-lib/ta_common.h":
     TA_RetCode TA_Initialize()
     TA_RetCode TA_Shutdown()
 
-cdef extern from "ta-lib/ta_abstract.h":
+cdef extern from "ta_abstract.h":
 
     TA_RetCode TA_GroupTableAlloc(TA_StringTable **table)
     TA_RetCode TA_GroupTableFree(TA_StringTable *table)
@@ -192,7 +192,7 @@ cdef extern from "ta-lib/ta_abstract.h":
 
     char* TA_FunctionDescriptionXML()
 
-cdef extern from "ta-lib/ta_func.h":
+cdef extern from "ta_func.h":
     TA_RetCode TA_ACOS(int startIdx, int endIdx, const double inReal[], int *outBegIdx, int *outNBElement, double outReal[])
     int TA_ACOS_Lookback()
     TA_RetCode TA_AD(int startIdx, int endIdx, const double inHigh[], const double inLow[], const double inClose[], const double inVolume[], int *outBegIdx, int *outNBElement, double outReal[])

In this way, we may not need to modify the generated file manually anymore.

@mckelvin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch mentioned above will also benefits #135 since we don't need the workaround symbolic link directory vendor/include/ta-lib any more, which (as a unix symbolic link) is not supported on Windows.

@mckelvin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrjbq7 BTW, why not remove the generated .c file from the git repository if we don't need to modify manually after the file is generated by Cython? The file is quite large, ~10 MB !

Cython, as a setup requirements should be added to setup_requires and it will be installed automatically during the setup procedure: https://github.com/douban/libmc/blob/76c9bef/setup.py#L94

@mrjbq7
Copy link
Collaborator Author

@mrjbq7 mrjbq7 commented on 88a5d4f Feb 6, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.