Skip to content

Commit 662ead2

Browse files
authored
Merge pull request #91 from bact/pyproject-migrate
Add Python 3.14 support
2 parents 41395b9 + 993ebcf commit 662ead2

16 files changed

Lines changed: 308 additions & 390 deletions

.github/workflows/build-python-wheels.yml

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ name: Build wheels
66
on:
77
push:
88
branches:
9-
- main
9+
- main
1010
paths:
11-
- 'nlpo3-python/**'
12-
- '.github/workflows/build-python-wheels.yml'
11+
- "nlpo3-python/**"
12+
- ".github/workflows/build-python-wheels.yml"
1313
pull_request:
1414
branches:
15-
- main
15+
- main
1616
paths:
17-
- 'nlpo3-python/**'
18-
- '.github/workflows/build-python-wheels.yml'
17+
- "nlpo3-python/**"
18+
- ".github/workflows/build-python-wheels.yml"
1919
release:
2020
types: [published]
21-
workflow_dispatch: {} # manual run
21+
workflow_dispatch: {} # manual run
2222

2323
jobs:
2424
echo_github_env:
2525
name: Echo env variables
2626
runs-on: ubuntu-latest
2727
steps:
28-
- run: |
29-
echo "github.event.action : ${{ github.event.action }}"
30-
echo "github.event_name : ${{ github.event_name }}"
31-
echo "github.ref : ${{ github.ref }}"
32-
echo "github.ref_type : ${{ github.ref_type }}"
33-
echo "github.event.ref : ${{ github.event.ref }}"
28+
- run: |
29+
echo "github.event.action : ${{ github.event.action }}"
30+
echo "github.event_name : ${{ github.event_name }}"
31+
echo "github.ref : ${{ github.ref }}"
32+
echo "github.ref_type : ${{ github.ref_type }}"
33+
echo "github.event.ref : ${{ github.event.ref }}"
3434
3535
# Check whether to build the wheels and the source tarball
3636
check_build_trigger:
@@ -41,14 +41,14 @@ jobs:
4141
outputs:
4242
build: ${{ steps.check_build_trigger.outputs.build }}
4343
steps:
44-
- name: Checkout source code
45-
uses: actions/checkout@v4
46-
with:
47-
ref: ${{ github.event.pull_request.head.sha }}
48-
- id: check_build_trigger
49-
name: Check build trigger
50-
run: bash build_tools/github/check_build_trigger.sh
51-
# To trigger the build steps, add "[cd build]" to commit message
44+
- name: Checkout source code
45+
uses: actions/checkout@v4
46+
with:
47+
ref: ${{ github.event.pull_request.head.sha }}
48+
- id: check_build_trigger
49+
name: Check build trigger
50+
run: bash build_tools/github/check_build_trigger.sh
51+
# To trigger the build steps, add "[cd build]" to commit message
5252

5353
build_wheels:
5454
name: Build ${{ matrix.os }}
@@ -60,84 +60,84 @@ jobs:
6060
fail-fast: false
6161
matrix:
6262
os: [macos-latest, ubuntu-latest, windows-latest]
63-
python-version: ["3.13"]
63+
python-version: ["3.14"] # Check with PyO3's maximum supported version
6464
env:
65-
CIBW_BUILD: "" # blank, let cibuildwheel build all supported platforms
65+
CIBW_BUILD: "" # blank, let cibuildwheel build all supported platforms
6666

6767
steps:
68-
- name: Checkout source code
69-
uses: actions/checkout@v6
68+
- name: Checkout source code
69+
uses: actions/checkout@v6
7070

71-
- name: Setup Python
72-
uses: actions/setup-python@v6
73-
with:
74-
python-version: ${{ matrix.python-version }}
75-
cache: "pip"
76-
- name: Install Python dependencies
77-
run: python -m pip install --upgrade pip
71+
- name: Setup Python
72+
uses: actions/setup-python@v6
73+
with:
74+
python-version: ${{ matrix.python-version }}
75+
cache: "pip"
76+
- name: Install Python dependencies
77+
run: python -m pip install --upgrade pip
7878

