Skip to content

fix: use find_packages() to include subpackages in wheel#39

Merged
sadrasabouri merged 7 commits into
openscilab:devfrom
Kaylebor:fix-wheel-subpackages
Jun 5, 2026
Merged

fix: use find_packages() to include subpackages in wheel#39
sadrasabouri merged 7 commits into
openscilab:devfrom
Kaylebor:fix-wheel-subpackages

Conversation

@Kaylebor

Copy link
Copy Markdown

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.py hardcodes packages=['tocount'].

This causes ModuleNotFoundError: No module named 'tocount.rule_based' on pip install tocount.

Fix: Use setuptools.find_packages() to automatically discover all subpackages.

Tested by building wheel locally and verifying all subpackages are present.

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.

@sadrasabouri sadrasabouri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread setup.py Outdated
Comment thread setup.py Outdated
@sepandhaghighi sepandhaghighi added the bug Something isn't working label May 28, 2026
@sepandhaghighi sepandhaghighi added this to the tocount v0.6 milestone May 28, 2026
- 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
@Kaylebor Kaylebor requested a review from sadrasabouri May 29, 2026 14:32
@codacy-production

codacy-production Bot commented May 29, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

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.

@Kaylebor

Kaylebor commented May 29, 2026

Copy link
Copy Markdown
Author

@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 sadrasabouri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better now. Thanks.
While you're working on the Codacy issues, please:

  1. make the target branch dev not main
  2. add changed to changelog.md
  3. [optional] add a test to capture this failure in the future

@codecov-commenter

codecov-commenter commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.68%. Comparing base (764ab90) to head (1761de5).
⚠️ Report is 2 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kaylebor Kaylebor changed the base branch from main to dev May 31, 2026 12:38
- 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.
@Kaylebor Kaylebor force-pushed the fix-wheel-subpackages branch from 8c8bb5e to ba53179 Compare May 31, 2026 12:50
@Kaylebor

Copy link
Copy Markdown
Author

@sadrasabouri

Much better now. Thanks. While you're working on the Codacy issues, please:

1. make the target branch `dev` not `main`

2. add changed to changelog.md

3. [optional] add a test to capture this failure in the future

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?

@sadrasabouri sadrasabouri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @Kaylebor
I fired the test workflows and left some final comments for you.

PS: and yes, Codacy seems like false alarming.

Comment thread tests/test_package.py Outdated
Comment on lines +1 to +5
"""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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to be that detailed. Make it concise like other tests.

Comment thread tests/test_package.py Outdated
Comment on lines +38 to +39
if result.returncode != 0:
pytest.skip(f"Could not build wheel:\n{result.stderr}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's assert this as well. If the wheel installation is not working that's an issue we should notice.

Comment thread tests/test_package.py Outdated
Comment on lines +45 to +48
pkg_dir = pkg.replace(".", "/") + "/"
assert any(
name.startswith(pkg_dir) for name in names
), f"{pkg} missing from wheel"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Comment thread CHANGELOG.md Outdated
Comment on lines +8 to +9
### Fixed
- `setup.py` package list updated to include all subpackages in the wheel

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

### Changed
- `setup.py` updated

Comment thread setup.py Outdated
from setuptools import setup
except ImportError:
from distutils.core import setup
from setuptools import setup

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, revert these lines to the original format (with try/except)

@sadrasabouri

Copy link
Copy Markdown
Member

@sepandhaghighi can you apply the same changes you applied in other pr here as well?

@sepandhaghighi

Copy link
Copy Markdown
Member

@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 💯

@sepandhaghighi sepandhaghighi self-assigned this Jun 5, 2026
@sepandhaghighi

Copy link
Copy Markdown
Member

@sadrasabouri

I eliminated legacy distutils.core and utilized the find_packages function with a pattern to gather all submodules. I also removed the package test, as it was somewhat hacky; we plan to implement more robust tests later.

@sadrasabouri sadrasabouri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @Kaylebor, thanks for your contribution.

@sadrasabouri sadrasabouri merged commit f92b6b6 into openscilab:dev Jun 5, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants