Create Python Package Using Python-poetry
$ pip install poetry
$ poetry new my-pkg
change directory into new project
$ cd my-pkg
$ poetry config virtualenvs.create true --local
$ poetry config virtualenvs.in-project true --local
#$ poetry config repositories.foo https://foo.bar/simple/ //optional
Create virtual environment
python -m venv .venv
$ source .venv/bin/activate
Install poetry inside new venv again
$ pip install poetry
Update `pyproject.toml file
[tool.poetry]
name = "my-pkg"
version = "0.1.0"
description = "My Project"
authors = ["Karthik Prasad"]
readme = "README.md"
license = "MIT"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Automation Suite :: Pytest"
]
[tool.poetry.dependencies]
python = "^3.8"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
allure-pytest = "^2.9.45"
#[tool.poetry.scripts]
#my-pkg = 'my-pkg:main'
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Check `poetry.toml file validity.
$ poetry check
$ poetry install
$ pytest --alluredir=allure-reports/
Update .vscode/settings.json with virtual environment
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
}
$ allure serve allure-reports/
$ poetry build
$ poetry publish -r my-pkg
$ deactivate
(Optional) create requirements.tx
$ pip freeze > requirements.txt
(optional) Install from requrements.tx
$ pip install -r requirements.txt