79-
- name: Setup Rust toolchain
80-
if: startsWith(matrix.os, 'ubuntu-') == false
81-
uses: actions-rust-lang/setup-rust-toolchain@v1
82-
# For Linux, Rust will be installed inside a cibuildwheel container later
79+
- name: Setup Rust toolchain
80+
if: startsWith(matrix.os, 'ubuntu-') == false
81+
uses: actions-rust-lang/setup-rust-toolchain@v1
82+
# For Linux, Rust will be installed inside a cibuildwheel container later
8383

84-
- name: Setup rustup target
85-
if: startsWith(matrix.os, 'macos-')
86-
run: rustup target add x86_64-apple-darwin
87-
# For cross-compile x86 on GitHub arm64 runner
84+
- name: Setup rustup target
85+
if: startsWith(matrix.os, 'macos-')
86+
run: rustup target add x86_64-apple-darwin
87+
# For cross-compile x86 on GitHub arm64 runner
8888

89-
- name: Build Python wheels
90-
uses: pypa/cibuildwheel@v3
91-
with:
92-
package-dir: nlpo3-python
93-
output-dir: wheelhouse
94-
env:
95-
CIBW_BUILD_VERBOSITY: 1
96-
# See CIBW_BUILD, CIBW_SKIP, CIBW_ARCHS and other build selectors at:
97-
# https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip
98-
CIBW_SKIP: "*-musllinux_i686"
99-
CIBW_ARCHS_MACOS: "x86_64 arm64"
100-
CIBW_ENVIRONMENT_MACOS: |
101-
MACOSX_DEPLOYMENT_TARGET=10.9
102-
PATH="$HOME/.cargo/bin:$PATH"
103-
CC=/usr/bin/clang
104-
CXX=/usr/bin/clang++
105-
CIBW_ARCHS_LINUX: "auto"
106-
CIBW_ENVIRONMENT_LINUX: PATH="$HOME/.cargo/bin:$PATH"
107-
CIBW_BEFORE_BUILD_LINUX: |
108-
pip install --upgrade setuptools-rust
109-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
110-
# It is needed to install Rust for Linux,
111-
# because cibuildwheel on Linux runs inside a container
112-
# and the container does not have Rust.
113-
CIBW_ARCHS_WINDOWS: "AMD64 x86"
89+
- name: Build Python wheels
90+
uses: pypa/cibuildwheel@v3
91+
with:
92+
package-dir: nlpo3-python
93+
output-dir: wheelhouse
94+
env:
95+
CIBW_BUILD_VERBOSITY: 1
96+
# See CIBW_BUILD, CIBW_SKIP, CIBW_ARCHS and other build selectors at:
97+
# https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip
98+
CIBW_SKIP: "*-musllinux_i686"
99+
CIBW_ARCHS_MACOS: "x86_64 arm64"
100+
CIBW_ENVIRONMENT_MACOS: |
101+
MACOSX_DEPLOYMENT_TARGET=10.9
102+
PATH="$HOME/.cargo/bin:$PATH"
103+
CC=/usr/bin/clang
104+
CXX=/usr/bin/clang++
105+
CIBW_ARCHS_LINUX: "auto"
106+
CIBW_ENVIRONMENT_LINUX: PATH="$HOME/.cargo/bin:$PATH"
107+
CIBW_BEFORE_BUILD_LINUX: |
108+
pip install --upgrade setuptools-rust
109+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
110+
# It is needed to install Rust for Linux,
111+
# because cibuildwheel on Linux runs inside a container
112+
# and the container does not have Rust.
113+
CIBW_ARCHS_WINDOWS: "AMD64 x86"
114114

