Bug: PythonUvBuilder resolves local requirements from the caller directory

未關閉 適合新手
#952 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 6 天內回覆

@vinsymoyya 已經在處理了。

開始於 2026年11月5日。

  • #953 來自 @vinsymoyya —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
build-system

研究方向

從 aws_lambda_builders.workflows.python_uv.packager 中的 PythonUvDependencyBuilder.build_dependencies 開始,接著比較 requirements 建置路徑與提供工作目錄的 pyproject 建置路徑。使用 issue 中描述的本機 wheel 和 requirements.txt,從函式目錄外執行建置以重現問題。完成標準是 wheel 相對於清單解析,且其模組寫入指定的成品目錄。

由索引模型根據 Issue 內容生成。

描述

Description

PythonUvBuilder resolves relative wheel and local package paths in a requirements manifest against the process working directory, rather than the manifest directory. A function with a vendored wheel therefore fails when built from its parent directory. The pyproject build path already supplies a working directory to uv; the requirements build path does not.

Steps to reproduce

With aws-lambda-builders 1.68.0 and uv installed, run this from outside the temporary function directory:

from pathlib import Path
from tempfile import TemporaryDirectory
from zipfile import ZipFile
from aws_lambda_builders.workflows.python_uv.packager import PythonUvDependencyBuilder

with TemporaryDirectory() as directory:
    root = Path(directory)
    app = root / "function"
    app.mkdir()
    wheel = app / "local_demo-1.0.0-py3-none-any.whl"
    with ZipFile(wheel, "w") as archive:
        archive.writestr("local_demo.py", "VALUE = 42\n")
        archive.writestr("local_demo-1.0.0.dist-info/METADATA",
                        "Metadata-Version: 2.1\nName: local-demo\nVersion: 1.0.0\n")
        archive.writestr("local_demo-1.0.0.dist-info/WHEEL",
                        "Wheel-Version: 1.0\nRoot-Is-Purelib: true\nTag: py3-none-any\n")
        archive.writestr("local_demo-1.0.0.dist-info/RECORD", "")
    manifest = app / "requirements.txt"
    manifest.write_text(f"./{wheel.name}\n", encoding="utf-8")
    target, scratch = root / "artifacts", root / "scratch"
    target.mkdir()
    scratch.mkdir()
    PythonUvDependencyBuilder(runtime="python3.13").build_dependencies(
        str(target), str(scratch), str(manifest)
    )
Observed result

UvBuildError: ... UV pip install failed: ... Distribution not found at: file:///<caller-directory>/local_demo-1.0.0-py3-none-any.whl

The wheel exists in function/; it is looked up outside that directory. This also reproduces through LambdaBuilder.build() with either absolute or relative build paths.

Expected result

Install the local wheel from the requirements manifest's directory and write its module into the requested artifact directory, independently of the caller's working directory.

Environment
  • Windows, Python 3.13.3, uv 0.11.26
  • aws-lambda-builders 1.68.0, develop commit e3e14536501e38b0d6d8db582ddec6d0e0bd6f8a
  • Reproduction uses a local wheel only; no AWS account or package index is needed.

I checked the open and closed issue/PR history. #887 addresses workspace-root discovery for pyproject builds; this reproduction uses only requirements.txt and no workspace.

主要語言
Python
星號
381
分支
161
平均合併
5 天 14 小時
30 天內合併 PR
3

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

aws/aws-lambda-builders 的其他 Issue

查看 aws/aws-lambda-builders 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。