Skip to content

Commit 341499e

Browse files
authored
Merge pull request #1188 from PyThaiNLP/copilot/simplify-configuration-files
Consolidate configuration into pyproject.toml
2 parents da8c3b6 + ce7ac9e commit 341499e

16 files changed

Lines changed: 438 additions & 367 deletions

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
python-version: "3.10"
2222
- name: Install build tools and doc build tools
2323
run: |
24-
pip install --upgrade "pip<24.1" "setuptools>=65.0.2,<=73.0.1"
24+
pip install --upgrade "pip<24.1" "setuptools>=69.0.0,<=73.0.1"
2525
pip install boto smart_open sphinx sphinx-rtd-theme
2626
# pip<24.1 because https://github.com/omry/omegaconf/pull/1195
2727
# setuptools>=65.0.2 because https://github.com/pypa/setuptools/commit/d03da04e024ad4289342077eef6de40013630a44#diff-9ea6e1e3dde6d4a7e08c7c88eceed69ca745d0d2c779f8f85219b22266efff7fR1

.github/workflows/pypi-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ jobs:
2626
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL: True
2727
run: |
2828
python -m pip install --upgrade "pip<24.1" setuptools
29-
python -m pip install -r https://raw.githubusercontent.com/PyThaiNLP/pythainlp/dev/docker_requirements.txt
30-
python -m pip install pythainlp[full]
29+
python -m pip install pythainlp[testing,full]
3130
python -m nltk.downloader omw-1.4
3231
- name: Test
3332
run: |

.github/workflows/unittest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
cache: "pip"
4242
- name: Install build tools
4343
run: |
44-
pip install --upgrade "pip<24.1" "setuptools>=65.0.2,<=73.0.1"
44+
pip install --upgrade "pip<24.1" "setuptools>=69.0.0,<=73.0.1"
4545
pip install coverage coveralls
4646
# pip<24.1 because https://github.com/omry/omegaconf/pull/1195
4747
# setuptools>=65.0.2 because https://github.com/pypa/setuptools/commit/d03da04e024ad4289342077eef6de40013630a44#diff-9ea6e1e3dde6d4a7e08c7c88eceed69ca745d0d2c779f8f85219b22266efff7fR1
@@ -70,11 +70,11 @@ jobs:
7070
# If torch for the platform is not available in PyPI, use this command:
7171
# pip install "<torch_wheel_url>"
7272
# Get wheel URL from http://download.pytorch.org/whl/torch/
73-
- name: Install dependencies from docker_requirements.txt
73+
- name: Install testing dependencies
7474
if: env.INSTALL_FULL_DEPS == 'true'
7575
env:
7676
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL: True
77-
run: pip install -r docker_requirements.txt
77+
run: pip install ".[testing]"
7878
- name: Install PyThaiNLP + dependencies (minimum)
7979
if: matrix.python-version != env.PYTHON_VERSION_LATEST && matrix.python-version != env.PYTHON_VERSION_LATEST_2
8080
run: pip install .

CONTRIBUTING.md

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
SPDX-FileCopyrightText: 2025 PyThaiNLP Project
2+
SPDX-FileCopyrightText: 2025-2026 PyThaiNLP Project
33
SPDX-FileType: DOCUMENTATION
44
SPDX-License-Identifier: CC0-1.0
55
---
@@ -108,44 +108,79 @@ Make sure the tests pass on GitHub Actions.
108108

109109
See more in [tests/README.md](./tests/README.md)
110110

111+
## Installing and Building
112+
113+
### Installing for Development
114+
115+
Install PyThaiNLP in editable mode with core dependencies:
116+
117+
```sh
118+
pip install -e .
119+
```
120+
121+
Install with optional dependency groups:
122+
123+
```sh
124+
# Install with compact set of dependencies (recommended for development)
125+
pip install -e ".[compact]"
126+
127+
# Install with full dependencies
128+
pip install -e ".[full]"
129+
130+
# Install with testing dependencies (pinned versions for reproducibility)
131+
pip install -e ".[testing]"
132+
```
133+
134+
See all available optional dependency groups in `pyproject.toml` under `[project.optional-dependencies]`.
135+
136+
### Building Distribution Packages
137+
138+
To build source distribution and wheel:
139+
140+
```sh
141+
python -m build
142+
```
143+
144+
This will create distribution packages in the `dist/` directory.
145+
111146
## Releasing
112147

