现象
load_data() 是 abses/__init__.py 里 __all__ 导出的公开 API,但发行 wheel 里根本没有它要读的数据文件。仓库 checkout 下能用(所以测试全过),pip install abses 之后必崩。
证据
abses/utils/data.py:
return Path(str(resources.files("data") / filename))
data 是仓库根目录的一个顶层包,而 pyproject.toml 只打包两个包:
[tool.hatch.build.targets.wheel]
packages = ["abses", "hydra_plugins"]
include = [
"abses/icons/*.otf",
"abses/conf/**/*.yaml",
"abses/conf/*.py",
]
实测构建产物:
$ uv build --wheel --out-dir /tmp/w
$ python -c "import zipfile,glob; n=zipfile.ZipFile(sorted(glob.glob('/tmp/w/*.whl'))[-1]).namelist(); \
print('data/:', any(x.startswith('data/') for x in n)); \
print('icons/:', any(x.startswith('icons/') for x in n)); \
print('otf:', [x for x in n if x.endswith('.otf')])"
data/: False
icons/: False
otf: []
顺带:include 里有一条死 glob
"abses/icons/*.otf" 指向的 abses/icons/ 目录不存在(实测 False)。真实字体在仓库根目录的 icons/,唯一使用者是 abses/viz/customize_marker.py:
FONT = pkg_resources.files("icons") / "fa-regular-400.otf"
而 customize_marker.py 全仓零 import(abses/viz/__init__.py 只从 plotting 导入)、覆盖率 0%,却是 fontawesome 和 icons 两个硬依赖存在的唯一理由。
建议方案
数据文件(必须修):
- 把示例数据移进包内,例如
abses/data/,load_data 改用 resources.files("abses.data"),并在 [tool.hatch.build.targets.wheel].include 里加上对应 glob;或
- 保留在仓库外,把
load_data 改成「按需下载 + 本地缓存」,并在缺失时给出可操作的报错。
方案 1 更简单;注意 data/ 目前约 8.5 MB(farmland.tif / precipitation.nc / irr_lands.csv / YR_cities.zip),若不想让 wheel 变大则选方案 2。
字体与死模块(建议一并处理):
- 删除
abses/viz/customize_marker.py,同时从 [project.dependencies] 移除 fontawesome 与 icons,并删掉那条死 glob。这是一次公共命名空间的移除,所以需要走弃用流程还是直接删,请先确认。
另外目前没有 [tool.hatch.build.targets.sdist],hatchling 默认会把 data/(8.5 MB)和 examples/ 扫进 sdist——sdist 有、wheel 没有,两者不一致,一并明确一下。
验收标准
现象
load_data()是abses/__init__.py里__all__导出的公开 API,但发行 wheel 里根本没有它要读的数据文件。仓库 checkout 下能用(所以测试全过),pip install abses之后必崩。证据
abses/utils/data.py:data是仓库根目录的一个顶层包,而pyproject.toml只打包两个包:实测构建产物:
顺带:
include里有一条死 glob"abses/icons/*.otf"指向的abses/icons/目录不存在(实测False)。真实字体在仓库根目录的icons/,唯一使用者是abses/viz/customize_marker.py:而
customize_marker.py全仓零 import(abses/viz/__init__.py只从plotting导入)、覆盖率 0%,却是fontawesome和icons两个硬依赖存在的唯一理由。建议方案
数据文件(必须修):
abses/data/,load_data改用resources.files("abses.data"),并在[tool.hatch.build.targets.wheel].include里加上对应 glob;或load_data改成「按需下载 + 本地缓存」,并在缺失时给出可操作的报错。方案 1 更简单;注意
data/目前约 8.5 MB(farmland.tif/precipitation.nc/irr_lands.csv/YR_cities.zip),若不想让 wheel 变大则选方案 2。字体与死模块(建议一并处理):
abses/viz/customize_marker.py,同时从[project.dependencies]移除fontawesome与icons,并删掉那条死 glob。这是一次公共命名空间的移除,所以需要走弃用流程还是直接删,请先确认。另外目前没有
[tool.hatch.build.targets.sdist],hatchling 默认会把data/(8.5 MB)和examples/扫进 sdist——sdist 有、wheel 没有,两者不一致,一并明确一下。验收标准
pip install dist/abses-*.whl后,from abses import load_data; load_data("farmland.tif")能返回一个存在的路径。pyproject.toml里不再有指向不存在目录的include条目。