Skip to content
Permalink
Browse files
Eol (#326)
* Reenable archival thunk code and rework setup.

* Fixed EOL to LF.
  • Loading branch information
Thrameos authored and marscher committed Jun 6, 2018
1 parent 5d4a72c commit 490eb65
Show file tree
Hide file tree
Showing 167 changed files with 18,811 additions and 18,596 deletions.
@@ -0,0 +1,12 @@
* test=auto

# Specify lf for all source files
*.py text eol=lf
*.cpp text eol=lf
*.c text eol=lf
*.h text eol=lf

*.xml text eol=lf
*.txt text
.gitignore text eol=lf
.gitattributes text eol=lf
@@ -21,23 +21,23 @@ addons:

env:
# one build with and without numpy support (opt numpy out)
- NUMPY="--install-option=--disable-numpy"
- NUMPY="--global-option=--disable-numpy"
- NUMPY=""

matrix:
allow_failures:
- python: 'pypy'
env: NUMPY="--install-option=--disable-numpy"
env: NUMPY="--global-option=--disable-numpy"
- python: 'pypy3'
env: NUMPY="--install-option=--disable-numpy"
env: NUMPY="--global-option=--disable-numpy"
- python: 'pypy'
env: NUMPY=""
- python: 'pypy3'
env: NUMPY=""
- python: 'nightly'
env: NUMPY=""
- python: 'nightly'
env: NUMPY="--install-option=--disable-numpy"
env: NUMPY="--global-option=--disable-numpy"

install:
- pip install . $NUMPY
@@ -22,3 +22,4 @@ Huge thanks to these CONTRIBUTORS:
* Martin K. Scherer
* Dongwon Shin
* rbprogrammer
* Karl Einar Nelson
@@ -13,6 +13,8 @@ This changelog *only* contains changes from the *first* pypi release (0.5.4.3) o
- Python thread option for JPypeReferenceQueue. References are always handled with
with the Java cleanup routine. The undocumented setUsePythonThreadForDaemon()
will be removed at a future version.
- promoted --install-option to a --global-option as it applies to the build as well
as install.

- **0.6.3 - 2018-04-03**
- Java reference counting has been converted to use JNI
@@ -173,7 +173,7 @@ array element but can process all data at once.
If you do not want this optional feature, because eg. it depends on NumPy, you
can opt it out in the installation process by passing *"--disable-numpy"* to
*setup.py*. To opt out with pip you need to append the additional argument
*"--install-option='--disable-numpy'*. This possibility exists since version
*"--global-option='--disable-numpy'*. This possibility exists since version
0.5.6.

Creating Java arrays from Python
@@ -1,40 +1,40 @@
This example of using JPype and JMS contributed by David Morgenthaler
Here is the message that accompanied it when he posted it on comp.lang.python :
=============================================================================
Your question intrigued me, so I gave it a try. And the anwer (at
least for JMS Publish/Subscribe TextMessages) is YES.
It includes:
- Java classes for a publisher (src/messaging/JpypePublisher) and a
subscriber (src/messaging/JpypeSubscriber). These Java classes, which
do most of the dirty work of connecting to the JMS server, are used
from python via jpype.
- Java classes that test the publisher and subscriber
(src/messaging/testJpepePublisher, src/messaging/testJpypeSubscriber)
- A Java interface that is used by python for the JProxy
- python scripts for publishing and subscribing
- An build.xml for ant to build and run the Java classes
The Java and python publishers and subscribers work in any reasonable
combination (J pub/J sub, J pub/p sub, p pub/p sub, p pub/J sub, and
even with multiple subscribers)
Copy conveniently located folder. You'll find a build.xml for
ant to build the Java. You'll have to edit (in the testers and in the
python scripts) the naming and connection factory stuff for your
situation. You'll also have to edit the python scripts to correctly
locate your jvm and other classpath information. Once you're correctly
configured, you can use ant to build and/or execute the Java (type
"ant help"). And once the Java is built, you can try the python
versions.
I can't imagine that this approach wouldn't work for JMS Queues. And
while I haven't tested it, I don't see anything preventing the use of
other message types (BinaryMessage, ObjectMessage,...).
BTW, I don't detect any noticable slowdown in the python versions from
the Java versions (probably because of the strightforward conversion
of python strings to Java Strings).
This example of using JPype and JMS contributed by David Morgenthaler