113148
- We use [semantic versioning](https://semver.org/): MAJOR.MINOR.PATCH, with development build suffix: MAJOR.MINOR.PATCH-devBUILD
114-
- We use [`bumpversion`](https://github.com/c4urself/bump2version/#installation) to manage versioning.
115-
- `bumpversion [major|minor|patch|release|build]`
149+
- We use [`bump-my-version`](https://github.com/callowayproject/bump-my-version) to manage versioning. The configuration is in `pyproject.toml` under `[tool.bumpversion]`.
150+
- `bump-my-version bump [major|minor|patch|release|build]`
116151
- Example:
117152

118153
```sh
119154
#current_version = 2.3.3-dev0
120155

121-
bumpversion build
156+
bump-my-version bump build
122157
#current_version = 2.3.3-dev1
123158

124-
bumpversion build
159+
bump-my-version bump build
125160
#current_version = 2.3.3-dev2
126161

127-
bumpversion release
162+
bump-my-version bump release
128163
#current_version = 2.3.3-beta0
129164

130-
bumpversion release
165+
bump-my-version bump release
131166
#current_version = 2.3.3
132167

133-
bumpversion patch
168+
bump-my-version bump patch
134169
#current_version = 2.3.6-dev0
135170

136-
bumpversion minor
171+
bump-my-version bump minor
137172
#current_version = 2.3.1-dev0
138173

139-
bumpversion build
174+
bump-my-version bump build
140175
#current_version = 2.3.1-dev1
141176

142-
bumpversion major
177+
bump-my-version bump major
143178
#current_version = 3.0.0-dev0
144179

145-
bumpversion release
180+
bump-my-version bump release
146181
#current_version = 3.0.0-beta0
147182

148-
bumpversion release
183+
bump-my-version bump release
149184
#current_version = 3.0.0
150185
```
151186

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN apt-get update && apt-get install -y --no-install-recommends build-essential
1212
ENV VIRTUAL_ENV=/opt/venv
1313
RUN python3 -m venv $VIRTUAL_ENV
1414
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
15-
RUN if [ -f docker_requirements.txt ]; then pip install -r docker_requirements.txt; fi
16-
RUN pip install -e .[full] && pip cache purge
15+
# Install PyThaiNLP with testing dependencies (replaces docker_requirements.txt)
16+
RUN pip install -e ".[testing]" && pip cache purge

Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,24 @@ lint: ## check style with flake8
5050
flake8 pythainlp tests
5151

5252
test: ## run tests quickly with the default Python
53-
python setup.py test
53+
python -m unittest discover
5454

5555
test-all: ## run tests on every Python version with tox
5656
tox
5757

5858
coverage: ## check code coverage quickly with the default Python
59-
coverage run --source pythainlp setup.py test
59+
coverage run --source pythainlp -m unittest discover
6060
coverage report -m
6161
coverage html
6262
$(BROWSER) htmlcov/index.html
6363

64-
release: clean ## package and upload a release
65-
python setup.py sdist upload
66-
python setup.py bdist_wheel upload
64+
release: clean ## package and upload a release (deprecated - use GitHub Actions)
65+
python -m build
66+
python -m twine upload dist/*
6767

6868
dist: clean ## builds source and wheel package
69-
python setup.py sdist
70-
python setup.py bdist_wheel
69+
python -m build
7170
ls -l dist
7271

7372
install: clean ## install the package to the active Python's site-packages
74-
python setup.py install
73+
python -m pip install .

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pip install pythainlp
3131

3232
## Getting Started
3333

34-
- PyThaiNLP requires Python 3.7+.
34+
- PyThaiNLP requires Python 3.9+.
3535
- Python 2.7 users can use PyThaiNLP 1.6. See [2.0 change log](https://github.com/PyThaiNLP/pythainlp/issues/118) | [Upgrading from 1.7](https://pythainlp.org/docs/2.0/notes/pythainlp-1_7-2_0.html) | [Upgrading ThaiNER from 1.7](https://github.com/PyThaiNLP/pythainlp/wiki/Upgrade-ThaiNER-from-PyThaiNLP-1.7-to-PyThaiNLP-2.0)
3636
- [PyThaiNLP Get Started notebook](https://pythainlp.org/tutorials/notebooks/pythainlp_get_started.html) | [API document](https://pythainlp.org/docs) | [Tutorials](https://pythainlp.org/tutorials)
3737
- [Official website](https://pythainlp.org/) | [PyPI](https://pypi.org/project/pythainlp/) | [Facebook page](https://www.facebook.com/pythainlp/)
@@ -81,17 +81,43 @@ Possible `extras`:
8181

8282
- `full` (install everything)
8383
- `compact` (install a stable and small subset of dependencies)
84+
- `abbreviation` (for Thai abbreviation support)
8485
- `attacut` (to support attacut, a fast and accurate tokenizer)
8586
- `benchmarks` (for [word tokenization benchmarking](tokenization-benchmark.md))
87+
- `budoux` (for BudouX text segmentation)
88+
- `coreference_resolution` (for coreference resolution)
89+
- `dependency_parsing` (for dependency parsing)
90+
- `el` (for entity linking)
91+
- `esupar` (for esupar parser support)
92+
- `generate` (for text generation)
8693
- `icu` (for ICU, International Components for Unicode, support in transliteration and tokenization)
8794
- `ipa` (for IPA, International Phonetic Alphabet, support in transliteration)
8895
- `ml` (to support ULMFiT models for classification)
96+
- `mt5` (for mT5 model support)
97+
- `nlpo3` (for nlpo3 Thai word tokenizer)
98+
- `onnx` (for ONNX model support)
99+
- `oskut` (for OSKut Thai word tokenizer)
100+
- `sefr_cut` (for SEFR CUT Thai word tokenizer)
101+
- `spacy_thai` (for spaCy Thai language support)
102+
- `spell` (for spelling correction)
103+
- `ssg` (for sentence segmentation)
104+
- `testing` (pinned versions for CI/CD reproducibility)
105+
- `textaugment` (for text augmentation)
106+
- `thai_nner` (for Thai named entity recognition)
89107
- `thai2fit` (for Thai word vector)
90108
- `thai2rom` (for machine-learnt romanization)
109+
- `transformers_ud` (for Universal Dependencies with transformers)
110+
- `translate` (for machine translation)
111+
- `wangchanberta` (for WangchanBERTa model)
112+
- `wangchanglm` (for WangchanGLM model)
113+
- `word_approximation` (for word approximation)
91114
- `wordnet` (for Thai WordNet API)
115+
- `wsd` (for word sense disambiguation)
116+
- `wtp` (for Where's the Point text segmentation)
117+
- `wunsen` (for Wunsen spell checker)
92118

93-
For dependency details, look at the `extras` variable in
94-
[`setup.py`](https://github.com/PyThaiNLP/pythainlp/blob/dev/setup.py).
119+
For dependency details, look at the `[project.optional-dependencies]` section in
120+
[`pyproject.toml`](https://github.com/PyThaiNLP/pythainlp/blob/dev/pyproject.toml).
95121

96122
## Data Directory
97123

README_TH.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,44 @@ pip install pythainlp[extra1,extra2,...]
8686

8787
- `full` (ติดตั้งทุกอย่าง)
8888
- `compact` (ติดตั้งไลบารีชุดเล็กที่ทดสอบแล้วว่าไม่ตีกันเองและติดตั้งได้ในทุกระบบปฏิบัติการ)
89+
- `abbreviation` (สำหรับการย่อคำภาษาไทย)
8990
- `attacut` (เพื่อสนับสนุน attacut ซึ่งเป็นตัวตัดคำที่ทำงานได้รวดเร็วและมีประสิทธิภาพ)
9091
- `benchmarks` (สำหรับ [word tokenization benchmarking](tokenization-benchmark.md))
92+
- `budoux` (สำหรับการแบ่งข้อความด้วย BudouX)
93+
- `coreference_resolution` (สำหรับการหาคำที่อ้างอิงถึงกัน)
94+
- `dependency_parsing` (สำหรับการวิเคราะห์โครงสร้างประโยค)
95+
- `el` (สำหรับการเชื่อมโยงเอนทิตี)
96+
- `esupar` (สำหรับการรองรับ esupar parser)
97+
- `generate` (สำหรับการสร้างข้อความ)
9198
- `icu` (สำหรับการรองรับ ICU หรือ International Components for Unicode ในการถอดเสียงเป็นอักษรและการตัดแบ่งคำ)
9299
- `ipa` (สำหรับการรองรับ IPA หรือ International Phonetic Alphabet ในการถอดเสียงเป็นอักษร)
93100
- `ml` (เพื่อให้สนับสนุนตัวแบบภาษา ULMFiT สำหรับการจำแนกข้อความ)
101+
- `mt5` (สำหรับรองรับโมเดล mT5)
102+
- `nlpo3` (สำหรับตัวตัดคำภาษาไทย nlpo3)
103+
- `onnx` (สำหรับรองรับโมเดล ONNX)
104+
- `oskut` (สำหรับตัวตัดคำภาษาไทย OSKut)
105+
- `sefr_cut` (สำหรับตัวตัดคำภาษาไทย SEFR CUT)
106+
- `spacy_thai` (สำหรับรองรับภาษาไทยใน spaCy)
107+
- `spell` (สำหรับการแก้ไขคำสะกดผิด)
108+
- `ssg` (สำหรับการแบ่งประโยค)
109+
- `testing` (เวอร์ชันที่ปักหมุดสำหรับ CI/CD)
110+
- `textaugment` (สำหรับการเพิ่มข้อมูลข้อความ)
111+
- `thai_nner` (สำหรับการจดจำชื่อเฉพาะภาษาไทย)
94112
- `thai2fit` (สำหรับ Thai word vector)
95113
- `thai2rom` (สำหรับการถอดอักษรไทยเป็นอักษรโรมัน)
114+
- `transformers_ud` (สำหรับ Universal Dependencies ด้วย transformers)
115+
- `translate` (สำหรับการแปลภาษา)
116+
- `wangchanberta` (สำหรับโมเดล WangchanBERTa)
117+
- `wangchanglm` (สำหรับโมเดล WangchanGLM)
118+
- `word_approximation` (สำหรับการประมาณคำ)
96119
- `wordnet` (สำหรับ Thai WordNet API)
120+
- `wsd` (สำหรับการแก้ความกำกวมของความหมายคำ)
121+
- `wtp` (สำหรับการแบ่งข้อความด้วย Where's the Point)
122+
- `wunsen` (สำหรับตัวตรวจการสะกดคำ Wunsen)
97123

98124
</details>
99125

100-
สำหรับโมดูลที่ต้องการ สามารถดูรายละเอียดได้ที่ตัวแปร `extras` ใน [`setup.py`](https://github.com/PyThaiNLP/pythainlp/blob/dev/setup.py).
126+
สำหรับโมดูลที่ต้องการ สามารถดูรายละเอียดได้ที่ส่วน `[project.optional-dependencies]` ใน [`pyproject.toml`](https://github.com/PyThaiNLP/pythainlp/blob/dev/pyproject.toml).
101127

102128
## Command-line
103129

@@ -117,7 +143,7 @@ thainlp help
117143

118144
## ผู้ใช้งาน Python 2
119145

120-
- PyThaiNLP สนับสนุน Python 3.7 ขึ้นไป บางความสามารถ สามารถใช้งานกับ Python 3 รุ่นก่อนหน้าได้ แต่ไม่ได้มีการทดสอบว่าใช้งานได้หรือไม่ อ่านเพิ่มเติม [1.7 -> 2.0 change log](https://github.com/PyThaiNLP/pythainlp/issues/118).
146+
- PyThaiNLP สนับสนุน Python 3.9 ขึ้นไป บางความสามารถ สามารถใช้งานกับ Python 3 รุ่นก่อนหน้าได้ แต่ไม่ได้มีการทดสอบว่าใช้งานได้หรือไม่ อ่านเพิ่มเติม [1.7 -> 2.0 change log](https://github.com/PyThaiNLP/pythainlp/issues/118).
121147
- [Upgrading from 1.7](https://pythainlp.org/docs/2.0/notes/pythainlp-1_7-2_0.html)
122148
- [Upgrade ThaiNER from 1.7](https://github.com/PyThaiNLP/pythainlp/wiki/Upgrade-ThaiNER-from-PyThaiNLP-1.7-to-PyThaiNLP-2.0)
123149
- ผู้ใช้งาน Python 2.7 สามารถใช้งาน PyThaiNLP 1.6

codemeta.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"@type": "SoftwareSourceCode",
44
"name": "PyThaiNLP",
55
"description": "Thai Natural Language Processing in Python",
6-
"version": "5.1.0",
6+
"version": "5.2.0",
77
"author": [
88
{
99
"@type": "Person",
@@ -61,15 +61,15 @@
6161
"issueTracker": "https://github.com/PyThaiNLP/pythainlp/issues",
6262
"url": "https://pythainlp.org/",
6363
"keywords": [
64+
"NLP",
6465
"natural language processing",
65-
"Thai",
66-
"Python",
66+
"tokenization",
6767
"text processing",
68+
"linguistics",
69+
"localization",
6870
"computational linguistics",
69-
"tokenization",
70-
"word segmentation",
71-
"NLP",
72-
"Thai language",
73-
"Thai NLP"
71+
"ThaiNLP",
72+
"Thai NLP",
73+
"Thai language"
7474
]
7575
}

docker_requirements.txt

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)