|
11 | 11 | import os |
12 | 12 | import re |
13 | 13 | import sys |
| 14 | +import glob |
14 | 15 | import warnings |
15 | 16 |
|
16 | 17 | from setuptools import Extension, find_packages, setup |
17 | 18 |
|
| 19 | + |
| 20 | +# Use this version when git data are not available, like in git zip archive. |
| 21 | +# Update when tagging a new release. |
| 22 | +FALLBACK_VERSION = '1.4.3' |
| 23 | + |
18 | 24 | MYDIR = os.path.dirname(os.path.abspath(__file__)) |
19 | 25 |
|
20 | 26 | # Helper functions ----------------------------------------------------------- |
@@ -98,50 +104,31 @@ def get_gsl_config_win(): |
98 | 104 | library_dirs += gcfg["library_dirs"] |
99 | 105 | # add optimization flags for other compilers if needed |
100 | 106 |
|
| 107 | +# define extension arguments here |
| 108 | +ext_kws = { |
| 109 | + 'include_dirs': include_dirs, |
| 110 | + 'libraries': libraries, |
| 111 | + 'library_dirs': library_dirs, |
| 112 | + 'define_macros': define_macros, |
| 113 | + 'extra_compile_args': extra_compile_args, |
| 114 | + 'extra_link_args': extra_link_args, |
| 115 | + 'extra_objects': extra_objects, |
| 116 | +} |
101 | 117 |
|
102 | 118 | # define extension here |
103 | | -pdffit2module = Extension( |
| 119 | +def create_extensions(): |
| 120 | + ext = Extension( |
104 | 121 | "diffpy.pdffit2.pdffit2", |
105 | | - [ |
106 | | - "src/extensions/pdffit2module/bindings.cc", |
107 | | - "src/extensions/pdffit2module/misc.cc", |
108 | | - "src/extensions/pdffit2module/pdffit2module.cc", |
109 | | - "src/extensions/pdffit2module/pyexceptions.cc", |
110 | | - "src/extensions/libpdffit2/Atom.cc", |
111 | | - "src/extensions/libpdffit2/LocalPeriodicTable.cc", |
112 | | - "src/extensions/libpdffit2/OutputStreams.cc", |
113 | | - "src/extensions/libpdffit2/PeriodicTable.cc", |
114 | | - "src/extensions/libpdffit2/PointsInSphere.cc", |
115 | | - "src/extensions/libpdffit2/StringUtils.cc", |
116 | | - "src/extensions/libpdffit2/fit.cc", |
117 | | - "src/extensions/libpdffit2/gaussj.cc", |
118 | | - "src/extensions/libpdffit2/metric.cc", |
119 | | - "src/extensions/libpdffit2/nrutil.cc", |
120 | | - "src/extensions/libpdffit2/output.cc", |
121 | | - "src/extensions/libpdffit2/parser.cc", |
122 | | - "src/extensions/libpdffit2/pdf.cc", |
123 | | - "src/extensions/libpdffit2/pdffit.cc", |
124 | | - "src/extensions/libpdffit2/pdflsmin.cc", |
125 | | - "src/extensions/libpdffit2/scatlen.cc", |
126 | | - "src/extensions/libpdffit2/stru.cc", |
127 | | - ], |
128 | | - include_dirs=include_dirs, |
129 | | - libraries=libraries, |
130 | | - library_dirs=library_dirs, |
131 | | - define_macros=define_macros, |
132 | | - extra_compile_args=extra_compile_args, |
133 | | - extra_link_args=extra_link_args, |
134 | | - extra_objects=extra_objects, |
135 | | -) |
| 122 | + glob.glob('src/extensions/**/*.cc'), |
| 123 | + **ext_kws) |
| 124 | + return [ext] |
136 | 125 |
|
137 | 126 | setup_args = dict( |
138 | | - packages=find_packages(where="src"), |
139 | | - package_dir={"": "src"}, |
140 | | - ext_modules=[pdffit2module], |
141 | | - # scripts=[] # place examples here |
| 127 | + ext_modules = [], |
142 | 128 | ) |
143 | 129 |
|
144 | 130 | if __name__ == "__main__": |
| 131 | + setup_args['ext_modules'] = create_extensions() |
145 | 132 | setup(**setup_args) |
146 | 133 |
|
147 | 134 | # End of file |
0 commit comments