2

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?

Erdem Tuna
  • 500
  • 4
  • 18

1 Answers1

2

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"
Erdem Tuna
  • 500
  • 4
  • 18
  • This worked ☝. I had to add this setup.py file to the package folder (to give a version number--a required parameter): `from setuptools import setup, find_packages` `setup(name='myproject', version='1.0', packages=find_packages())` Learned this from this article about sibling imports in general python: https://stackoverflow.com/a/50193944/3015186 And for the dependencies, I had to use OP's syntax (my directory name and package name happened to be the same, so I think these could maybe differ if your containing folder differs): `sibling_package = {path = "../sibling_package"}` – Preston Frasch May 24 '23 at 23:19