Repository: shenxiangzhuang/bleuscore (language: python)

Issue:
Add Poetry
https://github.com/PyO3/maturin/discussions/1246
https://github.com/kfields/hello-maturin


Discussion / hints:
Use poetry maybe a little bit noisy here. Consider to use naive `pyproject.toml` to make it simpler like tokenizer does [here](https://github.com/huggingface/tokenizers/blob/main/bindings/python/pyproject.toml).

Fix patch:
diff --git a/.gitignore b/.gitignore
index 3d260aa..96d8c65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+# .so file
+*.so
+
 __pycache__
 .hypothesis
 
diff --git a/pyproject.toml b/pyproject.toml
index 25585a8..769c08a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,11 +5,71 @@ build-backend = "maturin"
 [project]
 name = "bleuscore"
 requires-python = ">=3.8"
+authors = [
+    {name = 'Mathew Shen', email = 'datahonor@gmail.com'},
+]
 classifiers = [
     "Programming Language :: Rust",
     "Programming Language :: Python :: Implementation :: CPython",
     "Programming Language :: Python :: Implementation :: PyPy",
+#    "Development Status :: 5 - Production/Stable",
+    "Intended Audience :: Developers",
+    "Intended Audience :: Education",
+    "Intended Audience :: Science/Research",
+    "Operating System :: OS Independent",
+    "Programming Language :: Python :: 3",
+    "Programming Language :: Python :: 3.8",
+    "Programming Language :: Python :: 3.9",
+    "Programming Language :: Python :: 3.10",
+    "Programming Language :: Python :: 3.11",
+    "Topic :: Scientific/Engineering :: Artificial Intelligence",
 ]
-dynamic = ["version"]
+keywords = ["NLP", "Tokenizer", "BLEU", "DeepLearning"]
+dynamic = [
+    "version",
+    "description",
+    "license",
+    "readme",]
+dependencies = []
+
+[project.urls]
+Homepage = 'https://github.com/shenxiangzhuang/bleuscore'
+Source = 'https://github.com/shenxiangzhuang/bleuscore'
+
+[project.optional-dependencies]
+test = ["pytest", "hypothesis"]
+lint = ["black", "ruff~=0.3.7"]
+#docs = []
+#dev = []
+
+
 [tool.maturin]
 features = ["pyo3/extension-module"]
+python-source = "python"
+module-name = "bleuscore.bleuscore"
+#bindings = 'pyo3'
+
+[tool.black]
+line-length = 119
+target-version = "py38"
+
+[tool.ruff]
+line-length = 119
+target-version = "py38"
+lint.ignore = [
+    # a == None in tests vs is None.
+    "E711",
+    # a == False in tests vs is False.
+    "E712",
+    # try xx import except xx pattern without using the lib.
+    "F401",
+    # Raw type equality is required in asserts
+    "E721",
+    # Import order
+    "E402",
+    # Fixtures unused import
+    "F811",
+    # To ignore python/blerscore/__init__.py import errors
+    "F403",
+    "F405",
+]
\ No newline at end of file
diff --git a/python/bleuscore/__init__.py b/python/bleuscore/__init__.py
new file mode 100644
index 0000000..5b077c2
--- /dev/null
+++ b/python/bleuscore/__init__.py
@@ -0,0 +1,7 @@
+from .bleuscore import *
+
+__doc__ = bleuscore.__doc__
+__all__ = [
+    "tokenizer_regex",
+    "tokenizer_13a",
+]
diff --git a/python/bleuscore/py.typed b/python/bleuscore/py.typed
new file mode 100644
index 0000000..e69de29


Test patch:
diff --git a/benchmark/test_benchmark_regex.py b/benchmark/test_benchmark_regex.py
index cf1b749..50592d1 100644
--- a/benchmark/test_benchmark_regex.py
+++ b/benchmark/test_benchmark_regex.py
@@ -2,26 +2,29 @@
 from hypothesis import given
 from hypothesis import strategies as st
 import time
+
+from typing import List
+
 from py_token import TokenizerRegexp, Tokenizer13a
 
 from bleuscore import tokenizer_regex, tokenizer_13a
 
 
-def py_regex(line: str) -> list[str]:
+def py_regex(line: str) -> List[str]:
     token = TokenizerRegexp()
     return token(line)
 
 
-def py_13a(line: str) -> list[str]:
+def py_13a(line: str) -> List[str]:
     token = Tokenizer13a()
     return token(line)
 
 
-def rust_regex(line: str) -> list[str]:
+def rust_regex(line: str) -> List[str]:
     return tokenizer_regex(line)
 
 
-def rust_13a_regex(line: str) -> list[str]:
+def rust_13a_regex(line: str) -> List[str]:
     return tokenizer_13a(line)