Skip to content

Commit

Permalink
Add support for Linux Arm64 and drop support for Python 3.9 (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibdex authored Aug 30, 2024
1 parent 12ac454 commit 29afd80
Show file tree
Hide file tree
Showing 34 changed files with 1,115 additions and 1,278 deletions.
20 changes: 20 additions & 0 deletions .github/actions/build-conda-packages/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build Conda packages
description: Build the Conda packages
outputs:
platform:
description: The platform targeted by the Conda packages.
value: ${{ steps.get-platform.outputs.platform }}
runs:
using: composite
steps:
- uses: conda-incubator/setup-miniconda@v3
with:
conda-build-version: "24.7.1"

- run: conda build --no-anaconda-upload --output-folder dist .
# See https://github.com/conda-incubator/setup-miniconda/blame/059455a698430d8b68fa317268fa2e3da3492a98/README.md#L609-L610.
shell: bash -l {0}

- id: get-platform
run: uv run python -c 'from pathlib import Path; print(f"""platform={next(Path("dist").glob("*/jdk4py-*.tar.bz2")).parts[1]}""")' >> "$GITHUB_OUTPUT"
shell: bash
29 changes: 29 additions & 0 deletions .github/actions/build-java-runtime/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Java runtime
description: Build the Java runtime after installing the required dependencies.
inputs:
python-version:
description: The version of Python to set up.
required: true
runs:
using: composite
steps:
- run: curl -LsSf https://astral.sh/uv/0.4.0/install.sh | sh
shell: bash

- run: uv python install ${{ inputs.python-version }}
shell: bash

- run: uv sync --locked
shell: bash

- id: get-java-version
run: uv run python -c 'from jdk4py import JAVA_VERSION; print(f"""version={".".join(str(number) for number in JAVA_VERSION)}""")' >> "$GITHUB_OUTPUT"
shell: bash

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ steps.get-java-version.outputs.version }}

- run: uv run python build_java_runtime.py
shell: bash
42 changes: 0 additions & 42 deletions .github/actions/build-jdk/action.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/actions/build-python-wheel/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build Python wheel
description: Build the Python wheel
outputs:
filename:
description: The name of the built Python wheel.
value: ${{ steps.get-filename.outputs.filename }}
runs:
using: "composite"
steps:
- run: uv run python -m build --installer uv --wheel
shell: bash

- id: get-filename
run: uv run python -c 'from pathlib import Path; print(f"""filename={next(Path("dist").glob("jdk4py-*.whl")).parts[1]}""")' >> "$GITHUB_OUTPUT"
shell: bash
24 changes: 0 additions & 24 deletions .github/actions/create-conda-package/action.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/actions/create-python-wheel/action.yaml

This file was deleted.

38 changes: 17 additions & 21 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,36 @@ on:

jobs:
deploy:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.runner }}
environment: deployment
strategy:
matrix:
architecture:
- x64
os:
- macos-13
- ubuntu-22.04
runner:
- macos-13 # x64
- macos-14 # arm64
- ubuntu-24.04
- ubuntu-24.04-arm64 # GitHub-hosted larger runner in the ActiveViam organization.
- windows-2022
include:
- architecture: arm64
os: macos-14
name: Deploy on ${{ matrix.os }}-${{ matrix.architecture }}
name: Deploy on ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/build-jdk
- uses: ./.github/actions/build-java-runtime
with:
os: ${{ matrix.os }}
python-version: "3.12"

- uses: ./.github/actions/create-python-wheel
with:
build-number: ${{ env.JDK4PY_BUILD_NUMBER }}
- id: build-python-wheel
uses: ./.github/actions/build-python-wheel

- uses: ./.github/actions/create-conda-package
with:
architecture: ${{ matrix.architecture }}
- id: build-conda-packages
uses: ./.github/actions/build-conda-packages

- name: Upload Conda package
- name: Upload Conda packages
env:
JDK4PY_CONDA_CHANNEL_TOKEN: ${{ secrets.CONDA_CHANNEL_TOKEN }}
JDK4PY_CONDA_CHANNEL_URL: ${{ vars.CONDA_CHANNEL_URL }}
JDK4PY_CONDA_CHANNEL_USERNAME: ${{ vars.CONDA_CHANNEL_USERNAME }}
JDK4PY_CONDA_PLATFORM: ${{ steps.build-conda-packages.outputs.platform }}
run: |
ls dist/$JDK4PY_CONDA_PLATFORM/jdk4py-*.tar.bz2 | \
while read filepath; do
Expand All @@ -51,6 +46,7 @@ jobs:

