Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "ms_swift"
dynamic = ["version", "readme"]
description = "Swift: Scalable lightWeight Infrastructure for Fine-Tuning"
requires-python = ">=3.8"
license = { text = "Apache License 2.0" }
authors = [
{ name = "DAMO ModelScope teams", email = "contact@modelscope.cn" },
]
keywords = ["transformers", "LLM", "lora", "megatron", "grpo", "sft"]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"accelerate",
"addict",
"aiohttp",
"attrdict",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

attrdict is unmaintained and incompatible with Python 3.10+ (it fails with AttributeError: module 'collections' has no attribute 'Mapping'). Since this project supports Python 3.10, 3.11, and 3.12, this dependency will cause runtime errors. It is recommended to remove it and use addict (already listed on line 28) instead.

"binpacking",
"charset_normalizer",
"cpm_kernels",
"dacite",
"datasets>=3.0,<4.8.5",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

datasets>=3.0 requires Python 3.9 or higher. This conflicts with the project's declared requires-python = ">=3.8" on line 9. This will cause installation to fail on Python 3.8 environments. Consider lowering the minimum version of datasets to 2.0 or increasing the minimum Python version to 3.9.

Suggested change
"datasets>=3.0,<4.8.5",
"datasets>=2.0,<4.8.5",

"einops",
"fastapi",
"gradio>=3.40.0,<6.0",
"importlib_metadata",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The canonical package name is importlib-metadata (with a hyphen). Additionally, since the project requires Python >= 3.8, the standard library importlib.metadata is available. If the backport is still needed for specific features (like the improved entry_points API in 3.10+), it should use an environment marker to avoid unnecessary installation on newer Python versions.

Suggested change
"importlib_metadata",
"importlib-metadata; python_version < '3.10'",

"json_repair",
"matplotlib",
"modelscope>=1.23",
"nltk",
"numpy",
"openai",
"oss2",
"pandas",
"peft>=0.11,<0.20",
"pillow",
"PyYAML>=5.4",
"requests",
"rouge",
"safetensors",
"scipy",
"sentencepiece",
"simplejson>=3.3.0",
"sortedcontainers>=1.5.9",
"tensorboard",
"tiktoken",
"tqdm",
"transformers>=4.33,<5.9.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The upper bound <5.9.0 for transformers is highly specific. Unless there is a known reason to cap it at exactly 5.9.0, it is better to use a major version bound like <5.0.0 to follow standard semantic versioning practices.

Suggested change
"transformers>=4.33,<5.9.0",
"transformers>=4.33,<5.0.0",

"transformers_stream_generator",
"trl>=0.15,<1.0; python_version>='3.10'",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Including trl in the main dependencies with a python_version>='3.10' marker means it won't be installed on Python 3.8/3.9. If the codebase imports trl without runtime checks, it will crash. If trl is a core dependency, the project's minimum Python version should be bumped to 3.10. If it is optional, it should be moved to [project.optional-dependencies].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The trl dependency is guarded by python_version>='3.10'. Since the project supports Python 3.8+, users on older versions will not have trl installed, which may lead to runtime errors if the package depends on it. Consider adding a fallback for Python < 3.10 using an older version of trl that still supports those environments.

Suggested change
"trl>=0.15,<1.0; python_version>='3.10'",
"trl>=0.15,<1.0; python_version>='3.10'",
"trl<0.15; python_version<'3.10'",

"uvicorn",
"zstandard",
]
Comment on lines +26 to +67
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Hardcoding a static list of dependencies in pyproject.toml while setup.py continues to parse them from requirements/*.txt introduces a maintenance risk where the two sources of truth can fall out of sync. It is recommended to consolidate dependency management into pyproject.toml and either remove setup.py or refactor it to read from the TOML file to maintain a single source of truth.


[project.optional-dependencies]
all = [
"evalscope[opencompass,vlmeval]>=1.0.0; python_version>='3.10'",
"swanlab",
"ray",
]
eval = [
"evalscope[opencompass,vlmeval]>=1.0.0; python_version>='3.10'",
]
swanlab = [
"swanlab",
]
ray = [
"ray",
]
megatron = [
"mcore-bridge>=1.2.0; python_version>='3.12'",
"megatron-core>=0.15; python_version>='3.12'",
"peft>=0.15; python_version>='3.12'",
Comment on lines +85 to +87
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The python_version>='3.12' markers for Megatron-related dependencies are very restrictive. megatron-core and mcore-bridge typically support Python 3.10+. This restriction prevents users on Python 3.10 and 3.11 from using the Megatron integration. Unless there is a specific technical reason for 3.12+, consider lowering this to 3.10.

Comment on lines +85 to +87
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The Python version restriction python_version>='3.12' for the megatron optional dependencies appears overly restrictive. megatron-core and its associated packages typically support Python 3.10 and 3.11. Restricting these to 3.12+ will prevent many users in common research environments (which often use Python 3.10 or 3.11) from utilizing the Megatron integration features.

Suggested change
"mcore-bridge>=1.2.0; python_version>='3.12'",
"megatron-core>=0.15; python_version>='3.12'",
"peft>=0.15; python_version>='3.12'",
"mcore-bridge>=1.2.0; python_version>='3.10'",
"megatron-core>=0.15; python_version>='3.10'",
"peft>=0.15; python_version>='3.10'",

]
tests = [
"expecttest",
"flake8",
"isort>=4.3.21",
"modelscope",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

modelscope is already listed in the main dependencies (line 42), so it is redundant to include it in the tests optional dependencies.

"pre-commit",
"yapf==0.30.0",
]
docs = [
"docutils>=0.16.0",
"myst_parser",
"recommonmark",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

recommonmark is deprecated and has been superseded by myst-parser, which is already included in the docs extra. It should be removed to avoid redundancy.

"sphinx>=5.3.0",
"sphinx-book-theme",
"sphinx-copybutton",
"sphinx-rtd-theme",
"sphinx_markdown_tables",
"sphinxcontrib-mermaid",
]

[project.urls]
Homepage = "https://github.com/modelscope/ms-swift"

[project.scripts]
swift = "swift.cli.main:cli_main"
megatron = "swift.cli._megatron.main:cli_main"

[tool.setuptools]
include-package-data = true
zip-safe = false

[tool.setuptools.packages.find]
exclude = ["tests", "tests.*"]

[tool.setuptools.package-data]
"*" = [
"utils/*",
"dataset/data/*.*",
"config/*.json",
"loss_scale/config/*.json",
]

[tool.setuptools.dynamic]
version = { attr = "swift.version.__version__" }
readme = { file = ["README.md"], content-type = "text/markdown" }

[tool.uv]
package = true