Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 33324da

Browse files
committed
wow, so i had managed to goof up the original merge from master. recreating setup.py from an older copy and keeping the version and some other slight changes from upstream.
1 parent 8d8c96b commit 33324da

File tree

1 file changed

+16
-134
lines changed

1 file changed

+16
-134
lines changed

setup.py

Lines changed: 16 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
17-
1816
import sys
1917
import os
2018
import os.path
@@ -33,18 +31,15 @@
3331

3432
import jpyutil
3533

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-
4234
__author__ = jpyutil.__author__
4335
__copyright__ = jpyutil.__copyright__
4436
__license__ = jpyutil.__license__
4537
__version__ = jpyutil.__version__
4638

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+
4843

4944
do_maven = False
5045
if '--maven' in sys.argv:
@@ -142,128 +137,14 @@
142137
library_dirs += [os.path.join(sys.exec_prefix, 'lib')]
143138
extra_link_args += ['-Xlinker', '-rpath', jvm_dll_dir]
144139

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-
author_email='[email protected]',
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 -------------
219141

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
267148

268149
mvn_goal = 'package'
269150
log.info("Executing Maven goal '" + mvn_goal + "'")
@@ -296,6 +177,10 @@ def _read(filename):
296177
with open(filename) as file:
297178
return file.read()
298179

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+
299184
def test_python_java_rt():
300185
""" Run Python test cases against Java runtime classes. """
301186
sub_env = {'PYTHONPATH': _build_dir()}
@@ -342,7 +227,7 @@ def _copy_jpyutil():
342227
shutil.copy(src, dest)
343228

344229
def _build_jpy():
345-
#package_maven()
230+
package_maven()
346231
_copy_jpyutil()
347232
_write_jpy_config()
348233

@@ -414,8 +299,6 @@ def run(self):
414299
download_url='https://pypi.python.org/pypi/jpy/' + __version__,
415300
py_modules=['jpyutil'],
416301
package_data={'': [jpy_jar_file]},
417-
package_dir={'jpy': 'src/main/c'},
418-
zip_safe=False,
419302
ext_modules=[Extension('jpy',
420303
sources=sources,
421304
depends=headers,
@@ -455,4 +338,3 @@ def run(self):
455338
'Programming Language :: Python :: 3',
456339
'Programming Language :: Python :: 3.3',
457340
'Programming Language :: Python :: 3.4'])
458-

0 commit comments

Comments
 (0)