Skip to content

Commit 4ca0f04

Browse files
committed
Migrate setup.py to pyproject.toml
1 parent 29f3884 commit 4ca0f04

15 files changed

Lines changed: 413 additions & 1225 deletions

.pre-commit-config.yaml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ ci:
1919
autofix_prs: true
2020
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
2121
autoupdate_schedule: quarterly
22-
# skip all hooks that can change the files, use GitHub Action "code-formatting.yml" for this
23-
skip: [black,isort]
22+
skip: [ruff-check, ruff-format]
2423

2524
repos:
2625
- repo: https://github.com/pre-commit/pre-commit-hooks
27-
rev: v4.3.0
26+
rev: v6.0.0
2827
hooks:
2928
- id: check-yaml
3029
- id: check-case-conflict
@@ -33,20 +32,9 @@ repos:
3332
args: ['--maxkb=1000']
3433
- id: requirements-txt-fixer
3534

36-
- repo: https://github.com/PyCQA/isort
37-
rev: 5.13.2
35+
- repo: https://github.com/astral-sh/ruff-pre-commit
36+
rev: v0.15.8
3837
hooks:
39-
- id: isort
40-
name: Format imports
41-
exclude: docs/
42-
43-
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
44-
- repo: https://github.com/psf/black-pre-commit-mirror
45-
rev: 24.3.0
46-
hooks:
47-
- id: black
48-
# It is recommended to specify the latest version of Python
49-
# supported by your project here, or alternatively use
50-
# pre-commit's default_language_version, see
51-
# https://pre-commit.com/#top_level-default_language_version
52-
language_version: python3.10
38+
- id: ruff-check
39+
args: [ --fix ]
40+
- id: ruff-format

pyproject.toml

Lines changed: 223 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build-backend = "setuptools.build_meta"
1818

