Don't install tests, tools, scripts, examples as toplevel packages#15930
Open
tkanarsky wants to merge 1 commit into
Open
Don't install tests, tools, scripts, examples as toplevel packages#15930tkanarsky wants to merge 1 commit into
tkanarsky wants to merge 1 commit into
Conversation
Problem was that: ``` setuptools.setup( ... exclude=['tools', 'tests'], ... ) ``` is silently invalid syntax: https://setuptools.pypa.io/en/latest/references/keywords.html The set of toplevel packages discovered by setuptools is instead determined by `setuptools.find_packages()`, which had no excludes. As a result, whenever you pip installed `nemo_toolkit`, it would install packages `scripts`, `examples`, `tests` (tools doesn't get installed as it doesn't have an `__init__.py`) ``` ls ~/test/.venv/lib/python3.13/site-packages/ | grep -E '(examples|tests|scripts)' examples scripts tests ``` Quite annoying and almost certainly not intentional :) Fix by adding excludes to find_packages instead. Test: ``` (test) tkanarsky@dusmj0ksnkz:~/test$ uv pip install ~/gits/Speech/ Resolved 78 packages in 898ms Built nemo-toolkit @ file:///home/tkanarsky/gits/Speech Prepared 7 packages in 1.07s Installed 17 packages in 22ms + aistore==1.25.0 + annotated-types==0.7.0 + braceexpand==0.1.7 + charset-normalizer==3.4.9 + cloudpickle==3.1.2 + humanize==4.16.0 + msgspec==0.21.1 + nemo-toolkit==3.1.0+8ddab60075 (from file:///home/tkanarsky/gits/Speech) + overrides==7.7.0 + pydantic==2.13.4 + pydantic-core==2.46.4 + requests==2.34.2 + smart-open==8.0.1 + tenacity==9.1.4 + typing-inspection==0.4.2 + urllib3==2.7.0 + xxhash==3.8.1 (test) tkanarsky@dusmj0ksnkz:~/test$ ls ~/test/.venv/lib/python3.13/site-packages/ | grep -E '(examples|tests|scripts)' (test) tkanarsky@dusmj0ksnkz:~/test$ python3 Python 3.13.0 (main, Oct 16 2024, 03:23:02) [Clang 18.1.8 ] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import nemo >>> dir(nemo) ['__builtins__', '__cached__', '__contact_emails__', '__contact_names__', '__description__', '__doc__', '__download_url__', '__file__', '__homepage__', '__keywords__', '__license__', '__loader__', '__name__', '__package__', '__package_name__', '__path__', '__repository_url__', '__shortversion__', '__spec__', '__version__', 'package_info'] ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
Fix package namespace pollution by moving excludes from setuptools.setup(), where they are silently ignored, to setuptools.find_packages.
Collection: Most? Not sure, tbh.
Problem was that:
is silently invalid syntax: https://setuptools.pypa.io/en/latest/references/keywords.html
The set of toplevel packages discovered by setuptools is instead determined by
setuptools.find_packages(), which had no excludes.As a result, whenever you pip installed
nemo_toolkit, it would install packagesscripts,examples,tests(tools doesn't get installed as it doesn't have an__init__.py)Quite annoying and almost certainly not intentional :)
Fix by adding excludes to find_packages instead.
Test:
GitHub Actions CI
The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.
The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".
Before your PR is "Ready for review"
Pre checks:
PR Type:
If you haven't finished some of the above items you can still open "Draft" PR.
Who can review?
Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
Additional Information