fix: use find_packages() to include subpackages in wheel#39
Conversation
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.
There was a problem hiding this comment.
Thanks, @Kaylebor. I verify that the issue you raised exists.
I had some comments on your changes. Feel free to apply them and I will review again.
Also, make sure you read contributing guideline and add your name to AUTHORS.md under Other Contributors.
PS: You can also add a GitHub action test to capture this failure in the future.
- 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#39
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
@sadrasabouri applied your suggestions, feel free to tell me what you think 👍🏼 I do notice that Codacy Static Code Analysis failed, but I can't see the output, all good? Edit: I see the bot comment now, nevermind. I'll check it. |
sadrasabouri
left a comment
There was a problem hiding this comment.
Much better now. Thanks.
While you're working on the Codacy issues, please:
- make the target branch
devnotmain - add changed to changelog.md
- [optional] add a test to capture this failure in the future
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #39 +/- ##
==========================================
+ Coverage 97.64% 97.68% +0.04%
==========================================
Files 18 18
Lines 254 258 +4
Branches 13 13
==========================================
+ Hits 248 252 +4
Misses 3 3
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- 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.
8c8bb5e to
ba53179
Compare
All three done! The test is somewhat simple, mostly just tests that current packages are available after building the wheel. But it does build the wheel too, so if that fails we'll catch that in the future. Also, seems like Codacy issue was transient, it auto-fixed itself. All good? |
There was a problem hiding this comment.
Thanks so much @Kaylebor
I fired the test workflows and left some final comments for you.
PS: and yes, Codacy seems like false alarming.
| """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. |
There was a problem hiding this comment.
It doesn't need to be that detailed. Make it concise like other tests.
| if result.returncode != 0: | ||
| pytest.skip(f"Could not build wheel:\n{result.stderr}") |
There was a problem hiding this comment.
Let's assert this as well. If the wheel installation is not working that's an issue we should notice.
| pkg_dir = pkg.replace(".", "/") + "/" | ||
| assert any( | ||
| name.startswith(pkg_dir) for name in names | ||
| ), f"{pkg} missing from wheel" |
There was a problem hiding this comment.
This part is a bit concerning. I suggest doing this instead:
pkg_init = pkg.replace(".", "/") + "/__init__.py"
assert pkg_init in names, f"{pkg} (__init__.py) missing from wheel"| ### Fixed | ||
| - `setup.py` package list updated to include all subpackages in the wheel |
There was a problem hiding this comment.
### Changed
- `setup.py` updated
| from setuptools import setup | ||
| except ImportError: | ||
| from distutils.core import setup | ||
| from setuptools import setup |
There was a problem hiding this comment.
Also, revert these lines to the original format (with try/except)
|
@sepandhaghighi can you apply the same changes you applied in other pr here as well? |
Yeah, I will fix it within the next 24 hours 💯 |
|
I eliminated legacy |
sadrasabouri
left a comment
There was a problem hiding this comment.
Looks good to me. @Kaylebor, thanks for your contribution.
The PyPI wheel (v0.5) is missing all subpackages (rule_based, qwen_qwq, deepseek_r1, llama_3_1, tiktoken_cl100k, tiktoken_o200k, tiktoken_r50k) because
setup.pyhardcodespackages=['tocount'].This causes
ModuleNotFoundError: No module named 'tocount.rule_based'onpip install tocount.Fix: Use
setuptools.find_packages()to automatically discover all subpackages.Tested by building wheel locally and verifying all subpackages are present.