|
13 | 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | | - |
17 | | - |
18 | 16 | import sys |
19 | 17 | import os |
20 | 18 | import os.path |
|
33 | 31 |
|
34 | 32 | import jpyutil |
35 | 33 |
|
36 | | -base_dir = os.path.dirname(os.path.abspath(__file__)) |
37 | | -src_main_c_dir = os.path.join(base_dir, 'src', 'main', 'c') |
38 | | -src_test_py_dir = os.path.join(base_dir, 'src', 'test', 'python') |
39 | | - |
40 | | -import jpyutil |
41 | | - |
42 | 34 | __author__ = jpyutil.__author__ |
43 | 35 | __copyright__ = jpyutil.__copyright__ |
44 | 36 | __license__ = jpyutil.__license__ |
45 | 37 | __version__ = jpyutil.__version__ |
46 | 38 |
|
47 | | -print('Using ' + jpyutil.__file__) |
| 39 | +base_dir = os.path.dirname(os.path.abspath(__file__)) |
| 40 | +src_main_c_dir = os.path.join(base_dir, 'src', 'main', 'c') |
| 41 | +src_test_py_dir = os.path.join(base_dir, 'src', 'test', 'python') |
| 42 | + |
48 | 43 |
|
49 | 44 | do_maven = False |
50 | 45 | if '--maven' in sys.argv: |
|
142 | 137 | library_dirs += [os.path.join(sys.exec_prefix, 'lib')] |
143 | 138 | extra_link_args += ['-Xlinker', '-rpath', jvm_dll_dir] |
144 | 139 |
|
145 | | -with open('README.md') as file: |
146 | | - long_description = file.read() |
147 | | - |
148 | | -with open('CHANGES.md') as file: |
149 | | - changelog = file.read() |
150 | | - |
151 | | -dist = setup(name='jpy', |
152 | | - description='Bi-directional Python-Java bridge', |
153 | | - long_description=long_description + '\n\n' + changelog, |
154 | | - version=__version__, |
155 | | - platforms='Windows, Linux, Darwin', |
156 | | - author=__author__, |
157 | | - |
158 | | - maintainer='Brockmann Consult GmbH', |
159 | | - maintainer_email='[email protected]', |
160 | | - license=__license__, |
161 | | - url='https://github.com/bcdev/jpy', |
162 | | - download_url='https://pypi.python.org/pypi/jpy/' + __version__, |
163 | | - py_modules=['jpyutil'], |
164 | | - package_data={'': [jpy_jar_file]}, |
165 | | - ext_modules=[Extension('jpy', |
166 | | - sources=sources, |
167 | | - depends=headers, |
168 | | - include_dirs=include_dirs, |
169 | | - library_dirs=library_dirs, |
170 | | - libraries=libraries, |
171 | | - extra_link_args=extra_link_args, |
172 | | - extra_compile_args=extra_compile_args, |
173 | | - define_macros=define_macros), |
174 | | - Extension('jdl', |
175 | | - sources=[os.path.join(src_main_c_dir, 'jni/org_jpy_DL.c')], |
176 | | - depends=[os.path.join(src_main_c_dir, 'jni/org_jpy_DL.h')], |
177 | | - include_dirs=include_dirs, |
178 | | - library_dirs=library_dirs, |
179 | | - libraries=libraries, |
180 | | - extra_link_args=extra_link_args, |
181 | | - extra_compile_args=extra_compile_args, |
182 | | - define_macros=define_macros), |
183 | | - ], |
184 | | - classifiers=[ |
185 | | - # How mature is this project? Common values are |
186 | | - # 3 - Alpha |
187 | | - # 4 - Beta |
188 | | - # 5 - Production/Stable |
189 | | - 'Development Status :: 4 - Beta', |
190 | | - |
191 | | - # Indicate who your project is intended for |
192 | | - 'Intended Audience :: Developers', |
193 | | - |
194 | | - # Pick your license as you wish (should match "license" above) |
195 | | - 'License :: OSI Approved :: Apache 2 License', |
196 | | - |
197 | | - # Specify the Python versions you support here. In particular, ensure |
198 | | - # that you indicate whether you support Python 2, Python 3 or both. |
199 | | - 'Programming Language :: Python :: 2', |
200 | | - 'Programming Language :: Python :: 2.7', |
201 | | - 'Programming Language :: Python :: 3', |
202 | | - 'Programming Language :: Python :: 3.3', |
203 | | - 'Programming Language :: Python :: 3.4', |
204 | | - 'Programming Language :: Python :: 3.5', |
205 | | - ] |
206 | | - ) |
207 | | - |
208 | | -#import pprint |
209 | | -#pprint.pprint(dist) |
210 | | -#pprint.pprint(dist.__dict__) |
211 | | -#pprint.pprint(dist.commands) |
212 | | -#pprint.pprint(dist.command_obj) |
213 | | -#pprint.pprint(dist.command_obj['build'].__dict__) |
214 | | -#pprint.pprint(dist.command_obj['install'].__dict__) |
215 | | -#pprint.pprint(dist.command_obj['install_lib'].__dict__) |
216 | | -#pprint.pprint(dist.command_obj['bdist_egg'].__dict__) |
217 | | -#pprint.pprint(dist.command_obj['egg_info'].__dict__) |
218 | | - |
| 140 | +# ----------- Functions ------------- |
219 | 141 |
|
220 | | -# |
221 | | -# Continue with custom setup if 'build' step is included in commands |
222 | | -# |
223 | | - |
224 | | -def _build_dir(): |
225 | | - # TODO: figure out logic for dynamically getting this at runtime |
226 | | - return os.path.join(base_dir, 'build/lib.macosx-10.12-x86_64-3.6') |
227 | | - |
228 | | -if dist.commands and len(dist.commands) > 0 \ |
229 | | - and dist.command_obj and len(dist.command_obj) > 0 \ |
230 | | - and 'clean' not in dist.command_obj \ |
231 | | - and 'build' in dist.command_obj: |
232 | | - |
233 | | - # |
234 | | - # Get build directory (whose content we'll zip and in which we test) |
235 | | - # |
236 | | - |
237 | | - # build_dir = dist.command_obj['build'].build_lib |
238 | | - # if not os.path.exists(build_dir): |
239 | | - # log.error("Missing build directory '" + build_dir + "'") |
240 | | - # exit(1) |
241 | | - |
242 | | - build_dir = _build_dir() |
243 | | - # |
244 | | - # Get install directory |
245 | | - # |
246 | | - |
247 | | - install_dir = None |
248 | | - if 'install' in dist.command_obj: |
249 | | - install_dir = dist.command_obj['install'].install_lib |
250 | | - if not os.path.exists(install_dir): |
251 | | - log.warn("Missing install directory '" + install_dir + "'") |
252 | | - install_dir = None |
253 | | - |
254 | | - # |
255 | | - # Get egg (archive/directory) name |
256 | | - # |
257 | | - |
258 | | - egg_name = None |
259 | | - if 'bdist_egg' in dist.command_obj: |
260 | | - egg_output = dist.command_obj['bdist_egg'].egg_output |
261 | | - if egg_output: |
262 | | - egg_name = os.path.basename(dist.command_obj['bdist_egg'].egg_output) |
263 | | - |
264 | | - # |
265 | | - # Write jpy configuration files to target directories |
266 | | - # |
| 142 | +def package_maven(): |
| 143 | + """ Run maven package lifecycle """ |
| 144 | + if not os.getenv('JAVA_HOME'): |
| 145 | + # make sure Maven uses the same JDK which we have used to compile |
| 146 | + # and link the C-code |
| 147 | + os.environ['JAVA_HOME'] = jdk_home_dir |
267 | 148 |
|
268 | 149 | mvn_goal = 'package' |
269 | 150 | log.info("Executing Maven goal '" + mvn_goal + "'") |
@@ -296,6 +177,10 @@ def _read(filename): |
296 | 177 | with open(filename) as file: |
297 | 178 | return file.read() |
298 | 179 |
|
| 180 | +def _build_dir(): |
| 181 | + # TODO: figure out logic for dynamically getting this at runtime |
| 182 | + return os.path.join(base_dir, 'build/lib.macosx-10.12-x86_64-3.6') |
| 183 | + |
299 | 184 | def test_python_java_rt(): |
300 | 185 | """ Run Python test cases against Java runtime classes. """ |
301 | 186 | sub_env = {'PYTHONPATH': _build_dir()} |
@@ -342,7 +227,7 @@ def _copy_jpyutil(): |
342 | 227 | shutil.copy(src, dest) |
343 | 228 |
|
344 | 229 | def _build_jpy(): |
345 | | - #package_maven() |
| 230 | + package_maven() |
346 | 231 | _copy_jpyutil() |
347 | 232 | _write_jpy_config() |
348 | 233 |
|
@@ -414,8 +299,6 @@ def run(self): |
414 | 299 | download_url='https://pypi.python.org/pypi/jpy/' + __version__, |
415 | 300 | py_modules=['jpyutil'], |
416 | 301 | package_data={'': [jpy_jar_file]}, |
417 | | - package_dir={'jpy': 'src/main/c'}, |
418 | | - zip_safe=False, |
419 | 302 | ext_modules=[Extension('jpy', |
420 | 303 | sources=sources, |
421 | 304 | depends=headers, |
@@ -455,4 +338,3 @@ def run(self): |
455 | 338 | 'Programming Language :: Python :: 3', |
456 | 339 | 'Programming Language :: Python :: 3.3', |
457 | 340 | 'Programming Language :: Python :: 3.4']) |
458 | | - |
0 commit comments