Here is the message that accompanied it when he posted it on comp.lang.python :
=============================================================================
Your question intrigued me, so I gave it a try. And the anwer (at
least for JMS Publish/Subscribe TextMessages) is YES.

It includes:
- Java classes for a publisher (src/messaging/JpypePublisher) and a
subscriber (src/messaging/JpypeSubscriber). These Java classes, which
do most of the dirty work of connecting to the JMS server, are used
from python via jpype.
- Java classes that test the publisher and subscriber
(src/messaging/testJpepePublisher, src/messaging/testJpypeSubscriber)
- A Java interface that is used by python for the JProxy
- python scripts for publishing and subscribing
- An build.xml for ant to build and run the Java classes

The Java and python publishers and subscribers work in any reasonable
combination (J pub/J sub, J pub/p sub, p pub/p sub, p pub/J sub, and
even with multiple subscribers)

Copy conveniently located folder. You'll find a build.xml for
ant to build the Java. You'll have to edit (in the testers and in the
python scripts) the naming and connection factory stuff for your
situation. You'll also have to edit the python scripts to correctly
locate your jvm and other classpath information. Once you're correctly
configured, you can use ant to build and/or execute the Java (type
"ant help"). And once the Java is built, you can try the python
versions.

I can't imagine that this approach wouldn't work for JMS Queues. And
while I haven't tested it, I don't see anything preventing the use of
other message types (BinaryMessage, ObjectMessage,...).

BTW, I don't detect any noticable slowdown in the python versions from
the Java versions (probably because of the strightforward conversion
of python strings to Java Strings).

=============================================================================
@@ -1,35 +1,35 @@
from jpype import *
import time

NUMMSGS = 10

def pyPublisher (javaNamingFactory="weblogic.jndi.WLInitialContextFactory",
javaNamingProvider="t3://158.188.40.21:7001",
connectionFactory="weblogic.jms.ConnectionFactory",
topicName="defaultTopic"):
return messaging.JpypePublisher(javaNamingFactory,javaNamingProvider,
connectionFactory,topicName)

## Startup Jpype and import the messaging java package
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll",
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar")
messaging = JPackage('messaging')

# Get a publisher
publisher = pyPublisher()

## Timing test
# The "Start" message signals the subscriber to start timing message receipts
publisher.publish("Start")

t0 = time.time()
for i in range(NUMMSGS):
publisher.publish("Hello World! %s"%i)
print "MessageRate =",float(NUMMSGS)/(time.time()-t0)

# The "Stop" message signals the subscriber to stop timing message receipts
publisher.publish("Stop")

# Close and quit
publisher.close()
shutdownJVM()
from jpype import *
import time

NUMMSGS = 10

def pyPublisher (javaNamingFactory="weblogic.jndi.WLInitialContextFactory",
javaNamingProvider="t3://158.188.40.21:7001",
connectionFactory="weblogic.jms.ConnectionFactory",
topicName="defaultTopic"):
return messaging.JpypePublisher(javaNamingFactory,javaNamingProvider,
connectionFactory,topicName)

## Startup Jpype and import the messaging java package
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll",
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar")
messaging = JPackage('messaging')

# Get a publisher
publisher = pyPublisher()

## Timing test
# The "Start" message signals the subscriber to start timing message receipts
publisher.publish("Start")

t0 = time.time()
for i in range(NUMMSGS):
publisher.publish("Hello World! %s"%i)
print "MessageRate =",float(NUMMSGS)/(time.time()-t0)

# The "Stop" message signals the subscriber to stop timing message receipts
publisher.publish("Stop")

# Close and quit
publisher.close()
shutdownJVM()
@@ -1,42 +1,42 @@
from jpype import *
import time

def pySubscriber (proxy,
javaNamingFactory="weblogic.jndi.WLInitialContextFactory",
javaNamingProvider="t3://158.188.40.21:7001",
connectionFactory="weblogic.jms.ConnectionFactory",
topicName="defaultTopic"):
return messaging.JpypeSubscriber(proxy,javaNamingFactory,javaNamingProvider,
connectionFactory,topicName)

