|
1 | 1 | import os.path
|
2 | 2 |
|
3 |
| -import numpy |
| 3 | +from numpy import get_include |
| 4 | +from numpy.distutils.core import setup |
| 5 | +from numpy.distutils.misc_util import Configuration |
4 | 6 |
|
5 | 7 |
|
6 | 8 | def configuration(parent_package='', top_path=None):
|
7 |
| - from numpy.distutils.misc_util import Configuration |
8 |
| - |
9 | 9 | config = Configuration('impl', parent_package, top_path)
|
10 | 10 |
|
11 | 11 | randomdir = os.path.join(top_path, "lightning", "impl", "randomkit")
|
12 |
| - |
13 |
| - config.add_extension('adagrad_fast', |
14 |
| - sources=['adagrad_fast.pyx'], |
15 |
| - language='c++', |
16 |
| - include_dirs=[numpy.get_include(), randomdir]) |
17 |
| - |
18 |
| - config.add_extension('dataset_fast', |
19 |
| - sources=['dataset_fast.pyx'], |
20 |
| - language='c++', |
21 |
| - include_dirs=[numpy.get_include(), randomdir]) |
22 |
| - |
23 |
| - config.add_extension('dual_cd_fast', |
24 |
| - sources=['dual_cd_fast.pyx'], |
25 |
| - language='c++', |
26 |
| - include_dirs=[numpy.get_include(), randomdir]) |
27 |
| - |
28 |
| - config.add_extension('loss_fast', |
29 |
| - sources=['loss_fast.pyx'], |
30 |
| - language='c++', |
31 |
| - include_dirs=[numpy.get_include(), randomdir]) |
32 |
| - |
33 |
| - config.add_extension('prank_fast', |
34 |
| - sources=['prank_fast.pyx'], |
35 |
| - language='c++', |
36 |
| - include_dirs=[numpy.get_include(), randomdir]) |
37 |
| - |
38 |
| - config.add_extension('primal_cd_fast', |
39 |
| - sources=['primal_cd_fast.pyx'], |
40 |
| - language='c++', |
41 |
| - include_dirs=[numpy.get_include(), randomdir]) |
42 |
| - |
43 |
| - config.add_extension('prox_fast', |
44 |
| - sources=['prox_fast.pyx'], |
45 |
| - language='c++', |
46 |
| - include_dirs=[numpy.get_include(), randomdir]) |
47 |
| - |
48 |
| - config.add_extension('sag_fast', |
49 |
| - sources=['sag_fast.pyx'], |
50 |
| - language='c++', |
51 |
| - include_dirs=[numpy.get_include(), randomdir]) |
52 |
| - |
53 |
| - config.add_extension('sdca_fast', |
54 |
| - sources=['sdca_fast.pyx'], |
55 |
| - language='c++', |
56 |
| - include_dirs=[numpy.get_include(), randomdir]) |
57 |
| - |
58 |
| - config.add_extension('sgd_fast', |
59 |
| - sources=['sgd_fast.pyx'], |
60 |
| - language='c++', |
61 |
| - include_dirs=[numpy.get_include(), randomdir]) |
62 |
| - |
63 |
| - config.add_extension('svrg_fast', |
64 |
| - sources=['svrg_fast.pyx'], |
65 |
| - language='c++', |
66 |
| - include_dirs=[numpy.get_include(), randomdir]) |
| 12 | + currdir = os.path.dirname(os.path.abspath(__file__)) |
| 13 | + |
| 14 | + files = [ |
| 15 | + 'adagrad_fast', |
| 16 | + 'dataset_fast', |
| 17 | + 'dual_cd_fast', |
| 18 | + 'loss_fast', |
| 19 | + 'prank_fast', |
| 20 | + 'primal_cd_fast', |
| 21 | + 'prox_fast', |
| 22 | + 'sag_fast', |
| 23 | + 'sdca_fast', |
| 24 | + 'sgd_fast', |
| 25 | + 'svrg_fast', |
| 26 | + ] |
| 27 | + for f in files: |
| 28 | + config.add_extension(f, |
| 29 | + sources=[f'{f}.pyx'], |
| 30 | + language='c++', |
| 31 | + include_dirs=[get_include(), randomdir]) |
| 32 | + |
| 33 | + # add .pxd files to be re-used by third party software |
| 34 | + pxd_file = os.path.join(currdir, f'{f}.pxd') |
| 35 | + if os.path.exists(pxd_file): |
| 36 | + config.add_data_files(f'{f}.pxd') |
67 | 37 |
|
68 | 38 | config.add_subpackage('datasets')
|
69 | 39 | config.add_subpackage('randomkit')
|
70 | 40 | config.add_subpackage('tests')
|
71 | 41 |
|
72 |
| - # add .pxd files to be re-used by third party software |
73 |
| - config.add_data_files('sag_fast.pxd', 'dataset_fast.pxd', |
74 |
| - 'sgd_fast.pxd', 'prox_fast.pxd') |
75 |
| - |
76 | 42 | return config
|
77 | 43 |
|
78 | 44 | if __name__ == '__main__':
|
79 |
| - from numpy.distutils.core import setup |
80 | 45 | setup(**configuration(top_path='').todict())
|
0 commit comments