ITADN

`poetry build` misses package in a path excluded by .gitignore

#10831Closeddlr-cjs 创建于 2026-04-08
area/docs
D
dlr-cjscommented
### Description I built a project whose python files are located in "src/main/python/myproject" using `poetry build` with this pyproject.toml: ``` [build-system] requires = [ "poetry-core>=2.0.0",] build-backend = "poetry.core.masonry.api" ... [tool.poetry] packages = [{include = "myproject", from = "src/main/python"}] ``` The **python files in the "myproject" folder** are created by protobuf, are thus not part of the project source code and therefore **excluded from version control by ".gitignore".** The resulting sdist and wheel files do not contain the source code in the "myproject" package. I'd expect that if a package is explicitly mentioned in the pyproject.toml to be an included package, its content should not be ignored by poetry, even if listed in the .gitignore file. This behaviour is new in poetry 2.x. ### Workarounds Either do not add files relevant for the build to ".gitignore", or use `include` config rather than `packages`. ### Poetry Installation Method pip ### Operating System Windows 11 ### Poetry Version 2.2.0 and 2.3.3 ### Poetry Configuration ```bash session cache-dir = "C:\\Users\\redacted\\AppData\\Local\\pypoetry\\Cache" data-dir = "C:\\Users\\redacted\\AppData\\Roaming\\pypoetry" installer.max-workers = null installer.no-binary = null installer.only-binary = null installer.parallel = true installer.re-resolve = false keyring.enabled = true python.installation-dir = "{data-dir}\\python" # C:\Users\redacted\AppData\Roaming\pypoetry\python requests.max-retries = 0 solver.lazy-wheel = true system-git-client = false virtualenvs.create = true virtualenvs.in-project = null virtualenvs.options.always-copy = false virtualenvs.options.no-pip = false virtualenvs.options.system-site-packages = false virtualenvs.path = "{cache-dir}\\virtualenvs" # C:\Users\redacted\AppData\Local\pypoetry\Cache\virtualenvs virtualenvs.prompt = "{project_name}-py{python_version}" virtualenvs.use-poetry-python = false ``` ### Python Sysconfig <details> <summary>sysconfig.log</summary> <!-- Please leave one blank line below for enabling the code block rendering. --> ``` Platform: "win-amd64" Python version: "3.11" Current installation scheme: "venv" Paths: data = "D:\Git\fame\fame-protobuf\.venv" include = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none\Include" platinclude = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none\Include" platlib = "D:\Git\fame\fame-protobuf\.venv\Lib\site-packages" platstdlib = "D:\Git\fame\fame-protobuf\.venv\Lib" purelib = "D:\Git\fame\fame-protobuf\.venv\Lib\site-packages" scripts = "D:\Git\fame\fame-protobuf\.venv\Scripts" stdlib = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none\Lib" Variables: BINDIR = "D:\Git\fame\fame-protobuf\.venv\Scripts" BINLIBDEST = "D:\Git\fame\fame-protobuf\.venv\Lib" EXE = ".exe" EXT_SUFFIX = ".cp311-win_amd64.pyd" INCLUDEPY = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none\Include" LIBDEST = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none\Lib" TZPATH = "" VERSION = "311" VPATH = "..\.." abiflags = "" base = "D:\Git\fame\fame-protobuf\.venv" exec_prefix = "D:\Git\fame\fame-protobuf\.venv" installed_base = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none" installed_platbase = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none" platbase = "D:\Git\fame\fame-protobuf\.venv" platlibdir = "DLLs" prefix = "D:\Git\fame\fame-protobuf\.venv" projectbase = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11-windows-x86_64-none" py_version = "3.11.14" py_version_nodot = "311" py_version_nodot_plat = "311" py_version_short = "3.11" srcdir = "C:\Users\redacted\AppData\Roaming\uv\python\cpython-3.11.14-windows-x86_64-none" userbase = "C:\Users\redacted\AppData\Roaming\Python" ``` </details> ### Example pyproject.toml ```TOML [build-system] requires = [ "poetry-core>=2.0.0",] build-backend = "poetry.core.masonry.api" [project] name = "fameprotobuf" version = "3.0.0" description = "Protobuf definitions converted to python classes for use in `fameio`" license = "Apache-2.0" readme = "README.md" requires-python = ">=3.10,<3.15" keywords = [ "protobuffer", "FAME", "framework", "fameio", "agent-based modelling",] dynamic = ["classifiers"] dependencies = [ "protobuf>=7.34,<7.35", ] [tool.poetry] classifiers = [ "Development Status :: 5 - Production/Stable", "Operating System :: OS Independent", "Topic :: Scientific/Engineering",] packages = [{include = "fameprotobuf", from = "src/main/python"}] ``` ### Poetry Runtime Logs <details> <summary>poetry-runtime.log</summary> <!-- Please leave one blank line below for enabling the code block rendering. --> ``` [vvv.txt](https://github.com/user-attachments/files/26573043/vvv.txt) ``` </details>
关闭于 2026-04-22 5 条评论