Skip to content

Commit

Permalink
Merge branch 'master' into tidyup_virtual_override_mess
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrameos authored Dec 10, 2023
2 parents 5647a3a + a728267 commit f06042f
Show file tree
Hide file tree
Showing 30 changed files with 401 additions and 137 deletions.
6 changes: 6 additions & 0 deletions .azure/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
linux-3.11:
imageName: "ubuntu-latest"
python.version: '3.11'
linux-3.12:
imageName: "ubuntu-latest"
python.version: '3.12'
windows-3.7:
imageName: "windows-2019"
python.version: '3.7'
Expand All @@ -81,6 +84,9 @@ jobs:
windows-3.11:
imageName: "windows-2019"
python.version: '3.11'
windows-3.12:
imageName: "windows-2019"
python.version: '3.12'
mac-3.9:
imageName: "macos-11"
python.version: '3.9'
Expand Down
2 changes: 1 addition & 1 deletion .azure/doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# TODO: consider unpinning these?
Pygments==2.7.4
Pygments==2.15.0
docutils==0.14
commonmark==0.8.1
recommonmark==0.5.0
Expand Down
1 change: 1 addition & 0 deletions .azure/scripts/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ steps:
version: 11

- script: |
python -m pip install --upgrade pytest setuptools
python setup.py build_ext --inplace
displayName: 'Build module'

Expand Down
5 changes: 3 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ sphinx:

# Optionally set the version of Python and requirements required to build your docs
python:
version: "3.8"
install:
- method: pip
path: .
extra_requirements:
- docs

build:
image: latest
tools:
python: "3.8"
os: ubuntu-22.04
apt_packages:
- openjdk-8-jdk

Expand Down
13 changes: 11 additions & 2 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ This changelog *only* contains changes from the *first* pypi release (0.5.4.3) o

Latest Changes:
- **1.5.0_dev0 - 2023-04-03**
- **1.4.2_dev0 - 2022-10-26**

- Switched ``__eq__`` and ``__ne__`` operator to use ``equals`` rather than
``compareTo`` for comparable objects to avoid exception when comparing
object of different types.

- Fixed segmentation fault when comparing Java Comparable to primitives.

- Java exceptions that occur in inequality comparisons now map to Python
TypeError.

- Fixed crash when calling subscript on JArray.

- Fixed direct byte buffers not reporting nbytes correctly when cast to memoryview.
- Fixed direct byte buffers not reporting nbytes correctly when cast to
memoryview.

- Expand the defintion for Functional interface to include classes without
FunctionInterface annotation.
Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Java

JPype source distribution includes a copy of the Java JNI header
and precompiled Java code, thus the Java Development Kit (JDK) is not required.
JPype has been tested with Java versions from Java 1.7 to Java 13.
JPype has been tested with Java versions from Java 1.8 to Java 13.

C++
A C++ compiler which matches the ABI used to build CPython.
Expand Down
16 changes: 8 additions & 8 deletions doc/userguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ hard at work on your latest project but you just need to pip in the database
driver for your customers database and you can call it a night. Unfortunately,
it appears that your customers database will not connect to the Python database
API. The whole thing is custom and the customer isn't going to supply you with
a Python version. They did sent you a Java driver for the database but fat
a Python version. They did send you a Java driver for the database but fat
lot of good that will do for you.

Stumbling through the internet you find a module that says it can natively
load Java packages as Python modules. Well, it worth a shot...
load Java packages as Python modules. Well, it's worth a shot...