1919
[project]
2020
name = "nemo-toolkit"
21-
dynamic = ["dependencies", "optional-dependencies", "version"]
21+
dynamic = ["version"]
2222
description = "NeMo - a toolkit for Conversational AI"
2323
readme = "README.md"
2424
license = {file = "LICENSE"}
@@ -32,7 +32,6 @@ keywords = [
3232
"gpu",
3333
"language",
3434
"learning",
35-
"learning",
3635
"machine",
3736
"nvidia",
3837
"pytorch",
@@ -51,6 +50,10 @@ classifiers = [
5150
"Operating System :: OS Independent",
5251
"Programming Language :: Python :: 3",
5352
"Programming Language :: Python :: 3.10",
53+
"Programming Language :: Python :: 3.11",
54+
"Programming Language :: Python :: 3.12",
55+
"Programming Language :: Python :: 3.13",
56+
"Programming Language :: Python :: 3.14",
5457
"Topic :: Scientific/Engineering :: Artificial Intelligence",
5558
"Topic :: Scientific/Engineering :: Image Recognition",
5659
"Topic :: Scientific/Engineering :: Mathematics",
@@ -59,66 +62,50 @@ classifiers = [
5962
"Topic :: Software Development :: Libraries",
6063
"Topic :: Utilities",
6164
]
65+
dependencies = [
66+
"cuda-bindings ; sys_platform != 'darwin'",
67+
"fsspec>=2024.12.0",
68+
"huggingface-hub>=0.24",
69+
"numba ; sys_platform == 'darwin'",
70+
"numexpr<2.14.0", # WAR for attempted use of nonexistent numpy.typing
71+
"numpy>=1.22",
72+
"onnx>=1.7.0",
73+
"python-dateutil", # Align with upstream PyTorch requirements
74+
"ruamel.yaml",
75+
"scikit-learn",
76+
"tensorboard",
77+
"text-unidecode",
78+
"torch>=2.6.0",
79+
"tqdm>=4.41.0",
80+
"wget",
81+
"wrapt",
82+
]
6283

6384
[tool.setuptools]
64-
py-modules = ["nemo"]
85+
zip-safe = false
86+
include-package-data = true
87+
88+
[tool.setuptools.packages.find]
89+
exclude = ["tools", "tests"]
90+
91+
[tool.setuptools.package-data]
92+
"*" = ["*.tsv", "*.txt", "*.far", "*.fst", "*.cpp", "Makefile"]
93+
6594

6695
[project.entry-points."nemo_run.cli"]
6796
llm = "nemo.collections.llm"
6897

6998
[project.urls]
7099
Download = "https://github.com/NVIDIA/NeMo/releases"
71100
Homepage = "https://github.com/nvidia/nemo"
101+
Repository = "https://github.com/NVIDIA-NeMo/NeMo"
72102

73-
[tool.isort]
74-
profile = "black" # black-compatible
75-
line_length = 119 # should match black parameters
76-
ignore_whitespace = true # ignore whitespace for compatibility with the initial style
77-
py_version = 310 # python 3.10 as a target version
78-
known_first_party = ["nemo"] # FIRSTPARTY section
79-
known_third_party = ["nemo_text_processing", "examples", "scripts"] # THIRDPARTY section
80-
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
81-
default_section = "THIRDPARTY"
82-
extend_skip = ["setup.py", "docs/source/conf.py"]
83-
84-
85-
[tool.black]
86-
line_length = 119
87-
skip_string_normalization = true
88-
# major year version is stable, see details in
89-
# https://black.readthedocs.io/en/stable/the_black_code_style/index.html
90-
# `required_version` is necessary for consistency (other `black` versions will fail to reformat files)
91-
required_version = "24"
92-
target-version = ['py310', 'py311', 'py312']
93-
extend-exclude = '''
94-
# A regex preceded with ^/ will apply only to files and directories
95-
# in the root of the project.
96-
# include here only current collections, new collections should not be ignored
97-
# exclude the collection once it is reformatted (due to changes in PRs)
98-
(
99-
^\/docs\/
100-
| ^\/external\/
101-
| ^\/examples\/
102-
| ^\/nemo\/collections\/asr\/
103-
| ^\/nemo\/collections\/common\/
104-
| ^\/nemo\/collections\/multimodal\/
105-
| ^\/nemo\/collections\/nlp\/
106-
| ^\/nemo\/collections\/tts\/
107-
| ^\/nemo\/collections\/vision\/
108-
| ^\/nemo\/core\/
109-
| ^\/nemo\/utils\/
110-
| ^\/scripts\/
111-
| ^\/tests\/
112-
| ^\/tools\/
113-
| ^\/tutorials\/
114-
| ^\/setup.py
115-
)
116-
'''
117-
118-
[tool.pytest.ini_options]
103+
104+
[tool.pytest]
105+
strict = true
119106
# durations=0 will display all tests execution time, sorted in ascending order starting from from the slowest one.
120107
# -vv will also display tests with durration = 0.00s
121-
addopts = "--verbose --pyargs --durations=0 --strict-markers" # always add these arguments to pytest
108+
addopts = ["--verbose", "--pyargs", "--durations=0", "--strict-markers"] # always add these arguments to pytest
122109
testpaths = ["tests"]
123110
pythonpath = ["tests/e2e_nightly"]
124111
# directories to ignore when discovering tests
@@ -160,6 +147,192 @@ conflicts = [
160147
],
161148
]
162149

150+
[tool.ruff]
151+
line-length = 119
152+
extend-exclude = [
153+
"docs",
154+
"external",
155+
"examples",
156+
"nemo/collections/asr",
157+
"nemo/collections/common",
158+
"nemo/collections/multimodal",
159+
"nemo/collections/nlp",
160+
"nemo/collections/tts",
161+
"nemo/collections/vision",
162+
"nemo/core",
163+
"nemo/utils",
164+
"scripts",
165+
"tests",
166+
"tools",
167+
"tutorials",
168+
]
169+
[tool.ruff.lint]
170+
extend-select = [
171+
"E", # pycodestyle
172+
"F", # Pyflakes
173+
"UP", # pyupgrade
174+
"B", # flake8-bugbear
175+
"SIM", # flake8-simplify
176+
"I", # isort
177+
"F541", # f-string without any placeholders
178+
"F841", # local variable 'x' is assigned to but never used
179+
"F401", # 'x' imported but unused
180+
"E741", # ambiguous variable name 'l'
181+
"F821", # undefined name 'x'
182+
# "E266", # too many leading '#' for block comment
183+
]
184+
extend-ignore = [
185+
"SIM108",
186+
"E722",
187+
]
188+
[tool.ruff.lint.isort]
189+
known-first-party = ["nemo"] # FIRSTPARTY section
190+
known-third-party = ["nemo_text_processing", "examples", "scripts"] # THIRDPARTY section
191+
192+
193+
[project.optional-dependencies]
194+
all = [
195+
"nemo-toolkit[test]",
196+
"nemo-toolkit[run]",
197+
"nemo-toolkit[core]",
198+
"nemo-toolkit[lightning]",
199+
"nemo-toolkit[common]",
200+
"nemo-toolkit[asr]",
201+
"nemo-toolkit[tts]",
202+
"nemo-toolkit[slu]",
203+
"nemo-toolkit[audio]",
204+
]
205+
slu = [
206+
"jiwer>=2.0.0,<4.0.0",
207+
"progress>=1.5",
208+
"tabulate>=0.8.7",
209+
"textdistance>=4.1.5",
210+
"tqdm",
211+
"nemo-toolkit[asr]",
212+
]
213+
test = [
214+
"click>=8.1",
215+
"coverage",
216+
"parameterized",
217+
"pytest",
218+
"pytest-httpserver",
219+
"pytest-mock",
220+
"pytest-runner",
221+
"ruamel.yaml",
222+
"sphinx",
223+
"sphinxcontrib-bibtex",
224+
"wandb",
225+
"wget",
226+
"wrapt",
227+
"nemo-toolkit[tts]",
228+
"nemo-toolkit[common]",
229+
]
230+
audio = [
231+
"einops",
232+
"lhotse>=1.32.2",
233+
"librosa>=0.10.0",
234+
"matplotlib",
235+
"pesq; (platform_machine != 'x86_64' or platform_system != 'Darwin')",
236+
"pystoi",
237+
"scipy>=0.14",
238+
"soundfile",
239+
"nemo-toolkit[common]",
240+
]
241+
core = [
242+
"nemo-toolkit[lightning]"
243+
]
244+
lightning = [
245+
"cloudpickle",
246+
"fiddle",
247+
"hydra-core>1.3,<=1.3.2",
248+
"lightning>2.2.1,<=2.4.0",
249+
"nv_one_logger_core>=2.3.1",
250+
"nv_one_logger_pytorch_lightning_integration>=2.3.1",
251+
"nv_one_logger_training_telemetry>=2.3.1",
252+
"omegaconf<=2.3",
253+
"peft",
254+
"torchmetrics>=0.11.0",
255+
"transformers",
256+
"wandb",
257+
"webdataset>=0.2.86",
258+
]
259+
260+
common-only = [
261+
"datasets>=3.2.0",
262+
"einops",
263+
"inflect",
264+
"mediapy==1.1.6",
265+
"pandas",
266+
"sacremoses>=0.0.43",
267+
"sentencepiece<1.0.0",
268+
]
269+
270+
common = [
271+
"nemo-toolkit[common-only]",
272+
"nemo-toolkit[core]",
273+
]
274+
275+
asr-only = [
276+
"braceexpand",
277+
"diskcache",
278+
"editdistance",
279+
"einops",
280+
"jiwer>=3.1.0,<4.0.0",
281+
"kaldi-python-io",
282+
"kaldialign",
283+
"lhotse>=1.32.2",
284+
"librosa>=0.10.1",
285+
"marshmallow",
286+
"optuna",
287+
"packaging",
288+
"pyannote.core",
289+
"pyannote.metrics",
290+
"pydub",
291+
"pyloudnorm",
292+
"resampy",
293+
"ruamel.yaml",
294+
"sacrebleu",
295+
"scipy>=0.14",
296+
"soundfile",
297+
"sox<=1.5.0",
298+
"whisper_normalizer",
299+
]
300+
301+
asr = [
302+
"nemo-toolkit[asr-only]",
303+
"nemo-toolkit[common]",
304+
]
305+
tts = [
306+
"attrdict",
307+
"cdifflib==1.2.6",
308+
"einops",
309+
"janome",
310+
"jieba",
311+
"kornia",
312+
"librosa",
313+
"matplotlib",
314+
# pynini does not currently support aarch, disable nemo_text_processing for now
315+
"nemo_text_processing; 'arm' not in platform_machine and 'aarch' not in platform_machine and sys_platform != 'darwin'",
316+
"nltk",
317+
"pandas",
318+
"pyopenjtalk",
319+
"pypinyin",
320+
"pypinyin-dict",
321+
"seaborn",
322+
"nemo-toolkit[asr]",
323+
"nemo-toolkit[common]",
324+
]
325+
cu12 = [
326+
"cuda-python>=12.6.0,<13 ; platform_system != 'Darwin'",
327+
"numba-cuda[cu12] ; platform_system != 'Darwin'",
328+
]
329+
cu13 = [
330+
"cuda-python>=13,<14 ; platform_system != 'Darwin'",
331+
"numba-cuda[cu13] ; platform_system != 'Darwin'",
332+
]
333+
run = ["nemo_run"]
334+
335+
163336
[dependency-groups]
164337
docs = [
165338
"myst-parser>=4.0.1",

requirements/requirements.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)