From 96b0cd8337d897640d87e74aeb5fd4eb8bc1ad9b Mon Sep 17 00:00:00 2001 From: Ender Veiga Bueno Date: Thu, 28 May 2026 11:41:04 +0200 Subject: [PATCH 1/7] fix: use find_packages() to include subpackages in wheel The PyPI wheel was missing all subpackages (rule_based, qwen_qwq, deepseek_r1, llama_3_1, tiktoken_*) because packages was hardcoded to ['tocount']. Using find_packages() ensures all subpackages are included in the built wheel. --- setup.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 49d6d08..632374d 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """Setup module.""" try: - from setuptools import setup + from setuptools import setup, find_packages except ImportError: - from distutils.core import setup + from distutils.core import setup, find_packages def get_requires() -> list: @@ -30,8 +30,7 @@ def read_description() -> str: setup( name='tocount', - packages=[ - 'tocount', ], + packages=find_packages(), version='0.5', description='ToCount: Lightweight Token Estimator', long_description=read_description(), From d96dcf0d6dc3e09055b42b6e5d420a81adcea8cf Mon Sep 17 00:00:00 2001 From: Ender Veiga Bueno Date: Fri, 29 May 2026 16:31:18 +0200 Subject: [PATCH 2/7] fix: hardcode package list and fix setuptools import - Replace find_packages() with explicit package list per reviewer feedback - Remove broken distutils fallback (find_packages doesn't exist there) - Add @Kaylebor to AUTHORS.md under Other Contributors Addresses review comments in openscilab/tocount#39 --- AUTHORS.md | 1 + setup.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index ec878bd..1b6b579 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -10,6 +10,7 @@ # Other Contributors ---------- - [@boreshnavard](https://github.com/boreshnavard) ++ +- [@Kaylebor](https://github.com/Kaylebor) ++ Graphic designer diff --git a/setup.py b/setup.py index 632374d..0dbcadd 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- """Setup module.""" -try: - from setuptools import setup, find_packages -except ImportError: - from distutils.core import setup, find_packages +from setuptools import setup def get_requires() -> list: @@ -30,7 +27,16 @@ def read_description() -> str: setup( name='tocount', - packages=find_packages(), + packages=[ + 'tocount', + 'tocount.deepseek_r1', + 'tocount.llama_3_1', + 'tocount.qwen_qwq', + 'tocount.rule_based', + 'tocount.tiktoken_cl100k', + 'tocount.tiktoken_o200k', + 'tocount.tiktoken_r50k', + ], version='0.5', description='ToCount: Lightweight Token Estimator', long_description=read_description(), From ba53179f2f74ee1d72c715ee0c15ae3665fd9dc5 Mon Sep 17 00:00:00 2001 From: Ender Veiga Bueno Date: Sun, 31 May 2026 14:45:16 +0200 Subject: [PATCH 3/7] docs: update CHANGELOG and add packaging test - Add [Unreleased] entry for setup.py subpackage fix - Add tests/test_package.py to verify all subpackages are importable Catches wheel packaging regressions where subpackages would be missing after installation. --- CHANGELOG.md | 2 ++ tests/test_package.py | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/test_package.py diff --git a/CHANGELOG.md b/CHANGELOG.md index aceed29..ede0961 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- `setup.py` package list updated to include all subpackages in the wheel ## [0.5] - 2026-01-02 ### Added - `DEEPSEEK_R1.LINEAR_ALL` model diff --git a/tests/test_package.py b/tests/test_package.py new file mode 100644 index 0000000..f0735ea --- /dev/null +++ b/tests/test_package.py @@ -0,0 +1,48 @@ +"""Regression test for wheel packaging (issue #39). + +Ensures all subpackages are included in the built wheel. +The original bug: setup.py hardcoded packages=['tocount'], omitting +subpackages from the PyPI wheel and causing ModuleNotFoundError. +""" +import subprocess +import sys +import tempfile +import zipfile +from pathlib import Path + +import pytest + + +EXPECTED_PACKAGES = [ + "tocount", + "tocount.rule_based", + "tocount.qwen_qwq", + "tocount.deepseek_r1", + "tocount.llama_3_1", + "tocount.tiktoken_cl100k", + "tocount.tiktoken_o200k", + "tocount.tiktoken_r50k", +] + + +def test_wheel_contains_all_subpackages(): + """Build wheel and verify every expected subpackage is present.""" + project_root = Path(__file__).parent.parent + with tempfile.TemporaryDirectory() as tmpdir: + result = subprocess.run( + [sys.executable, "-m", "pip", "wheel", str(project_root), + "--no-deps", "-w", tmpdir], + capture_output=True, + text=True, + ) + if result.returncode != 0: + pytest.skip(f"Could not build wheel:\n{result.stderr}") + + wheel = next(Path(tmpdir).glob("*.whl")) + with zipfile.ZipFile(wheel) as zf: + names = zf.namelist() + for pkg in EXPECTED_PACKAGES: + pkg_dir = pkg.replace(".", "/") + "/" + assert any( + name.startswith(pkg_dir) for name in names + ), f"{pkg} missing from wheel" From 9cf57feedccedaad5a21cd94ea430620a6257535 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 5 Jun 2026 18:39:46 +0330 Subject: [PATCH 4/7] fix : fix setup.py --- setup.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 0dbcadd..58897be 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """Setup module.""" -from setuptools import setup +from setuptools import setup, find_package def get_requires() -> list: @@ -27,16 +27,7 @@ def read_description() -> str: setup( name='tocount', - packages=[ - 'tocount', - 'tocount.deepseek_r1', - 'tocount.llama_3_1', - 'tocount.qwen_qwq', - 'tocount.rule_based', - 'tocount.tiktoken_cl100k', - 'tocount.tiktoken_o200k', - 'tocount.tiktoken_r50k', - ], + packages=find_packages(include=["tocount.*"]), version='0.5', description='ToCount: Lightweight Token Estimator', long_description=read_description(), From 992c841e9ff4b55f819a904f8221bb02b218ba4b Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 5 Jun 2026 18:40:33 +0330 Subject: [PATCH 5/7] fix : remove package test --- CHANGELOG.md | 4 ++-- tests/test_package.py | 48 ------------------------------------------- 2 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 tests/test_package.py diff --git a/CHANGELOG.md b/CHANGELOG.md index ede0961..65d44f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] -### Fixed -- `setup.py` package list updated to include all subpackages in the wheel +### Changed +- `setup.py` updated ## [0.5] - 2026-01-02 ### Added - `DEEPSEEK_R1.LINEAR_ALL` model diff --git a/tests/test_package.py b/tests/test_package.py deleted file mode 100644 index f0735ea..0000000 --- a/tests/test_package.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Regression test for wheel packaging (issue #39). - -Ensures all subpackages are included in the built wheel. -The original bug: setup.py hardcoded packages=['tocount'], omitting -subpackages from the PyPI wheel and causing ModuleNotFoundError. -""" -import subprocess -import sys -import tempfile -import zipfile -from pathlib import Path - -import pytest - - -EXPECTED_PACKAGES = [ - "tocount", - "tocount.rule_based", - "tocount.qwen_qwq", - "tocount.deepseek_r1", - "tocount.llama_3_1", - "tocount.tiktoken_cl100k", - "tocount.tiktoken_o200k", - "tocount.tiktoken_r50k", -] - - -def test_wheel_contains_all_subpackages(): - """Build wheel and verify every expected subpackage is present.""" - project_root = Path(__file__).parent.parent - with tempfile.TemporaryDirectory() as tmpdir: - result = subprocess.run( - [sys.executable, "-m", "pip", "wheel", str(project_root), - "--no-deps", "-w", tmpdir], - capture_output=True, - text=True, - ) - if result.returncode != 0: - pytest.skip(f"Could not build wheel:\n{result.stderr}") - - wheel = next(Path(tmpdir).glob("*.whl")) - with zipfile.ZipFile(wheel) as zf: - names = zf.namelist() - for pkg in EXPECTED_PACKAGES: - pkg_dir = pkg.replace(".", "/") + "/" - assert any( - name.startswith(pkg_dir) for name in names - ), f"{pkg} missing from wheel" From ea32d7b357396c923682e20846166365d06905b2 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 5 Jun 2026 18:42:17 +0330 Subject: [PATCH 6/7] fix : fix typo --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 58897be..9c601c8 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """Setup module.""" -from setuptools import setup, find_package +from setuptools import setup, find_packages def get_requires() -> list: From 1761de52b24679f7b5f840e4260f2da7e189cee1 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 5 Jun 2026 18:45:50 +0330 Subject: [PATCH 7/7] fix : fix typo --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9c601c8..320b7ad 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def read_description() -> str: setup( name='tocount', - packages=find_packages(include=["tocount.*"]), + packages=find_packages(include=["tocount*"]), version='0.5', description='ToCount: Lightweight Token Estimator', long_description=read_description(),