|
1 |
| -# -*- coding: utf-8 -*- |
2 |
| - |
3 |
| -from setuptools import setup |
4 |
| -from setuptools import find_packages |
5 |
| -from distutils.cmd import Command |
6 |
| -from distutils.extension import Extension |
7 |
| -import os |
8 |
| -import sys |
9 |
| -import io |
10 |
| -import subprocess |
11 |
| -import platform |
12 |
| -import numpy as np |
13 |
| -from Cython.Build import cythonize |
14 |
| -import Cython.Compiler.Options |
15 |
| -Cython.Compiler.Options.annotate = True |
16 |
| - |
17 |
| -if "--line_trace" in sys.argv: |
18 |
| - line_trace = True |
19 |
| - print("Build with line trace enabled ...") |
20 |
| - sys.argv.remove("--line_trace") |
21 |
| -else: |
22 |
| - line_trace = False |
23 |
| - |
24 |
| -PACKAGE = "PyFin" |
25 |
| -NAME = "Finance-Python" |
26 |
| -VERSION = "0.6.5" |
27 |
| -DESCRIPTION = "PyFin " + VERSION |
28 |
| -AUTHOR = "cheng li" |
29 |
| -AUTHOR_EMAIL = "wegamekinglc@hotmail.com" |
30 |
| -URL = 'https://github.com/ChinaQuants/Finance-Python' |
31 |
| - |
32 |
| - |
33 |
| -def git_version(): |
34 |
| - from subprocess import Popen, PIPE |
35 |
| - gitproc = Popen(['git', 'rev-parse', 'HEAD'], stdout=PIPE) |
36 |
| - (stdout, _) = gitproc.communicate() |
37 |
| - return stdout.strip() |
38 |
| - |
39 |
| - |
40 |
| -class test(Command): |
41 |
| - description = "test the distribution prior to install" |
42 |
| - |
43 |
| - user_options = [ |
44 |
| - ('test-dir=', None, |
45 |
| - "directory that contains the test definitions"), |
46 |
| - ] |
47 |
| - |
48 |
| - def initialize_options(self): |
49 |
| - pass |
50 |
| - |
51 |
| - def finalize_options(self): |
52 |
| - pass |
53 |
| - |
54 |
| - def run(self): |
55 |
| - if sys.platform == 'win32': |
56 |
| - command = "coverage run PyFin/tests/testSuite.py& coverage report& coverage html" |
57 |
| - else: |
58 |
| - command = "coverage run PyFin/tests/testSuite.py; coverage report; coverage html" |
59 |
| - process = subprocess.Popen(command, shell=True) |
60 |
| - process.wait() |
61 |
| - |
62 |
| - |
63 |
| -class version_build(Command): |
64 |
| - |
65 |
| - description = "test the distribution prior to install" |
66 |
| - |
67 |
| - user_options = [ |
68 |
| - ('test-dir=', None, |
69 |
| - "directory that contains the test definitions"), |
70 |
| - ] |
71 |
| - |
72 |
| - def initialize_options(self): |
73 |
| - pass |
74 |
| - |
75 |
| - def finalize_options(self): |
76 |
| - pass |
77 |
| - |
78 |
| - def run(self): |
79 |
| - git_ver = git_version()[:10] |
80 |
| - configFile = 'PyFin/__init__.py' |
81 |
| - |
82 |
| - file_handle = open(configFile, 'r') |
83 |
| - lines = file_handle.readlines() |
84 |
| - newFiles = [] |
85 |
| - for line in lines: |
86 |
| - if line.startswith('__version__'): |
87 |
| - line = line.split('+')[0].rstrip() |
88 |
| - line = line + " + \"-" + git_ver + "\"\n" |
89 |
| - newFiles.append(line) |
90 |
| - file_handle.close() |
91 |
| - os.remove(configFile) |
92 |
| - file_handle = open(configFile, 'w') |
93 |
| - file_handle.writelines(newFiles) |
94 |
| - file_handle.close() |
95 |
| - |
96 |
| -if sys.version_info > (3, 0, 0): |
97 |
| - requirements = "requirements/py3.txt" |
98 |
| -else: |
99 |
| - requirements = "requirements/py2.txt" |
100 |
| - |
101 |
| - |
102 |
| -ext_modules = [ |
103 |
| - "PyFin/Analysis/SeriesValues.pyx", |
104 |
| - "PyFin/Analysis/transformer.pyx", |
105 |
| - "PyFin/Analysis/SecurityValueHolders.pyx", |
106 |
| - "PyFin/Analysis/CrossSectionValueHolders.pyx", |
107 |
| - "PyFin/Analysis/TechnicalAnalysis/StatefulTechnicalAnalysers.pyx", |
108 |
| - "PyFin/Analysis/TechnicalAnalysis/StatelessTechnicalAnalysers.pyx", |
109 |
| - "PyFin/Math/Accumulators/impl.pyx", |
110 |
| - "PyFin/Math/Accumulators/IAccumulators.pyx", |
111 |
| - "PyFin/Math/Accumulators/StatefulAccumulators.pyx", |
112 |
| - "PyFin/Math/Accumulators/StatelessAccumulators.pyx", |
113 |
| - "PyFin/Math/Distributions/NormalDistribution.pyx", |
114 |
| - "PyFin/Math/Distributions/norm.pyx", |
115 |
| - "PyFin/Math/ErrorFunction.pyx", |
116 |
| - "PyFin/Math/MathConstants.pyx", |
117 |
| - "PyFin/Math/udfs.pyx", |
118 |
| - "PyFin/DateUtilities/Calendar.pyx", |
119 |
| - "PyFin/DateUtilities/Date.pyx", |
120 |
| - "PyFin/DateUtilities/Period.pyx", |
121 |
| - "PyFin/DateUtilities/Schedule.pyx", |
122 |
| - "PyFin/Utilities/Asserts.pyx", |
123 |
| - "PyFin/Utilities/Tools.pyx", |
124 |
| - "PyFin/PricingEngines/BlackFormula.pyx", |
125 |
| - "PyFin/PricingEngines/SabrFormulaImpl.pyx", |
126 |
| - "PyFin/PricingEngines/SVIInterpolationImpl.pyx", |
127 |
| - "PyFin/Enums/TimeUnits.pyx", |
128 |
| - "PyFin/Enums/BizDayConventions.pyx", |
129 |
| - "PyFin/Enums/DateGeneration.pyx", |
130 |
| - "PyFin/Enums/Months.pyx", |
131 |
| - "PyFin/Enums/NormalizingType.pyx", |
132 |
| - "PyFin/Enums/OptionType.pyx", |
133 |
| - "PyFin/Enums/Weekdays.pyx" |
134 |
| -] |
135 |
| - |
136 |
| - |
137 |
| -def generate_extensions(ext_modules, line_trace=False): |
138 |
| - |
139 |
| - extensions = [] |
140 |
| - |
141 |
| - if line_trace: |
142 |
| - print("define cython trace to True ...") |
143 |
| - define_macros = [('CYTHON_TRACE', 1), ('CYTHON_TRACE_NOGIL', 1)] |
144 |
| - else: |
145 |
| - define_macros = [] |
146 |
| - |
147 |
| - for pyxfile in ext_modules: |
148 |
| - ext = Extension(name='.'.join(pyxfile.split('/'))[:-4], |
149 |
| - sources=[pyxfile], |
150 |
| - define_macros=define_macros) |
151 |
| - extensions.append(ext) |
152 |
| - return extensions |
153 |
| - |
154 |
| - |
155 |
| -if platform.system() != "Windows": |
156 |
| - import multiprocessing |
157 |
| - n_cpu = multiprocessing.cpu_count() |
158 |
| -else: |
159 |
| - n_cpu = 0 |
160 |
| - |
161 |
| -ext_modules_settings = cythonize(generate_extensions(ext_modules, line_trace), |
162 |
| - compiler_directives={'embedsignature': True, 'linetrace': line_trace}, |
163 |
| - nthreads=n_cpu) |
164 |
| - |
165 |
| - |
166 |
| -setup( |
167 |
| - name=NAME, |
168 |
| - version=VERSION, |
169 |
| - description=DESCRIPTION, |
170 |
| - author=AUTHOR, |
171 |
| - author_email=AUTHOR_EMAIL, |
172 |
| - url=URL, |
173 |
| - packages=find_packages(), |
174 |
| - include_package_data=False, |
175 |
| - install_requires=io.open(requirements, encoding='utf8').read(), |
176 |
| - classifiers=[], |
177 |
| - cmdclass={"test": test, |
178 |
| - "version_build": version_build}, |
179 |
| - ext_modules=ext_modules_settings, |
180 |
| - include_dirs=[np.get_include()], |
181 |
| -) |
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +from setuptools import setup |
| 4 | +from setuptools import find_packages |
| 5 | +from distutils.cmd import Command |
| 6 | +from distutils.extension import Extension |
| 7 | +import os |
| 8 | +import sys |
| 9 | +import io |
| 10 | +import subprocess |
| 11 | +import platform |
| 12 | +import numpy as np |
| 13 | +from Cython.Build import cythonize |
| 14 | +import Cython.Compiler.Options |
| 15 | +Cython.Compiler.Options.annotate = True |
| 16 | + |
| 17 | +if "--line_trace" in sys.argv: |
| 18 | + line_trace = True |
| 19 | + print("Build with line trace enabled ...") |
| 20 | + sys.argv.remove("--line_trace") |
| 21 | +else: |
| 22 | + line_trace = False |
| 23 | + |
| 24 | +PACKAGE = "PyFin" |
| 25 | +NAME = "Finance-Python" |
| 26 | +VERSION = "0.6.6" |
| 27 | +DESCRIPTION = "PyFin " + VERSION |
| 28 | +AUTHOR = "cheng li" |
| 29 | +AUTHOR_EMAIL = "wegamekinglc@hotmail.com" |
| 30 | +URL = 'https://github.com/ChinaQuants/Finance-Python' |
| 31 | + |
| 32 | + |
| 33 | +def git_version(): |
| 34 | + from subprocess import Popen, PIPE |
| 35 | + gitproc = Popen(['git', 'rev-parse', 'HEAD'], stdout=PIPE) |
| 36 | + (stdout, _) = gitproc.communicate() |
| 37 | + return stdout.strip() |
| 38 | + |
| 39 | + |
| 40 | +class test(Command): |
| 41 | + description = "test the distribution prior to install" |
| 42 | + |
| 43 | + user_options = [ |
| 44 | + ('test-dir=', None, |
| 45 | + "directory that contains the test definitions"), |
| 46 | + ] |
| 47 | + |
| 48 | + def initialize_options(self): |
| 49 | + pass |
| 50 | + |
| 51 | + def finalize_options(self): |
| 52 | + pass |
| 53 | + |
| 54 | + def run(self): |
| 55 | + if sys.platform == 'win32': |
| 56 | + command = "coverage run PyFin/tests/testSuite.py& coverage report& coverage html" |
| 57 | + else: |
| 58 | + command = "coverage run PyFin/tests/testSuite.py; coverage report; coverage html" |
| 59 | + process = subprocess.Popen(command, shell=True) |
| 60 | + process.wait() |
| 61 | + |
| 62 | + |
| 63 | +class version_build(Command): |
| 64 | + |
| 65 | + description = "test the distribution prior to install" |
| 66 | + |
| 67 | + user_options = [ |
| 68 | + ('test-dir=', None, |
| 69 | + "directory that contains the test definitions"), |
| 70 | + ] |
| 71 | + |
| 72 | + def initialize_options(self): |
| 73 | + pass |
| 74 | + |
| 75 | + def finalize_options(self): |
| 76 | + pass |
| 77 | + |
| 78 | + def run(self): |
| 79 | + git_ver = git_version()[:10] |
| 80 | + configFile = 'PyFin/__init__.py' |
| 81 | + |
| 82 | + file_handle = open(configFile, 'r') |
| 83 | + lines = file_handle.readlines() |
| 84 | + newFiles = [] |
| 85 | + for line in lines: |
| 86 | + if line.startswith('__version__'): |
| 87 | + line = line.split('+')[0].rstrip() |
| 88 | + line = line + " + \"-" + git_ver + "\"\n" |
| 89 | + newFiles.append(line) |
| 90 | + file_handle.close() |
| 91 | + os.remove(configFile) |
| 92 | + file_handle = open(configFile, 'w') |
| 93 | + file_handle.writelines(newFiles) |
| 94 | + file_handle.close() |
| 95 | + |
| 96 | +if sys.version_info > (3, 0, 0): |
| 97 | + requirements = "requirements/py3.txt" |
| 98 | +else: |
| 99 | + requirements = "requirements/py2.txt" |
| 100 | + |
| 101 | + |
| 102 | +ext_modules = [ |
| 103 | + "PyFin/Analysis/SeriesValues.pyx", |
| 104 | + "PyFin/Analysis/transformer.pyx", |
| 105 | + "PyFin/Analysis/SecurityValueHolders.pyx", |
| 106 | + "PyFin/Analysis/CrossSectionValueHolders.pyx", |
| 107 | + "PyFin/Analysis/TechnicalAnalysis/StatefulTechnicalAnalysers.pyx", |
| 108 | + "PyFin/Analysis/TechnicalAnalysis/StatelessTechnicalAnalysers.pyx", |
| 109 | + "PyFin/Math/Accumulators/impl.pyx", |
| 110 | + "PyFin/Math/Accumulators/IAccumulators.pyx", |
| 111 | + "PyFin/Math/Accumulators/StatefulAccumulators.pyx", |
| 112 | + "PyFin/Math/Accumulators/StatelessAccumulators.pyx", |
| 113 | + "PyFin/Math/Distributions/NormalDistribution.pyx", |
| 114 | + "PyFin/Math/Distributions/norm.pyx", |
| 115 | + "PyFin/Math/ErrorFunction.pyx", |
| 116 | + "PyFin/Math/MathConstants.pyx", |
| 117 | + "PyFin/Math/udfs.pyx", |
| 118 | + "PyFin/DateUtilities/Calendar.pyx", |
| 119 | + "PyFin/DateUtilities/Date.pyx", |
| 120 | + "PyFin/DateUtilities/Period.pyx", |
| 121 | + "PyFin/DateUtilities/Schedule.pyx", |
| 122 | + "PyFin/Utilities/Asserts.pyx", |
| 123 | + "PyFin/Utilities/Tools.pyx", |
| 124 | + "PyFin/PricingEngines/BlackFormula.pyx", |
| 125 | + "PyFin/PricingEngines/SabrFormulaImpl.pyx", |
| 126 | + "PyFin/PricingEngines/SVIInterpolationImpl.pyx", |
| 127 | + "PyFin/Enums/TimeUnits.pyx", |
| 128 | + "PyFin/Enums/BizDayConventions.pyx", |
| 129 | + "PyFin/Enums/DateGeneration.pyx", |
| 130 | + "PyFin/Enums/Months.pyx", |
| 131 | + "PyFin/Enums/NormalizingType.pyx", |
| 132 | + "PyFin/Enums/OptionType.pyx", |
| 133 | + "PyFin/Enums/Weekdays.pyx" |
| 134 | +] |
| 135 | + |
| 136 | + |
| 137 | +def generate_extensions(ext_modules, line_trace=False): |
| 138 | + |
| 139 | + extensions = [] |
| 140 | + |
| 141 | + if line_trace: |
| 142 | + print("define cython trace to True ...") |
| 143 | + define_macros = [('CYTHON_TRACE', 1), ('CYTHON_TRACE_NOGIL', 1)] |
| 144 | + else: |
| 145 | + define_macros = [] |
| 146 | + |
| 147 | + for pyxfile in ext_modules: |
| 148 | + ext = Extension(name='.'.join(pyxfile.split('/'))[:-4], |
| 149 | + sources=[pyxfile], |
| 150 | + define_macros=define_macros) |
| 151 | + extensions.append(ext) |
| 152 | + return extensions |
| 153 | + |
| 154 | + |
| 155 | +if platform.system() != "Windows": |
| 156 | + import multiprocessing |
| 157 | + n_cpu = multiprocessing.cpu_count() |
| 158 | +else: |
| 159 | + n_cpu = 0 |
| 160 | + |
| 161 | +ext_modules_settings = cythonize(generate_extensions(ext_modules, line_trace), |
| 162 | + compiler_directives={'embedsignature': True, 'linetrace': line_trace}, |
| 163 | + nthreads=n_cpu) |
| 164 | + |
| 165 | + |
| 166 | +setup( |
| 167 | + name=NAME, |
| 168 | + version=VERSION, |
| 169 | + description=DESCRIPTION, |
| 170 | + author=AUTHOR, |
| 171 | + author_email=AUTHOR_EMAIL, |
| 172 | + url=URL, |
| 173 | + packages=find_packages(), |
| 174 | + include_package_data=False, |
| 175 | + install_requires=io.open(requirements, encoding='utf8').read(), |
| 176 | + classifiers=[], |
| 177 | + cmdclass={"test": test, |
| 178 | + "version_build": version_build}, |
| 179 | + ext_modules=ext_modules_settings, |
| 180 | + include_dirs=[np.get_include()], |
| 181 | +) |
0 commit comments