Sample to reference Poetry project on GitHub

Introduction

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.

Directory structure

poetry-lib


├── pyproject.toml
└── poetry_lib
    └── aaa2.py

poetry-main


├── pyproject.toml
└── main.py

File

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())

Run

setup


$ cd poetry-main
$ poetry install
$ python main.py
2021-03-13 08:00:14.266597

At the end

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 スクリーンショット 2020-09-13 8.09.38.png

Recommended Posts

Sample to reference Poetry project on GitHub
How to reference static files in a Django project
How to use GitHub on a multi-person server without a password
Sample to put Python Flask web app on Azure App Service (Web App)
Sample script to monitor Load Average on CloudWatch on AWS EC2