Skip to content

Commit edf3630

Browse files
authored
Merge pull request #242 from nielstron/feature/migrate-uv-github-actions
2 parents 168aef7 + ba35bcd commit edf3630

24 files changed

+2014
-219
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
- language_support
9+
pull_request:
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: astral-sh/setup-uv@v6
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Sync dependencies
27+
run: uv sync --extra classifier
28+
29+
- name: Smoke import
30+
run: uv run python scripts/test_import_error.py
31+
32+
- name: Build generated assets
33+
run: uv run python scripts/build.py
34+
35+
- name: Run test suite
36+
run: |
37+
uv run pytest \
38+
quantulum3/tests/test_setup.py \
39+
quantulum3/tests/test_hypothesis.py \
40+
quantulum3/tests/test_no_classifier.py \
41+
quantulum3/tests/test_parse_ranges.py \
42+
quantulum3/_lang/en_US/tests/extract_spellout_values.py \
43+
quantulum3/tests/test_classes.py \
44+
quantulum3/tests/test_scripts.py \
45+
quantulum3/tests/test_load.py
46+
47+
- name: Run classifier tests
48+
run: uv run pytest quantulum3/tests/test_classifier.py -k "not test_wikipedia_pages"

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: astral-sh/setup-uv@v6
18+
with:
19+
python-version: "3.13"
20+
21+
- name: Sync dependencies
22+
run: uv sync --extra classifier
23+
24+
- name: Build generated assets
25+
run: uv run python scripts/build.py
26+
27+
- name: Build distributions
28+
run: uv build
29+
30+
- uses: actions/upload-artifact@v4
31+
with:
32+
name: dist
33+
path: dist/*
34+
35+
publish:
36+
needs: build
37+
runs-on: ubuntu-latest
38+
if: github.event_name == 'release'
39+
permissions:
40+
id-token: write
41+
42+
steps:
43+
- uses: actions/download-artifact@v4
44+
with:
45+
name: dist
46+
path: dist
47+
48+
- uses: pypa/gh-action-pypi-publish@release/v1

.travis.yml

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

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

Pipfile

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

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# quantulum3
22

3-
[![Travis master build state](https://app.travis-ci.com/nielstron/quantulum3.svg?branch=master "Travis master build state")](https://app.travis-ci.com/nielstron/quantulum3)
3+
[![CI](https://github.com/nielstron/quantulum3/actions/workflows/ci.yml/badge.svg)](https://github.com/nielstron/quantulum3/actions/workflows/ci.yml)
44
[![Coverage Status](https://coveralls.io/repos/github/nielstron/quantulum3/badge.svg?branch=master)](https://coveralls.io/github/nielstron/quantulum3?branch=master)
55
[![PyPI version](https://badge.fury.io/py/quantulum3.svg)](https://pypi.org/project/quantulum3/)
66
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/quantulum3.svg)
@@ -26,12 +26,24 @@ the fork of [sohrabtowfighi](https://github.com/sohrabtowfighi/quantulum).
2626
pip install quantulum3
2727
```
2828

29+
Or with `uv`:
30+
31+
```bash
32+
uv add quantulum3
33+
```
34+
2935
To install dependencies for using or training the disambiguation classifier, use
3036

3137
```bash
3238
pip install quantulum3[classifier]
3339
```
3440

41+
Or with `uv`:
42+
43+
```bash
44+
uv add "quantulum3[classifier]"
45+
```
46+
3547
The disambiguation classifier is used when the parser find two or more units that are a match for the text.
3648

3749
### Usage
@@ -210,12 +222,18 @@ Use `quantulum3-training` on the command line, the script `quantulum3/scripts/tr
210222
quantulum3-training --lang <language> --data <path/to/training/file.json> --output <path/to/output/file.joblib>
211223
```
212224

225+
With `uv`, you can run the installed entry point without activating an environment:
226+
227+
```bash
228+
uv run quantulum3-training --lang <language> --data <path/to/training/file.json> --output <path/to/output/file.joblib>
229+
```
230+
213231
You can pass multiple training files in to the training command. The output is in joblib format.
214232

215233
To use your custom model, pass the path to the trained model file to the
216234
parser:
217235

218-
```pyton
236+
```python
219237
parser = Parser.parse(<text>, classifier_path="path/to/model.joblib")
220238
```
221239

@@ -346,25 +364,23 @@ All fields are case sensitive.
346364

347365
### Contributing
348366

349-
`dev` build:
367+
`dev` build:
350368

351-
[![Travis dev build state](https://travis-ci.com/nielstron/quantulum3.svg?branch=dev "Travis dev build state")](https://travis-ci.com/nielstron/quantulum3)
369+
[![CI](https://github.com/nielstron/quantulum3/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/nielstron/quantulum3/actions/workflows/ci.yml)
352370
[![Coverage Status](https://coveralls.io/repos/github/nielstron/quantulum3/badge.svg?branch=dev)](https://coveralls.io/github/nielstron/quantulum3?branch=dev)
353371

354372
If you'd like to contribute follow these steps:
355373
1. Clone a fork of this project into your workspace
356-
2. Run `pip install -e .` at the root of your development folder.
357-
3. `pip install pipenv` and `pipenv shell`
358-
4. Inside the project folder run `pipenv install --dev`
359-
5. Make your changes
360-
6. Run `scripts/format.sh` and `scripts/build.py` from the package root directory.
361-
7. Test your changes with `python3 setup.py test`
362-
(Optional, will be done automatically after pushing)
363-
8. Create a Pull Request when having commited and pushed your changes
374+
2. Run `uv sync --extra classifier`
375+
3. Commit the generated `uv.lock` changes when dependencies change
376+
4. Make your changes
377+
5. Run `scripts/format.sh` and `uv run scripts/build.py` from the package root directory. The build step regenerates `common-words.json` and `clf.joblib`.
378+
6. Test your changes with `uv run pytest`
379+
7. Create a Pull Request when you have committed and pushed your changes
364380

365381
### Language support
366382

367-
[![Travis dev build state](https://travis-ci.com/nielstron/quantulum3.svg?branch=language_support "Travis dev build state")](https://travis-ci.com/nielstron/quantulum3)
383+
[![CI](https://github.com/nielstron/quantulum3/actions/workflows/ci.yml/badge.svg?branch=language_support)](https://github.com/nielstron/quantulum3/actions/workflows/ci.yml)
368384
[![Coverage Status](https://coveralls.io/repos/github/nielstron/quantulum3/badge.svg?branch=language_support)](https://coveralls.io/github/nielstron/quantulum3?branch=dev)
369385

370386
There is a branch for language support, namely `language_support`.

pyproject.toml

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,93 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta:__legacy__"
2+
requires = ["setuptools>=69", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "quantulum3"
7+
version = "0.9.2"
8+
description = "Extract quantities from unstructured text."
9+
readme = "README.md"
10+
license = "MIT"
11+
authors = [
12+
{ name = "Marco Lagi, nielstron, sohrabtowfighi, grhawk and Rodrigo Castro", email = "n.muendler@web.de" },
13+
]
14+
requires-python = ">=3.9"
15+
dependencies = [
16+
"inflect",
17+
"num2words",
18+
]
19+
keywords = [
20+
"information extraction",
21+
"quantities",
22+
"units",
23+
"measurements",
24+
"nlp",
25+
"natural language processing",
26+
"text mining",
27+
"text processing",
28+
]
29+
classifiers = [
30+
"Development Status :: 3 - Alpha",
31+
"Intended Audience :: Developers",
32+
"Intended Audience :: Science/Research",
33+
"Natural Language :: English",
34+
"Operating System :: MacOS :: MacOS X",
35+
"Operating System :: Microsoft :: Windows",
36+
"Operating System :: POSIX",
37+
"Programming Language :: Python",
38+
"Programming Language :: Python :: 3",
39+
"Programming Language :: Python :: 3.9",
40+
"Programming Language :: Python :: 3.10",
41+
"Programming Language :: Python :: 3.11",
42+
"Programming Language :: Python :: 3.12",
43+
"Programming Language :: Python :: 3.13",
44+
"Topic :: Scientific/Engineering",
45+
"Topic :: Text Processing :: Linguistic",
46+
]
47+
48+
[project.optional-dependencies]
49+
classifier = [
50+
"joblib",
51+
"numpy",
52+
"scikit-learn",
53+
"scipy",
54+
"stemming",
55+
"wikipedia",
56+
]
57+
58+
[project.scripts]
59+
quantulum3-training = "quantulum3.scripts.train:main"
60+
61+
[project.urls]
62+
Homepage = "https://github.com/nielstron/quantulum3"
63+
Repository = "https://github.com/nielstron/quantulum3"
64+
Issues = "https://github.com/nielstron/quantulum3/issues"
65+
Changelog = "https://github.com/nielstron/quantulum3/blob/master/CHANGES"
66+
67+
[dependency-groups]
68+
dev = [
69+
"black",
70+
"coverage",
71+
"flake8",
72+
"hypothesis",
73+
"pylint",
74+
"pytest",
75+
]
76+
77+
[tool.setuptools]
78+
include-package-data = true
79+
80+
[tool.setuptools.packages.find]
81+
include = ["quantulum3*"]
82+
83+
[tool.setuptools.package-data]
84+
quantulum3 = ["*.json", "*.joblib", "_lang/**/*.json", "_lang/**/*.txt", "_lang/**/*.joblib"]
85+
86+
[tool.pytest.ini_options]
87+
testpaths = [
88+
"quantulum3/tests",
89+
"quantulum3/_lang/en_US/tests",
90+
]
91+
92+
[tool.uv]
93+
default-groups = ["dev"]

quantulum3/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""quantulum3 init."""
22

3-
VERSION = (0, 9, 2)
3+
from importlib.metadata import version
44

5-
__version__ = ".".join([str(i) for i in VERSION])
5+
__version__ = version("quantulum3")
66
__author__ = "Marco Lagi, nielstron, sohrabtowfighi, grhawk and Rodrigo Castro"
77
__author_email__ = "n.muendler@web.de"
88
__copyright__ = "Copyright (C) 2016 Marco Lagi, nielstron,t sohrabtowfighi, "

0 commit comments

Comments
 (0)