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

Publish with uv and add support for Python 3.13 #82

Merged
merged 10 commits into from
Jan 13, 2025
Merged
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
8 changes: 7 additions & 1 deletion .github/actions/build-conda-packages/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ runs:
steps:
- uses: conda-incubator/setup-miniconda@v3
with:
conda-build-version: "24.7.1"
conda-build-version: "24.11.2"
conda-remove-defaults: true

# See https://github.com/conda/conda/issues/12563#issuecomment-1494264704.
- if: ${{ runner.os == 'Windows' }}
run: echo "LIBARCHIVE=C:\\Miniconda\\Library\\bin\\archive.dll" >> "$GITHUB_ENV"
shell: bash -l {0}

- run: conda build --no-anaconda-upload --output-folder dist .
# See https://github.com/conda-incubator/setup-miniconda/blame/059455a698430d8b68fa317268fa2e3da3492a98/README.md#L609-L610.
Expand Down
14 changes: 3 additions & 11 deletions .github/actions/build-java-runtime/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ inputs:
runs:
using: composite
steps:
- uses: astral-sh/setup-uv@v2
- uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: "uv.lock"
# The cache key already contains the OS and the architecture.
cache-suffix: ${{ inputs.python-version }}
enable-cache: true
version: "0.4.7"

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

- run: uv sync --locked
shell: bash
python-version: ${{ inputs.python-version }}
version: "0.5.16"

- 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"
Expand Down
10 changes: 0 additions & 10 deletions .github/actions/build-python-wheel/action.yaml

This file was deleted.

14 changes: 4 additions & 10 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
python-version: "3.10"

- uses: ./.github/actions/build-python-wheel
- run: uv build --wheel

- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -53,7 +53,8 @@ jobs:
merge-multiple: true
path: dist/

- name: List Conda packages and Python wheels
- if: ${{ runner.debug == '1' }}
name: List Conda packages and Python wheels
run: ls -R dist/

- name: Publish Conda packages
Expand All @@ -70,12 +71,5 @@ jobs:
done
shell: bash

# Conda packages are nested inside platform specific directories.
# Deleting all sub directories only leaves Python wheels in `dist/`.
# This is required to not confuse `twine upload` when `dist/*` is passed.
# See https://github.com/pypa/gh-action-pypi-publish/blob/36978192ca7715ea2e0d12e82d5518a651a9f739/twine-upload.sh#L208C43-L208C61.
- name: Keep only Python wheels
run: rm -R -- dist/*/

- name: Publish Python wheels
uses: pypa/gh-action-pypi-publish@release/v1
run: uv publish
8 changes: 5 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
python: "3.11"
- runner: ubuntu-24.04
python: "3.12"
- runner: ubuntu-24.04
python: "3.13"
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand All @@ -30,15 +32,15 @@ jobs:
with:
python-version: ${{ matrix.python}}

- uses: ./.github/actions/build-python-wheel
- run: uv build --wheel

# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.10' }}
run: uv run ruff format --check .
run: uv run ruff format --check

# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.10' }}
run: uv run ruff check .
run: uv run ruff check

# No need to test each platform and Python version.
- if: ${{ matrix.runner == 'ubuntu-24.04' && matrix.python == '3.10' }}
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ PosixPath('/Users/johndoe/dev/jdk4py/jdk4py/java-runtime')
PosixPath('/Users/johndoe/dev/jdk4py/jdk4py/java-runtime/bin/java')
>>> JAVA_VERSION
(21, 0, 4)
>>> from subprocess import check_output
>>> from subprocess import run
>>> some_java_options = ["-Xmx16G", "-Xms2G"]
>>> check_output([JAVA, "-jar", "HelloWorld.jar", *some_java_options])
b"Hello, World!"
>>> run(
... [JAVA, "-jar", "HelloWorld.jar", *some_java_options],
... capture_output=True,
... check=True,
... text=True,
... ).stdout.strip()
"Hello, World!"
```

## Versioning
Expand Down
1 change: 1 addition & 0 deletions conda.recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ python:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build-backend = "hatchling.build"
requires = [
# Keep pinned to ensure same version is used by `conda build` (version must be available on anaconda).
# Keep in sync with version in `tool.uv.dev-dependencies`.
"hatchling ==1.21.1",
"hatchling ==1.27.0",
]

[project]
Expand Down Expand Up @@ -47,14 +47,17 @@ filterwarnings = ["error"]

[tool.ruff.lint]
ignore = [
"COM812",
"D100",
"D101",
"D102",
"D103",
"D104",
"D203",
"D211",
"D212",
"EM102",
"ISC001",
"S101",
"TRY003",
]
Expand All @@ -63,10 +66,11 @@ select = ["ALL"]
[tool.uv]
dev-dependencies = [
# Keep in sync with version in `build-system.requires`.
"hatchling ==1.21.1",
"hatchling ==1.27.0",
"mypy",
# Keep pinned to ensure same version is used by `conda build` (version must be available on anaconda).
"pytest ==7.4.4",
"ruff",
"twine",
]
required-version = ">=0.5.16,<0.6"
trusted-publishing = "always"
2 changes: 1 addition & 1 deletion src/jdk4py/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"21.0.4.1"
"21.0.4.2"
32 changes: 19 additions & 13 deletions tests/test_jdk4py.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from pathlib import Path
from subprocess import STDOUT, check_output
from subprocess import run

from jdk4py import JAVA, JAVA_VERSION
from jdk4py._included_locales import INCLUDED_LOCALES
Expand All @@ -9,32 +9,38 @@


def test_java_version() -> None:
output = check_output( # noqa: S603
completed_process = run( # noqa: S603
[JAVA, "-version"],
stderr=STDOUT,
capture_output=True,
check=True,
text=True,
)
match = re.match(r'^openjdk version "(?P<version>[^"]+)"', output)
assert match, f"Unexpected output:\n{output}"
match = re.match(r'^openjdk version "(?P<version>[^"]+)"', completed_process.stderr)
assert match, f"Unexpected output:\n{completed_process.stdout}"
version = match.group("version")
assert isinstance(version, str)
assert tuple([int(number) for number in version.split(".")][:3]) == JAVA_VERSION


def test_jar_execution() -> None:
output = check_output( # noqa: S603
completed_process = run( # noqa: S603
[JAVA, "-jar", _TEST_RESOURCES_DIRECTORY / "HelloWorld.jar"],
stderr=STDOUT,
capture_output=True,
check=True,
text=True,
).strip()
assert output == "Hello, World"
)
assert completed_process.stdout.strip() == "Hello, World"


def test_included_locales() -> None:
output = check_output( # noqa: S603
completed_process = run( # noqa: S603
[JAVA, "-jar", _TEST_RESOURCES_DIRECTORY / "PrintAvailableLocales.jar"],
stderr=STDOUT,
capture_output=True,
check=True,
text=True,
).strip()
locales = {locale.replace("_", "-") for locale in output.splitlines()}
)
locales = {
locale.replace("_", "-")
for locale in completed_process.stdout.strip().splitlines()
}
assert locales.issuperset(INCLUDED_LOCALES)
Loading
Loading