- name: Upload Python wheel
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: poetry run twine upload dist/jdk4py-*.whl --username __token__ --password "$PYPI_TOKEN"
JDK4PY_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
JDK4PY_WHEEL_FILENAME: ${{ steps.build-python-wheel.outputs.filename }}
run: uv run twine upload dist/"$JDK4PY_WHEEL_FILENAME" --username __token__ --password "$JDK4PY_PYPI_TOKEN"
shell: bash
96 changes: 38 additions & 58 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,98 +5,78 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
architecture:
- x64
os:
- macos-13
- ubuntu-22.04
runner:
- macos-13 # x64
- macos-14 # arm64
- ubuntu-24.04
- ubuntu-24.04-arm64 # GitHub-hosted larger runner in the ActiveViam organization.
- windows-2022
python:
- "3.12"
include:
- architecture: arm64
os: macos-14
python: "3.12"
- architecture: x64
os: ubuntu-22.04
- runner: ubuntu-24.04
python: "3.11"
- architecture: x64
os: ubuntu-22.04
- runner: ubuntu-24.04
python: "3.10"
- architecture: x64
os: ubuntu-22.04
python: "3.9"
fail-fast: false
name: Test on ${{ matrix.os }}-${{ matrix.architecture }} with Python ${{ matrix.python }}
name: Test on ${{ matrix.runner }} with Python ${{ matrix.python }}
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/build-jdk
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python }}
- uses: ./.github/actions/build-java-runtime

- uses: ./.github/actions/create-python-wheel
with:
build-number: ${{ env.JDK4PY_BUILD_NUMBER }}
- id: build-python-wheel
uses: ./.github/actions/build-python-wheel

# No need to do that for each OS and Python version.
- if: ${{ matrix.os == 'ubuntu-22.04' && matrix.python == '3.12' }}
name: Check formatting
run: poetry run ruff format --check .
# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.12' }}
run: uv run ruff format --check .

# No need to do that for each OS and Python version.
- if: ${{ matrix.os == 'ubuntu-22.04' && matrix.python == '3.12' }}
name: Lint
run: poetry run ruff check .
# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.12' }}
run: uv run ruff check .

# No need to do that for each OS and Python version.
- if: ${{ matrix.os == 'ubuntu-22.04' && matrix.python == '3.12' }}
name: Typecheck
run: poetry run mypy --show-error-codes jdk4py scripts tests
# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.12' }}
run: uv run mypy

- run: poetry run pytest
- run: uv run pytest

# The library's Python wheels are not tied to a specific version of Python so there is no need to upload the package for each Python version.
# The Python wheels are not tied to a specific Python version.
- if: ${{ matrix.python == '3.12' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: jdk4py-${{ matrix.os }}-${{ matrix.architecture }}.whl
path: dist/jdk4py-*.whl
name: ${{ steps.build-python-wheel.outputs.filename }}
path: dist/${{ steps.build-python-wheel.outputs.filename }}

conda-package:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
architecture:
- x64
os:
- macos-13
- ubuntu-22.04
runner:
- macos-13 # x64
- macos-14 # arm64
- ubuntu-24.04
- ubuntu-24.04-arm64 # GitHub-hosted larger runner in the ActiveViam organization.
- windows-2022
include:
- architecture: arm64
os: macos-14
name: Test Conda packaging on ${{ matrix.os }}-${{ matrix.architecture }}
name: Test Conda packaging on ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/build-jdk
- uses: ./.github/actions/build-java-runtime
with:
os: ${{ matrix.os }}
# No need to test each Python version.
python-version: "3.12"

- uses: ./.github/actions/create-conda-package
with:
architecture: ${{ matrix.architecture }}
- id: build-conda-packages
uses: ./.github/actions/build-conda-packages

- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: jdk4py-${{ matrix.os }}-${{ matrix.architecture }}-conda-packages
path: dist/${{ env.JDK4PY_CONDA_PLATFORM }}/jdk4py-*.tar.bz2
name: jdk4py-${{ steps.build-conda-packages.outputs.platform }}-conda-packages
path: dist/${{ steps.build-conda-packages.outputs.platform }}/jdk4py-*.tar.bz2
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Python
__pycache__
*.egg-info
build
dist

# Java
java-runtime
.venv/
__pycache__/
build/
dist/
java-runtime/
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"ms-python.python",
"tamasfe.even-better-toml"
]
}
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnType": true
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"python.analysis.autoImportCompletions": true,
"python.languageServer": "Pylance",
"python.testing.pytestEnabled": true,
}
Loading

0 comments on commit 29afd80

Please sign in to comment.