Skip to content

Don't install tests, tools, scripts, examples as toplevel packages#15930

Open
tkanarsky wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
tkanarsky:fix-toplevel-excludes
Open

Don't install tests, tools, scripts, examples as toplevel packages#15930
tkanarsky wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
tkanarsky:fix-toplevel-excludes

Conversation

@tkanarsky

@tkanarsky tkanarsky commented Jul 21, 2026

Copy link
Copy Markdown

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:

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']

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:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

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

  • Related to # (issue)

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']
```
@tkanarsky
tkanarsky requested a review from a team as a code owner July 21, 2026 03:42
@copy-pr-bot

copy-pr-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants