Search code examples
pythonpippython-poetry

poetry install failed when there is path dependecy


I have this dirs:

.
├── project1
│   ├── calc.py
│   └── pyproject.toml
└── project2
    ├── foo.py
    └── pyproject.toml

project1/pyproject.toml (was generated by poetry install, then i`ve added project2 dependency:

[tool.poetry]
name = "project1"
version = "0.1.0"
description = ""
authors = ["sib"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
project2 = {path="/home/sib/projects/test_poetry/project2/"}


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

project2/pyproject.toml (was generated by poetry init)

[tool.poetry]
name = "project2"
version = "0.1.0"
description = ""
authors = ["sib"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

When i try poetry install in project1 directory i have error:

  PoetryException

  Failed to install /home/sib/projects/test_poetry/project2

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/pip.py:58 in pip_install
       54│ 
       55│     try:
       56│         return environment.run_pip(*args)
       57│     except EnvCommandError as e:
    →  58│         raise PoetryException(f"Failed to install {path.as_posix()}") from e
       59│ 

How can i fix this problem? i have this problem on Ubuntu and Windows


Solution

  • I solve this problem. I decide create new project nearly project1(2). I use poetry new ... instead poetry init. Then installing project1 was completed successfully. I added README.md into project2, create project2/project2/__init.py and move foo.py to project2/project2. After that installing project1 was completed successfully too.