Skip to content

Commit 255596d

Browse files
authored
Publish with uv and add support for Python 3.13 (#82)
1 parent a695001 commit 255596d

File tree

11 files changed

+150
-557
lines changed

11 files changed

+150
-557
lines changed

.github/actions/build-conda-packages/action.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ runs:
55
steps:
66
- uses: conda-incubator/setup-miniconda@v3
77
with:
8-
conda-build-version: "24.7.1"
8+
conda-build-version: "24.11.2"
9+
conda-remove-defaults: true
10+
11+
# See https://github.com/conda/conda/issues/12563#issuecomment-1494264704.
12+
- if: ${{ runner.os == 'Windows' }}
13+
run: echo "LIBARCHIVE=C:\\Miniconda\\Library\\bin\\archive.dll" >> "$GITHUB_ENV"
14+
shell: bash -l {0}
915

1016
- run: conda build --no-anaconda-upload --output-folder dist .
1117
# See https://github.com/conda-incubator/setup-miniconda/blame/059455a698430d8b68fa317268fa2e3da3492a98/README.md#L609-L610.

.github/actions/build-java-runtime/action.yaml

+3-11
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,11 @@ inputs:
77
runs:
88
using: composite
99
steps:
10-
- uses: astral-sh/setup-uv@v2
10+
- uses: astral-sh/setup-uv@v5
1111
with:
12-
cache-dependency-glob: "uv.lock"
13-
# The cache key already contains the OS and the architecture.
14-
cache-suffix: ${{ inputs.python-version }}
1512
enable-cache: true
16-
version: "0.4.7"
17-
18-
- run: uv python install ${{ inputs.python-version }}
19-
shell: bash
20-
21-
- run: uv sync --locked
22-
shell: bash
13+
python-version: ${{ inputs.python-version }}
14+
version: "0.5.16"
2315

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

.github/actions/build-python-wheel/action.yaml

-10
This file was deleted.

.github/workflows/deployment.yaml

+4-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
python-version: "3.10"
2525

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

2828
- uses: actions/upload-artifact@v4
2929
with:
@@ -53,7 +53,8 @@ jobs:
5353
merge-multiple: true
5454
path: dist/
5555

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

5960
- name: Publish Conda packages
@@ -70,12 +71,5 @@ jobs:
7071
done
7172
shell: bash
7273

73-
# Conda packages are nested inside platform specific directories.
74-
# Deleting all sub directories only leaves Python wheels in `dist/`.
75-
# This is required to not confuse `twine upload` when `dist/*` is passed.
76-
# See https://github.com/pypa/gh-action-pypi-publish/blob/36978192ca7715ea2e0d12e82d5518a651a9f739/twine-upload.sh#L208C43-L208C61.
77-
- name: Keep only Python wheels
78-
run: rm -R -- dist/*/
79-
8074
- name: Publish Python wheels
81-
uses: pypa/gh-action-pypi-publish@release/v1
75+
run: uv publish

.github/workflows/test.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
python: "3.11"
2323
- runner: ubuntu-24.04
2424
python: "3.12"
25+
- runner: ubuntu-24.04
26+
python: "3.13"
2527
fail-fast: false
2628
steps:
2729
- uses: actions/checkout@v4
@@ -30,15 +32,15 @@ jobs:
3032
with:
3133
python-version: ${{ matrix.python}}
3234

33-
- uses: ./.github/actions/build-python-wheel
35+
- run: uv build --wheel
3436

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

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

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

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ PosixPath('/Users/johndoe/dev/jdk4py/jdk4py/java-runtime')
2727
PosixPath('/Users/johndoe/dev/jdk4py/jdk4py/java-runtime/bin/java')
2828
>>> JAVA_VERSION
2929
(21, 0, 4)
30-
>>> from subprocess import check_output
30+
>>> from subprocess import run
3131
>>> some_java_options = ["-Xmx16G", "-Xms2G"]
32-
>>> check_output([JAVA, "-jar", "HelloWorld.jar", *some_java_options])
33-
b"Hello, World!"
32+
>>> run(
33+
... [JAVA, "-jar", "HelloWorld.jar", *some_java_options],
34+
... capture_output=True,
35+
... check=True,
36+
... text=True,
37+
... ).stdout.strip()
38+
"Hello, World!"
3439
```
3540

3641
## Versioning

conda.recipe/conda_build_config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ python:
22
- "3.10"
33
- "3.11"
44
- "3.12"
5+
- "3.13"

pyproject.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ build-backend = "hatchling.build"
33
requires = [
44
# Keep pinned to ensure same version is used by `conda build` (version must be available on anaconda).
55
# Keep in sync with version in `tool.uv.dev-dependencies`.
6-
"hatchling ==1.21.1",
6+
"hatchling ==1.27.0",
77
]
88

99
[project]
@@ -47,14 +47,17 @@ filterwarnings = ["error"]
4747

4848
[tool.ruff.lint]
4949
ignore = [
50+
"COM812",
5051
"D100",
5152
"D101",
5253
"D102",
5354
"D103",
5455
"D104",
56+
"D203",
5557
"D211",
5658
"D212",
5759
"EM102",
60+
"ISC001",
5861
"S101",
5962
"TRY003",
6063
]
@@ -63,10 +66,11 @@ select = ["ALL"]
6366
[tool.uv]
6467
dev-dependencies = [
6568
# Keep in sync with version in `build-system.requires`.
66-
"hatchling ==1.21.1",
69+
"hatchling ==1.27.0",
6770
"mypy",
6871
# Keep pinned to ensure same version is used by `conda build` (version must be available on anaconda).
6972
"pytest ==7.4.4",
7073
"ruff",
71-
"twine",
7274
]
75+
required-version = ">=0.5.16,<0.6"
76+
trusted-publishing = "always"

src/jdk4py/version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"21.0.4.1"
1+
"21.0.4.2"

tests/test_jdk4py.py

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22
from pathlib import Path
3-
from subprocess import STDOUT, check_output
3+
from subprocess import run
44

55
from jdk4py import JAVA, JAVA_VERSION
66
from jdk4py._included_locales import INCLUDED_LOCALES
@@ -9,32 +9,38 @@
99

1010

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

2324

2425
def test_jar_execution() -> None:
25-
output = check_output( # noqa: S603
26+
completed_process = run( # noqa: S603
2627
[JAVA, "-jar", _TEST_RESOURCES_DIRECTORY / "HelloWorld.jar"],
27-
stderr=STDOUT,
28+
capture_output=True,
29+
check=True,
2830
text=True,
29-
).strip()
30-
assert output == "Hello, World"
31+
)
32+
assert completed_process.stdout.strip() == "Hello, World"
3133

3234

3335
def test_included_locales() -> None:
34-
output = check_output( # noqa: S603
36+
completed_process = run( # noqa: S603
3537
[JAVA, "-jar", _TEST_RESOURCES_DIRECTORY / "PrintAvailableLocales.jar"],
36-
stderr=STDOUT,
38+
capture_output=True,
39+
check=True,
3740
text=True,
38-
).strip()
39-
locales = {locale.replace("_", "-") for locale in output.splitlines()}
41+
)
42+
locales = {
43+
locale.replace("_", "-")
44+
for locale in completed_process.stdout.strip().splitlines()
45+
}
4046
assert locales.issuperset(INCLUDED_LOCALES)

0 commit comments

Comments
 (0)