Skip to content
Merged
Changes from all 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
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pathlib import Path

import paddle
from packaging import tags
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 新增了 from packaging import tags,但在 requirements.txt 等依赖文件中未显式声明 packaging 依赖。

虽然 packaging 可能被其他依赖(如 setuptools-scm)间接引入,但为了确保环境一致性,建议显式声明:

# 在 requirements.txt 等文件中添加:
+packaging

from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
from setuptools.command.install import install
Expand All @@ -42,16 +43,17 @@


class CustomBdistWheel(bdist_wheel):
"""Custom wheel builder for pure Python packages."""
"""Custom wheel builder."""

def finalize_options(self):
"""Configure wheel as pure Python and platform-independent."""
"""Configure wheel as {python tag}-{abi tag}-{platform tag}."""
super().finalize_options()
self.root_is_pure = True
self.python_tag = "py3"
self.abi_tag = "none"
tag = next(tags.sys_tags())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 next(tags.sys_tags()) 在极端情况下可能抛出 StopIteration 异常(如非常老的 Python 版本或特殊环境)。

建议添加异常处理或默认值:

tag = next(tags.sys_tags(), None)
if tag is None:
    # Fallback to safe defaults
    tag = type('obj', (object,), {
        'interpreter': 'py3',
        'abi': 'none',
        'platform': 'any'
    })()
self.python_tag = tag.interpreter
self.abi_tag = tag.abi
self.plat_name = tag.platform

self.root_is_pure = False
self.python_tag = tag.interpreter
self.abi_tag = tag.abi
self.plat_name_supplied = True
self.plat_name = "any"
self.plat_name = tag.platform


class CMakeExtension(Extension):
Expand Down
Loading