Skip to content
Permalink
Browse files

Merge branch 'master' into explicit_cast

  • Loading branch information
Thrameos committed Mar 22, 2020
2 parents 2cbe28c + c3118f9 commit 15ca358bd48bd9438f38548375a8a2a6d9ac21de
@@ -17,17 +17,27 @@ env:
- PIP=pip
- INST=""

addons:
apt:
packages:
- ant

matrix:
allow_failures:
- python: nightly
- python: pypy3

include:
- name: "Python on macOS xcode 11.3"
os: osx
osx_image: xcode11.3
language: java
env:
- PYTHON=python3
- INST=--user
- PIP=pip3
install:
- echo $PYTHON $INST
- $PYTHON setup.py sdist
- $PIP install $INST dist/* $NUMPY
- $PIP install $INST -r test-requirements.txt
- $PYTHON setup.py test_java

- name: "Test document generation"
python: 3.7
dist: xenial
@@ -70,36 +80,19 @@ matrix:
- $PIP install -e .
- $PIP install gcovr pytest-cov jedi
- mvn -f project/coverage package
- ant -f test/build.xml
- $PYTHON setup.py test_java
script:
- $PYTHON -m pytest -v test/jpypetest --cov=jpype --cov-report=xml:coverage_py.xml --jar="native/org.jpype.jar" --jacoco --checkjni
- gcovr -r . --xml -o coverage.xml -d --exclude-unreachable-branches --exclude-throw-branches
- java -jar project/coverage/org.jacoco.cli-0.8.5-nodeps.jar report jacoco.exec --classfiles build/classes/ --xml coverage_java.xml
- bash <(curl -s https://codecov.io/bash) -f coverage.xml -f coverage_py.xml -f coverage_java.xml

- name: "Python on macOS xcode 11.3"
os: osx
osx_image: xcode11.3
language: java
env:
- PYTHON=python3
- INST=--user
- PIP=pip3
addons:
homebrew:
packages:
- ant
# Remove the following after bug is resolved
# https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296/17
update: true


install:
- echo $PYTHON $INST
- $PYTHON setup.py sdist
- $PIP install $INST dist/* $NUMPY
- $PIP install $INST -r test-requirements.txt
- ant -f test/build.xml
- $PYTHON setup.py test_java

script:
- $PYTHON -c "import jpype"
@@ -4,7 +4,6 @@ environment:
# /E:ON and /V:ON options are not enabled in the batch script intepreter
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
ANT_HOME: "C:\\ProgramData\\chocolatey\\lib\\ant\\apache-ant-1.10.5"
NUMPY_: "numpy x.x"
#JAVA_HOME: "C:\\jdk8"
JAVA_HOME: "C:\\Program Files\\Java\\jdk1.8.0"
@@ -25,13 +24,14 @@ environment:
# ARCH: x86_64
# CYGSH: C:\Cygwin64\bin\bash -c

- PYTHON: "C:\\Miniconda3"
ARCH: x86
CONDA_PY: "3-latest"
# Disabling... stuck at 3.7 for a while
#- PYTHON: "C:\\Miniconda3"
#ARCH: x86
#CONDA_PY: "3-latest"

- PYTHON: "C:\\Miniconda3-x64"
CONDA_PY: "3-latest"
ARCH: x86_64
#- PYTHON: "C:\\Miniconda3-x64"
#CONDA_PY: "3-latest"
#ARCH: x86_64

- PYTHON: "C:\\Miniconda36-x64"
CONDA_PY: "3.6.5"
@@ -51,21 +51,10 @@ environment:


install:
# Force java to be installed where JAVA_HOME points
# We can install and test multiple versions of java here
# - We will have to move the JAVA_HOME and the build of the harness to the test section.
# - We will need to figure out how to run nose multiple times on the same run so that
# we can get the result from each of the java version runs.
#
#- cinst jdk8 -params 'installdir=C:\\jdk8' %CINST_OPTS%

# - cinst jdk7 -params 'installdir=C:\\jdk7'
# - cinst jdk9 -version 9.0.4.11 -params 'installdir=C:\\jdk9'
- cinst ant %CINST_OPTS% --ignore-dependencies
- refreshenv

# Add thinges to path
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%ANT_HOME%\\bin;%PATH%"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"

# If cygwin installed run install.sh, else run the install.ps1
- "IF DEFINED CYGWIN (%CYGSH% appveyor/install.sh) ELSE (powershell ./appveyor/install.ps1)"
@@ -1,7 +1,6 @@
$env:Path += ";"+$env:PYTHON

# Check that we have the expected version and architecture for Python
ant.exe -version
python.exe --version
python.exe -c "import struct; print(struct.calcsize('P') * 8)"

@@ -15,7 +14,7 @@ pip.exe install numpy
#pip.exe install pytest==5.2.0
#pip.exe install -r "test-requirements.txt" # -r dev-requirements.txt

ant.exe -f test\\build.xml
python setup.py test_java

# Build the compiled extension and run the project tests
python.exe setup.py --enable-build-jar bdist_wheel
@@ -6,7 +6,6 @@ echo JAVA_HOME=$JAVA_HOME
echo ARCH=$ARCH
echo PATH=$PATH
echo PYTHON=$PYTHON
echo ANT_HOME=$ANT_HOME

# If we do not have Java installed we can't proceed
if [ ! -d "$JAVA_HOME" ]; then
@@ -52,7 +51,6 @@ rm -r ./pip ./wheel ./setuptools_scm

# Check versions
echo "==== Check versions"
"$ANT_HOME/bin/ant" -version
$PYTHON --version
"$JAVA_HOME/bin/java.exe" -version

@@ -70,7 +68,7 @@ $PYTHON -c "import struct; print(struct.calcsize('P') * 8)"

# Build the test harness
echo "==== Build test"
"$ANT_HOME/bin/ant" -f test/build.xml
$PYTHON setup.py test_java

# Install the package
echo "==== Build module"
@@ -1,5 +1,5 @@
/*****************************************************************************
Copyright 2004-2008 Steve Ménard
Copyright 2004-2008 Steve Ménard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -151,6 +151,14 @@ void JPypeException::convertJavaToPython()
jthrowable th = m_Throwable.get();
jvalue v;
v.l = th;
// GCOVR_EXCL_START
// This is condition is only hit if something fails during the initial boot
if (m_Context->getJavaContext() == NULL || m_Context->m_Context_GetExcClassID == NULL)
{
PyErr_SetString(PyExc_SystemError, frame.toString(th).c_str());
return;
}
// GCOVR_EXCL_STOP
jlong pycls = frame.CallLongMethodA(m_Context->getJavaContext(), m_Context->m_Context_GetExcClassID, &v);
if (pycls != 0)
{
@@ -17,6 +17,7 @@
package org.jpype.classloader;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.TreeMap;
import java.util.jar.JarEntry;
@@ -78,7 +79,7 @@ public void importClass(String name, byte[] code)
*/
public void importJar(byte[] bytes)
{
try (JarInputStream is = new JarInputStream(new ByteArrayInputStream(bytes)))
try ( JarInputStream is = new JarInputStream(new ByteArrayInputStream(bytes)))
{
while (true)
{
@@ -88,20 +89,14 @@ public void importJar(byte[] bytes)

// Skip directories and other non-class resources
long size = nextEntry.getSize();
if (size <= 0)
if (size == 0)
continue;

byte[] data = new byte[(int) size];
int total = 0;

// Read the contents.
while (true)
{
int r = is.read(data, total, data.length - total);
total += r;
if (r == 0 || total == size)
break;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int q;
while ((q = is.read()) != -1)
baos.write(q);
byte[] data = baos.toByteArray();

// Store all classes we find
String name = nextEntry.getName();
@@ -1,16 +1,43 @@
# -*- coding: utf-8 -*-
import os
import sys
import subprocess
import distutils.cmd
import distutils.log
from distutils.errors import DistutilsPlatformError
from distutils.dir_util import copy_tree
import glob
import re
import shlex


def compileJava(self):
target_version = "1.7"
srcs = glob.glob('native/java/**/*.java', recursive=True)
src1 = [i for i in srcs if "JPypeClassLoader" in i]
src2 = [i for i in srcs if not "JPypeClassLoader" in i]
cmd1 = shlex.split('javac -d build/lib -g:none -source %s -target %s' %
(target_version, target_version))
cmd1.extend(src1)
cmd2 = shlex.split('javac -d build/classes -g:none -source %s -target %s -cp build/lib' %
(target_version, target_version))
cmd2.extend(src2)
os.makedirs("build/lib", exist_ok=True)
os.makedirs("build/classes", exist_ok=True)
self.announce(" %s" % " ".join(cmd1), level=distutils.log.INFO)
subprocess.check_call(cmd1)
self.announce(" %s" % " ".join(cmd2), level=distutils.log.INFO)
subprocess.check_call(cmd2)
cmd3 = shlex.split(
'jar cvf build/lib/org.jpype.jar -C build/classes/ .')
self.announce(" %s" % " ".join(cmd3), level=distutils.log.INFO)
subprocess.check_call(cmd3)


class BuildJavaCommand(distutils.cmd.Command):
"""A custom command to create jar file during build."""

description = 'run ant to make a jar'
description = 'build jpype jar'
user_options = []

def initialize_options(self):
@@ -38,20 +65,15 @@ def run(self):
"Jar cache is missing, using --enable-build-jar to recreate it.")

# build the jar
buildDir = os.path.join("..", "build")
buildXmlFile = os.path.join("native", "build.xml")
command = [self.distribution.ant, '-Dbuild=%s' %
buildDir, '-f', buildXmlFile]
cmdStr = ' '.join(command)
self.announce(" %s" % cmdStr, level=distutils.log.INFO)
try:
subprocess.check_call(command)
compileJava(self)
except subprocess.CalledProcessError as exc:
distutils.log.error(exc.output)
raise DistutilsPlatformError("Error executing {}".format(exc.cmd))

# Disable for now. Java coverage tool needs work
# Coverage tool requires special placement of the source
if self.distribution.enable_coverage:
import shutil
shutil.copyfile(os.path.join("build", "lib", "org.jpype.jar"), os.path.join(
"native", "org.jpype.jar"))
# if self.distribution.enable_coverage:
# import shutil
# shutil.copyfile(os.path.join("build", "lib", "org.jpype.jar"), os.path.join(
# "native", "org.jpype.jar"))
@@ -91,6 +91,10 @@ def write(self):
print("""
all: $(LIB)
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
build/src/jp_thunk.cpp: $(call rwildcard,native/java,*.java)
python setup.py build_thunk
DEPDIR = build/deps
$(DEPDIR): ; @mkdir -p $@
@@ -124,6 +124,7 @@ def finalize_options(self):

def run(self):
"""Run command."""
self.run_command("build_java")
self.announce(
'Building thunks',
level=distutils.log.INFO)
@@ -8,13 +8,11 @@ class Distribution(_Distribution):
global_options = [
('enable-build-jar', None, 'Build the java jar portion'),
('enable-tracing', None, 'Set for tracing for debugging'),
('ant=', None, 'Set the ant executable (default ant)', 1),
('enable-coverage', None, 'Instrument c++ code for code coverage measuring'),

] + _Distribution.global_options

def parse_command_line(self):
self.ant = "ant"
self.enable_tracing = False
self.enable_build_jar = False
self.enable_coverage = False
@@ -11,7 +11,7 @@ class BuildSourceDistribution(sdist):
"""
Override some behavior on sdist
Copy the build/lib to native/jars to remove ant/jdk dependency
Copy the build/lib to native/jars to remove javac/jdk dependency
"""

def run(self):

0 comments on commit 15ca358

Please sign in to comment.
You can’t perform that action at this time.