From 51f9ced579bd71221fbef97da7881708a555e816 Mon Sep 17 00:00:00 2001 From: Taku Kudo Date: Sat, 17 Aug 2024 10:21:14 +0000 Subject: [PATCH] fix the build error on setup.py test --- .github/workflows/cmake.yml | 2 +- .github/workflows/requirements/base.in | 1 + python/setup.py | 1 + python/test/sentencepiece_test.py | 5 ++++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 3c47ddf..2c4aa54 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -63,7 +63,7 @@ jobs: working-directory: ${{github.workspace}}/python run: | python -m pip install --require-hashes --no-dependencies -r ../.github/workflows/requirements/base.txt - python setup.py test + python -m pytest python setup.py bdist_wheel - name: Upload artifcacts diff --git a/.github/workflows/requirements/base.in b/.github/workflows/requirements/base.in index fcbc1c4..d32433c 100644 --- a/.github/workflows/requirements/base.in +++ b/.github/workflows/requirements/base.in @@ -2,3 +2,4 @@ pip setuptools wheel twine +pytest diff --git a/python/setup.py b/python/setup.py index 3fe6a63..f7d8cf1 100755 --- a/python/setup.py +++ b/python/setup.py @@ -211,4 +211,5 @@ setup( 'Topic :: Software Development :: Libraries :: Python Modules', ], test_suite='sentencepiece_test.suite', + tests_require=['pytest'], ) diff --git a/python/test/sentencepiece_test.py b/python/test/sentencepiece_test.py index 701ece9..b043cc2 100755 --- a/python/test/sentencepiece_test.py +++ b/python/test/sentencepiece_test.py @@ -15,11 +15,14 @@ # See the License for the specific language governing permissions and # limitations under the License.! +import sys + +sys.path.insert(0, 'src') + from collections import defaultdict import io import os import pickle -import sys import unittest import sentencepiece as spm