Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot specify dependency in parent folder with Poetry

I have the following file hierarchy:

./
├── abc
│   ├── pyproject.toml
│   ├── main.py
│   └── xyz 
│      ├── __init__.py
│      └── other.py
└── common-lib
    ├── pyproject.toml
    └── common
        ├── __init__.py
        └── lib1.py

In pyproject.toml file of abc, I cannot seem to add common-lib as a dependency no matter how I try. One example is as below. I checked many similar questions.

[tool.poetry]
packages = [{ include = "common", from = "common-lib" }]
[tool.poetry.dependencies]
common-lib = { path = "../common-lib", develop=true}

I receive the following error.

Updating dependencies
Resolving dependencies...

Package operations: 1 install, 0 updates, 0 removals

  • Installing common-lib (0.1.0 somePath/common-lib)

  ModuleOrPackageNotFound

  No file/folder found for package common-lib

  at ~\AppData\Roaming\Python\Python310\site-packages\poetry\core\masonry\utils\module.py:63 in __init__
       59│                             "from": str(src.relative_to(self._path)),
       60│                         }
       61│                     ]
       62│                 else:
    →  63│                     raise ModuleOrPackageNotFound(
       64│                         "No file/folder found for package {}".format(name)
       65│                     )
       66│
       67│         for package in packages:

Could you help me solving this problem?

like image 770
Erdem Tuna Avatar asked Oct 22 '25 23:10

Erdem Tuna


1 Answers

I managed to solve the issue with the following settings in the pyproject.toml.

[tool.poetry]
packages = [{ include = "common", from = "../common-lib"}]
[tool.poetry.dependencies]
common-lib = "../common-lib"
like image 174
Erdem Tuna Avatar answered Oct 25 '25 15:10

Erdem Tuna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!