So first thing the guide says is that you need to install Java and set up
a ``JAVA_HOME`` environment variable pointing to the JRE. Then start the
Expand Down Expand Up @@ -305,9 +305,9 @@ design goals.
- Favor clarity over performance. This doesn't mean not trying to optimize
paths, but just as premature optimization is the bane of programmers,
requiring writing to maximize speed is a poor long term choice, especially
in a language such as Python were weak typing can promote bit rot.
in a language such as Python where weak typing can promote bit rot.
- If a new method has to be introduced, make look familiar.
- If a new method has to be introduced, make it look familiar.
Java programmers look to a method named "of" to convert to a type on
factories such as a Stream, thus ``JArray.of`` converts a Python NumPy array
to Java. Python programmers expect that memory backed objects can be converted
Expand Down Expand Up @@ -546,7 +546,7 @@ JPype Concepts
***************
At its heart, JPype is about providing a bridge to use Java within Python.
Depending on your prospective that can either be a means of accessing Java
Depending on your perspective that can either be a means of accessing Java
libraries from within Python or a way to use Java using Python syntax for
interactivity and visualization. This mean not only exposing a limited API but
instead trying to provide the entirety of the Java language with Python.
Expand Down Expand Up @@ -2179,7 +2179,7 @@ NumPy arrays, and conversion of NumPy integer types to Java boxed types.
Transfers to Java
=================
Memory from a NumPy array can be transferred Java in bulk. The transfer of
Memory from a NumPy array can be transferred to Java in bulk. The transfer of
a one dimensional NumPy array to Java can either be done at initialization
or by use of the Python slice operator.
Expand Down Expand Up @@ -2271,7 +2271,7 @@ all buffers become invalid and any access to NumPy arrays backed by Java
risk crashing. To avoid this fate, either create the memory for the buffer from
within Python and pass it to Java. Or use the Java ``java.lang.Runtime.exit``
which will terminate both the Java and Python process without leaving any
opertunity to access a dangling buffer.
opportunity to access a dangling buffer.
Buffer backed memory is not limited to use with NumPy. Buffer transfers are
supported to provide shared memory between processes or memory mapped files.
Expand All @@ -2282,7 +2282,7 @@ NumPy Primitives
================
When converting a Python type to a boxed Java type, there is the difficulty
that Java has no way to known the size of a Python numerical value. But when
that Java has no way to know the size of a Python numerical value. But when
converting NumPy numerical types, this is not an issue. The following
conversions apply to NumPy primitive types.
Expand Down
2 changes: 1 addition & 1 deletion examples/jms/testJpypePublisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def pyPublisher(javaNamingFactory="weblogic.jndi.WLInitialContextFactory",
t0 = time.time()
for i in range(NUMMSGS):
publisher.publish("Hello World! %s" % i)
print "MessageRate =", float(NUMMSGS) / (time.time() - t0)
print("MessageRate =", float(NUMMSGS) / (time.time() - t0))

# The "Stop" message signals the subscriber to stop timing message receipts
publisher.publish("Stop")
Expand Down
6 changes: 3 additions & 3 deletions examples/jms/testJpypeSubscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class pyCallback:
count = 0

def onMessage(self, text):
print 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)
print("Message Rate =", float(pyCallback.count) / (time.time() - pyCallback.startTime))
else:
pyCallback.count += 1

Expand All @@ -39,7 +39,7 @@ def onMessage(self, text):

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

# Prevent this thread from exiting
time.sleep(1000)
Expand Down
2 changes: 1 addition & 1 deletion examples/linux/findjvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
import os.path

jvmlib = jpype.getDefaultJVMPath()
print os.path.dirname(os.path.dirname(jvmlib))
print(os.path.dirname(os.path.dirname(jvmlib)))
2 changes: 1 addition & 1 deletion examples/rmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

p = java.rmi.Naming.lookup("rmi://localhost:2004/server")

print p, p.__class__
print(p, p.__class__)

p.callRemote()

Expand Down
8 changes: 5 additions & 3 deletions jpype/_classpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#
# *****************************************************************************
import os as _os
import typing

import _jpype

__all__ = ['addClassPath', 'getClassPath']
Expand All @@ -24,7 +26,7 @@
_SEP = _os.path.pathsep


def addClassPath(path1):
def addClassPath(path1: typing.Union[str, _os.PathLike]) -> None:
""" Add a path to the Java class path
Classpath items can be a java, a directory, or a
Expand Down Expand Up @@ -66,7 +68,7 @@ def addClassPath(path1):
_CLASSPATHS.append(path1)


def getClassPath(env=True):
def getClassPath(env: bool = True) -> str:
""" Get the full Java class path.
Includes user added paths and the environment CLASSPATH.
Expand All @@ -79,7 +81,7 @@ def getClassPath(env=True):
global _CLASSPATHS
global _SEP

# Merge the evironment path
# Merge the environment path
classPath = list(_CLASSPATHS)
envPath = _os.environ.get("CLASSPATH")
if env and envPath:
Expand Down
Loading

0 comments on commit f06042f

Please sign in to comment.