Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support installing and testing using only a JRE #705

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
java-package: 'jre'
architecture: ${{ matrix.architecture }}

- name: Setup ant on macOS
Expand Down
201 changes: 201 additions & 0 deletions .github/workflows/test-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
on:
push:
pull_request:
create:

name: Continuous Integration - Testing Wheels on JREs
jobs:
build_test_jar:
runs-on: 'ubuntu-latest'
steps:

- name: Checkout pyjnius
uses: actions/checkout@v3

- name: Setup java
# There's no need to setup java on ubuntu-latest, as build is done into a manylinux
# containerized environment. (CIBW_BEFORE_ALL_LINUX) takes care of it.
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
architecture: 'x64'

- name: Setup ant on Linux
run: |
sudo apt-get update && sudo apt-get install -y ant

- name: Build test-classes via ant
run: ant all

- name: Upload test-classes
uses: actions/upload-artifact@v3
with:
name: test-classes
path: build/test-classes

build_wheels:
name: cibuildwheel on ${{ matrix.os }} ${{ matrix.architecture }}
env:
CIBW_BEFORE_ALL_LINUX: 'yum install -y java-11-openjdk-devel'
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ''
CIBW_SKIP: 'cp36-* *musllinux*'
strategy:
matrix:
include:
- os: windows-latest
architecture: 'x86'
cibw_archs: 'x86'
- os: windows-latest
architecture: 'x64'
cibw_archs: 'AMD64'
- os: ubuntu-latest
architecture: 'x64'
cibw_archs: 'x86_64'
- os: macos-latest
architecture: 'x64'
cibw_archs: 'x86_64 universal2'
runs-on: ${{ matrix.os }}
steps:

- name: Checkout pyjnius
uses: actions/checkout@v3

- name: Setup Python (Ubuntu x86_64, macOS Intel, Windows x86_64)
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest'
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Setup java
# There's no need to setup java on ubuntu-latest, as build is done into a manylinux
# containerized environment. (CIBW_BEFORE_ALL_LINUX) takes care of it.
if: ${{ matrix.os != 'ubuntu-latest' }}
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
architecture: ${{ matrix.architecture }}

- name: Install cibuildwheel & build wheels (Windows)
if: matrix.os == 'windows-latest'
env:
CIBW_ARCHS: '${{ matrix.cibw_archs }}'
run: |
python -m pip install cibuildwheel~=2.16.2
python -m cibuildwheel --output-dir dist

- name: Install cibuildwheel & build wheels (Linux, macOS Intel)
if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'kivy-ubuntu-arm64') || (matrix.os == 'macos-latest')
env:
CIBW_ARCHS: '${{ matrix.cibw_archs }}'
run: |
source .ci/utils.sh
ensure_python_version 3.11
python -m pip install cibuildwheel~=2.16.2
python -m cibuildwheel --output-dir dist

- name: upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

test_wheels:
name: Test wheel on ${{ matrix.os }} (${{ matrix.architecture }}) Python ${{ matrix.python }}
needs:
- build_wheels
continue-on-error: true
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest', 'kivy-ubuntu-arm64']
python: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.7', 'pypy3.8', 'pypy3.9']
include:
# We may would like to introduce tests also on windows-latest on x86 (win32 wheels)?
- os: ubuntu-latest
architecture: 'x64'
- os: windows-latest
architecture: 'x64'
- os: macos-latest
architecture: 'x64'
- os: apple-silicon-m1
architecture: 'aarch64'
python: '3.10'
- os: apple-silicon-m1
architecture: 'aarch64'
python: '3.11'
- os: apple-silicon-m1
architecture: 'aarch64'
python: '3.12'
runs-on: ${{ matrix.os }}
steps:

- name: Checkout pyjnius
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: dist
path: dist

- uses: actions/download-artifact@v3
with:
name: test-classes
path: build/test-classes

- name: Setup Python (Ubuntu x86_64, macOS Intel, Windows x86_64)
# Needs to be skipped on our self-hosted runners tagged as 'apple-silicon-m1'
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' || matrix.os == 'apple-silicon-m1'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Setup java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
java-package: 'jre'
architecture: ${{ matrix.architecture }}

- name: Install pyjnius wheel + test prerequisites (Windows, macOS)
if: matrix.os == 'windows-latest' || matrix.os == 'macos-latest' || matrix.os == 'apple-silicon-m1'
# --find-links=dist --no-index is needed to avoid downloading the pyjnius wheel
# from the index. We need to test the wheel we just built.
run: |
python -m pip install --find-links=dist --no-index pyjnius
python -m pip install pyjnius[dev,ci]

- name: Install pyjnius wheel + test prerequisites (Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'kivy-ubuntu-arm64'
# --find-links=dist --no-index is needed to avoid downloading the pyjnius wheel
# from the index. We need to test the wheel we just built.
run: |
source .ci/utils.sh
ensure_python_version ${{ matrix.python }}
python -m pip install --find-links=dist --no-index pyjnius
python -m pip install pyjnius[dev,ci]

- name: Test wheel (Linux, macOS)
if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'kivy-ubuntu-arm64') || (matrix.os == 'macos-latest') || (matrix.os == 'apple-silicon-m1')
run: |
source .ci/utils.sh
ensure_python_version ${{ matrix.python }}
cd tests
CLASSPATH=../build/test-classes:../build/classes python -m pytest -v

- name: Test wheel ( Windows + Python == 3.7.x )
# On Python < 3.8.x, we can't use `os.add_dll_directory`, so the jre should be in PATH.
if: (matrix.os == 'windows-latest') && contains(matrix.python, '3.7')
run: |
cd tests
$env:PATH +=";$env:JAVA_HOME\jre\bin\server\;$env:JAVA_HOME\jre\bin\client\;$env:JAVA_HOME\bin\server\"
$env:CLASSPATH ="../build/test-classes;../build/classes"
python -m pytest -v

- name: Test wheel (Windows + Python != 3.7.x )
if: (matrix.os == 'windows-latest') && !contains(matrix.python, '3.7')
run: |
cd tests
$env:CLASSPATH ="../build/test-classes;../build/classes"
python -m pytest -v
4 changes: 2 additions & 2 deletions docs/source/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Building PyJNIus
Building PyJNIus is necessary for development purposes, or if there is no
pre-built binary for your particular platform.

Like installation of PyJNIus, building PyJNIus requires a `Java Development Kit
Building PyJNIus requires a `Java Development Kit
<https://www.oracle.com/java/technologies/downloads/>`_ (JDK)
to be installed.
to be installed (NB: installing pre-built wheels required only a JRE).

Apart from the JDK, the build requirements for each platform are as follows:

Expand Down
3 changes: 2 additions & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ If there is no pre-compiled binary available, pip install will aim to compile
a binary on your operating system. For more information see the :ref:`building`
documentation.

You will need the Java JDK installed (`OpenJDK <https://openjdk.org/>`_ is fine).
You will need the Java JRE installed (`OpenJDK <https://openjdk.org/>`_ is fine).
PyJNIus searches for Java in the usual places on each operating system. If PyJNIus
cannot find Java, set the `JAVA_HOME` environment variable (this is often needed
`on Windows <https://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linux#windows>`_).
NB: Building pyjnius requires a Java JDK rather than a JRE.

Installation for Android
------------------------
Expand Down
Loading