PantsBuild 无法在我的工作目录中找到定位文件

问题描述 投票:0回答:1

我正在尝试穿着裤子来运行我的项目

我在使用 Polylith 结构的 monorepo 工作,对于某些 Reson Pants 找不到我的文件

文件树如下所示:

project
|
|--Workspace
|   |
|   |--bases
|   |--components
|   |  |--utils
|   |  |  |--some_file.py
|   |--projects
|   |  |--proj1
|   |  |  |--main.py
|   |--tests
|
|--pants.toml

pants.toml
文件中,我定义了以下内容:

...
[source]
root_patterns = [
  "/Workspace",
]
...

我正在尝试从

some_file
导入
main
,如下所示:

from Workspace.components.utils import some_file

根据此页面:https://www.pantsbuild.org/2.19/docs/using-pants/key-concepts/source-roots 据我了解这应该有效,但我得到的是:

ModuleNotFoundError: No module named 'Workspace'

我尝试在 main.py 的 BUILD 文件中定义依赖项,但无论我如何更改构建中的路径和

pants.toml
[sources]
,它都看不到任何文件 它返回另一个错误:

pants.engine.target.InvalidFieldException: Workspace/projetcs/proj1: Failed to get dependencies for Workspace/projetcs/proj1/main.py: The file or directory 'components/utils' does not exist on disk in the workspace, so the address 'components/utils:some_file' from the `dependencies` field from the target Workspace/projetcs/proj1/main.py cannot be resolved.
python pants python-polylith
1个回答
0
投票

我最终放弃了将 Repo 划分到不同的工作空间,并将

base/project/components
文件夹放在项目根目录下的做法,从而达到了目的

© www.soinside.com 2019 - 2024. All rights reserved.