I have a simple project layout
myproject on ī main [$!?] is š¦ v1.0.0 via ī v18.14.0 via š v3.10.9
⯠tree -L 1
.
āāā build
āāā deploy
āāā Dockerfile
āāā poetry.lock
āāā pyproject.toml
āāā README.md
āāā scripts.py
āāā src
The pyproject.toml is:
[tool.poetry]
name = "myproject"
version = "0.1.0"
description = ""
authors = [""]
[tool.poetry.scripts]
test = "scripts:test"
The scripts.py is:
import subprocess
def test():
"""
Run all unittests.
"""
subprocess.run(
['python', '-u', '-m', 'pytest']
)
if __name__ == '__main__':
test()
When I run poetry run test:
myproject on main [$!?] is š¦ v1.0.0 via ī v18.14.0 via š v3.10.9
No file/folder found for package myproject
Short answer:
The directory where your pyproject.toml file sits needs to be share the same name, e.g., if the name config in pyproject.toml is name = "myproject", the directory needs to be also named myproject. Therefore, you must either:
pyproject.toml orpyproject.toml file to the correct directory orpackage-mode = false to your pyproject.toml.Explanation:
There's a thread on the official GitHub for Poetry that discusses this issue. The gist of the issue is that whatever you choose for your project name, i.e., name = "myproject", needs to be the direct parent directory of where your pyproject.toml file lives. When there is a mismatch, you get the error you are getting.
Sources:
For those that will have same error as mine:
rename package-name to package_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With