## Startup Jpype and import the messaging java package
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll",
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar")
messaging = JPackage('messaging')

# Setup the JProxy for the messaging.JpypeSubscriberCallback interface
class pyCallback:
startTime = 0
count = 0
def onMessage (self,text):
print text
if text=='Start':
pyCallback.startTime=time.time()
pyCallback.count = 0
elif text=='Stop':
print "Message Rate =",float(pyCallback.count)/(time.time()-pyCallback.startTime)
else:
pyCallback.count += 1

c = pyCallback()
proxy = JProxy(messaging.JpypeSubscriberCallback,inst=c)

# Get a subscriber
sub = pySubscriber(proxy)
print "Listening..."

# Prevent this thread from exiting
time.sleep(1000)

# exit
shutdownJVM()
from jpype import *
import time

def pySubscriber (proxy,
javaNamingFactory="weblogic.jndi.WLInitialContextFactory",
javaNamingProvider="t3://158.188.40.21:7001",
connectionFactory="weblogic.jms.ConnectionFactory",
topicName="defaultTopic"):
return messaging.JpypeSubscriber(proxy,javaNamingFactory,javaNamingProvider,
connectionFactory,topicName)

## Startup Jpype and import the messaging java package
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll",
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar")
messaging = JPackage('messaging')

# Setup the JProxy for the messaging.JpypeSubscriberCallback interface
class pyCallback:
startTime = 0
count = 0
def onMessage (self,text):
print text
if text=='Start':
pyCallback.startTime=time.time()
pyCallback.count = 0
elif text=='Stop':
print "Message Rate =",float(pyCallback.count)/(time.time()-pyCallback.startTime)
else:
pyCallback.count += 1

c = pyCallback()
proxy = JProxy(messaging.JpypeSubscriberCallback,inst=c)

# Get a subscriber
sub = pySubscriber(proxy)
print "Listening..."

# Prevent this thread from exiting
time.sleep(1000)

# exit
shutdownJVM()
@@ -1,20 +1,20 @@
The 2 scripts in this derectory are here to resolve a weakness in the linux implementation.
Since the JVM is loaded dynamically, the LD_LIBRARY_PATH may not contain the proper directories.
Unfortunately, dlopen() will ignore any changes made to the LD_LIBRARY_PATH in the current process.
The jpype.sh is meant as an example for people redistributing apps using jpype. Instead of having
users launch python script.py directly, have then launch script.sh. The companion finjvm.py can be
delivered along your app, but is also present in the ptyhon distribution of jpype.
Developpers are encouraged to make their lives simpler by adding the correct directories to their
LD_LIBRARY_PATH directly.
To learn more about the dlopen problem, you can look at :
http://forum.java.sun.com/thread.jsp?forum=52&thread=303583&message=1210441
and
http://www.nathanr.net/diary/index.php?year=2004&month=05
The 2 scripts in this derectory are here to resolve a weakness in the linux implementation.

Since the JVM is loaded dynamically, the LD_LIBRARY_PATH may not contain the proper directories.

Unfortunately, dlopen() will ignore any changes made to the LD_LIBRARY_PATH in the current process.

The jpype.sh is meant as an example for people redistributing apps using jpype. Instead of having
users launch python script.py directly, have then launch script.sh. The companion finjvm.py can be
delivered along your app, but is also present in the ptyhon distribution of jpype.

Developpers are encouraged to make their lives simpler by adding the correct directories to their
LD_LIBRARY_PATH directly.

To learn more about the dlopen problem, you can look at :

http://forum.java.sun.com/thread.jsp?forum=52&thread=303583&message=1210441

and

http://www.nathanr.net/diary/index.php?year=2004&month=05
@@ -1,20 +1,20 @@
#*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#*****************************************************************************
import jpype, os.path

jvmlib = jpype.getDefaultJVMPath()
print os.path.dirname(os.path.dirname(jvmlib))
#*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#*****************************************************************************
import jpype, os.path

jvmlib = jpype.getDefaultJVMPath()
print os.path.dirname(os.path.dirname(jvmlib))

0 comments on commit 490eb65

Please sign in to comment.