The biggest difference between Pipenv and Poetry is that Pipenv can't be used in library projects, but I thought Poetry could be used, so I studied Poetry.
This is a sample that installs two projects, the main project and the library project, via Github and executes the functions of the library project from the main project.
The sources are listed in the main project and the library project.
poetry-lib
├── pyproject.toml
└── poetry_lib
└── aaa2.py
poetry-main
├── pyproject.toml
└── main.py
poetry-lib
pyproject.toml
[tool.poetry]
name = "poetry-lib"
version = "0.1.0"
description = ""
authors = ["va034600"]
packages = [
{ include = "poetry_lib" },
]
[tool.poetry.dependencies]
python = "^3.6"
python-dateutil = "^2.8.1"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
aaa2.py
from dateutil.relativedelta import *
from datetime import *
def bbb2():
today = datetime.now()
return today + relativedelta(months=+6)
poetry-main
pyproject.toml
[tool.poetry]
name = "poetry-main"
version = "0.1.0"
description = ""
authors = ["va034600"]
[tool.poetry.dependencies]
python = "^3.6"
poetry-lib = { git = "ssh://[email protected]/va034600/poetry-lib.git" }
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
main.py
from poetry_lib import aaa2
print(aaa2.bbb2())
setup
$ cd poetry-main
$ poetry install
$ python main.py
2021-03-13 08:00:14.266597
If you use Pytharm, you can debug and check the reflection of the modified library by attaching the library project to the main project. Convenient
Recommended Posts