115-
- name: Store artifacts
116-
uses: actions/upload-artifact@v6
117-
with:
118-
path: ./wheelhouse/*.whl
115+
- name: Store artifacts
116+
uses: actions/upload-artifact@v6
117+
with:
118+
path: ./wheelhouse/*.whl
119119

120120
build_sdist:
121121
name: Build source distribution
122122
runs-on: ubuntu-latest
123123
needs: check_build_trigger
124124
if: needs.check_build_trigger.outputs.build
125125
steps:
126-
- name: Checkout source code
127-
uses: actions/checkout@v6
128-
- name: Setup Python
129-
uses: actions/setup-python@v6
130-
with:
131-
python-version: "3.13"
132-
cache: "pip"
133-
- name: Build source distribution
134-
run: |
135-
cd nlpo3-python
136-
bash ../build_tools/github/build_source.sh
137-
- name: Store artifacts
138-
uses: actions/upload-artifact@v6
139-
with:
140-
path: nlpo3-python/dist/*.tar.gz
126+
- name: Checkout source code
127+
uses: actions/checkout@v6
128+
- name: Setup Python
129+
uses: actions/setup-python@v6
130+
with:
131+
python-version: "3.14" # Check with PyO3's maximum supported version
132+
cache: "pip"
133+
- name: Build source distribution
134+
run: |
135+
cd nlpo3-python
136+
bash ../build_tools/github/build_source.sh
137+
- name: Store artifacts
138+
uses: actions/upload-artifact@v6
139+
with:
140+
path: nlpo3-python/dist/*.tar.gz
141141

142142
publish_pypi:
143143
name: Publish to PyPI
@@ -148,14 +148,14 @@ jobs:
148148
# Alternatively, upload to PyPI on every tag starting with 'v':
149149
#if: github.event_name == 'push' && startsWith(github.event.ref, 'v')
150150
steps:
151-
- name: Retrieve artifacts
152-
uses: actions/download-artifact@v6
153-
with:
154-
name: artifact
155-
path: dist
156-
- name: Publish package
157-
uses: pypa/gh-action-pypi-publish@v1
158-
with:
159-
skip-existing: true
160-
user: __token__
161-
password: ${{ secrets.PYPI_API_TOKEN }}
151+
- name: Retrieve artifacts
152+
uses: actions/download-artifact@v6
153+
with:
154+
name: artifact
155+
path: dist
156+
- name: Publish package
157+
uses: pypa/gh-action-pypi-publish@v1
158+
with:
159+
skip-existing: true
160+
user: __token__
161+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test-main-lib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
steps:
3434
- name: Checkout source code
35-
uses: actions/checkout@v4
35+
uses: actions/checkout@v6
3636

3737
- name: Setup Rust toolchain
3838
uses: actions-rust-lang/setup-rust-toolchain@v1

.github/workflows/test-nlpo3-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
steps:
3232
- name: Checkout source code
33-
uses: actions/checkout@v4
33+
uses: actions/checkout@v6
3434

3535
- name: Setup Rust toolchain - non-win32
3636
uses: actions-rs/toolchain@v1

.github/workflows/test-nlpo3-python.yml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ name: Test nlpo3-python
22
on:
33
push:
44
branches:
5-
- main
5+
- main
66
paths:
7-
- 'nlpo3-python/**'
8-
- '!notebooks/'
9-
- '!LICENSE'
10-
- '!*.md'
7+
- "nlpo3-python/**"
8+
- "!notebooks/"
9+
- "!LICENSE"
10+
- "!*.md"
1111
pull_request:
1212
branches:
13-
- main
13+
- main
1414
paths:
15-
- 'nlpo3-python/**'
16-
- '!notebooks/'
17-
- '!LICENSE'
18-
- '!*.md'
15+
- "nlpo3-python/**"
16+
- "!notebooks/"
17+
- "!LICENSE"
18+
- "!*.md"
1919

2020
defaults:
2121
run:
@@ -27,27 +27,24 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
os: [macos-latest, ubuntu-latest, windows-latest]
30-
python-version: ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8", "3.7"]
31-
bitness: [64] # 32, 64
30+
python-version: ["3.14", "3.13", "3.12", "3.11", "3.10", "3.9"]
31+
bitness: [64] # 32, 64
3232
include:
3333
- os: windows-latest
3434
python-version: "3.9"
3535
bitness: 32
36-
exclude:
37-
- os: macos-latest
38-
python-version: "3.7"
3936

4037
runs-on: ${{ matrix.os }}
4138

4239
steps:
4340
- name: Checkout source code
44-
uses: actions/checkout@v4
41+
uses: actions/checkout@v6
4542

4643
- name: Setup Rust toolchain
4744
uses: actions-rust-lang/setup-rust-toolchain@v1
4845

4946
- name: Set up Python ${{ matrix.python-version }}
50-
uses: actions/setup-python@v5
47+
uses: actions/setup-python@v6
5148
with:
5249
python-version: ${{ matrix.python-version }}
5350
cache: "pip"

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ path = "src/lib.rs"
3434
crate-type = ["cdylib", "rlib"]
3535

3636
[dependencies]
37-
anyhow = "1.0.93"
38-
binary-heap-plus = "0.5.0"
39-
bytecount = "0.6.8"
40-
lazy_static = "1.5.0"
41-
rayon = "1.10.0"
42-
regex = "1.11.1"
43-
rustc-hash = "1.1.0"
44-
regex-syntax = "0.6.29"
37+
anyhow = "1.0"
38+
binary-heap-plus = "0.5"
39+
bytecount = "0.6"
40+
lazy_static = "1.5"
41+
rayon = "1.11"
42+
regex = "1.12"
43+
rustc-hash = "1.1"
44+
regex-syntax = "0.6"
4545

4646
[[test]]
4747
name = "basic"

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
SPDX-FileCopyrightText: 2024 PyThaiNLP Project
2+
SPDX-FileCopyrightText: 2024-2026 PyThaiNLP Project
33
SPDX-License-Identifier: Apache-2.0
44
---
55

@@ -9,8 +9,8 @@ SPDX-License-Identifier: Apache-2.0
99
[![Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg "Apache-2.0")](https://opensource.org/license/apache-2-0)
1010
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14082448.svg)](https://doi.org/10.5281/zenodo.14082448)
1111

12-
Thai natural language processing library in Rust,
13-
with Python and Node bindings. Formerly oxidized-thainlp.
12+
A Thai natural language processing library written in Rust,
13+
with optional Python and Node.js bindings. Formerly known as `oxidized-thainlp`.
1414

1515
To use as a library in a Rust project:
1616

@@ -40,10 +40,10 @@ pip install nlpo3
4040
## Features
4141

4242
- Thai word tokenizer
43-
- Use maximal-matching dictionary-based tokenization algorithm
44-
and honor [Thai Character Cluster][tcc] boundaries
45-
- [2.5x faster][benchmark]
46-
than similar pure Python implementation (PyThaiNLP's newmm)
43+
- Uses a maximal-matching, dictionary-based tokenization algorithm
44+
and respects [Thai Character Cluster][tcc] boundaries.
45+
- Approximately [2. faster][benchmark] than the comparable pure-Python
46+
implementation (PyThaiNLP's `newmm`).
4747
- Load a dictionary from a plain text file (one word per line)
4848
or from `Vec<String>`
4949

@@ -137,9 +137,9 @@ See more at [nlpo3-cli](./nlpo3-cli/).
137137

138138
### Dictionary
139139

140-
- For the interest of library size, nlpO3 does not assume what dictionary the
141-
user would like to use, and it does not come with a dictionary.
142-
- A dictionary is needed for the dictionary-based word tokenizer.
140+
- To keep the library small, `nlpO3` does not include a dictionary; users should
141+
provide one when using the dictionary-based tokenizer.
142+
- A dictionary is required for the dictionary-based word tokenizer.
143143
- For tokenization dictionary, try
144144
- [words_th.tx][dict-pythainlp] from [PyThaiNLP][pythainlp]
145145
- ~62,000 words

nlpo3-python/CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ identifiers:
3535
- description: This is the collection of archived snapshots of all versions of the software.
3636
type: doi
3737
value: "10.5281/zenodo.14082448"
38-
version: v1.3.1
39-
date-released: "2024-11-11"
38+
version: v1.4.0
39+
date-released: "2026-01-31"

0 commit comments

Comments
 (0)