Python Poetry for a Noob - Getting started

preview_player
ะŸะพะบะฐะทะฐั‚ัŒ ะพะฟะธัะฐะฝะธะต
๐Ÿ‰ โ‹† ๐Ÿซ ๐ŸŽ€ ๐•Š๐•ฆ๐•ž๐•ž๐•’๐•ฃ๐•ช ๐ŸŽ€ ๐Ÿซ โ‹† ๐Ÿ‰
Managing packages and dependencies in Python can be overwhelming and resource intensive. Poetry will help with starting new projects, maintaining existing ones and provide centralized dependency management. Like most Python projects, it relies on external packages. The maintenance work falls on the developer to make sure each version of each package is updated and working after each update. By leveraging Poetry, a dependency manager, we can specify, install and resolve external packages in one source location known as out project file. This way we can ensure we always have the right dependencies,lol versions and configurations, and dependencies of dependencies, with the added value of central management.

๐Ÿ‰ โ‹† ๐Ÿซ ๐ŸŽ€ ๐”ฝ๐•š๐•๐•–๐•ค ๐•’๐•Ÿ๐•• ๐•„๐• ๐•ฃ๐•– ๐”ฝ๐•š๐•๐•–๐•ค ๐ŸŽ€ ๐Ÿซ โ‹† ๐Ÿ‰

MANIFEST.in - Specifies metadata for accompanying files

Pipfile - Dedicated file for project dependencies

๐Ÿ‰ โ‹† ๐Ÿซ ๐ŸŽ€ ๐•Ž๐•™๐•’๐•ฅ ๐•ก๐• ๐•–๐•ฅ๐•ฃ๐•ช ๐••๐• ๐•–๐•ค ๐•—๐• ๐•ฃ ๐•ž๐•–? ๐ŸŽ€ ๐Ÿซ โ‹† ๐Ÿ‰
After implementing Poetry, you will have 2 new files.

๐Ÿ‰ โ‹† ๐Ÿซ ๐ŸŽ€ โ„‚๐•ฃ๐•–๐•’๐•ฅ๐•š๐•Ÿ๐•˜ ๐•’ ๐•Ÿ๐•–๐•จ ๐•ก๐• ๐•–๐•ฅ๐•ฃ๐•ช ๐•ก๐•’๐•”๐•œ๐•’๐•˜๐•– ๐ŸŽ€ ๐Ÿซ โ‹† ๐Ÿ‰
Creating our first poetry package is very simple.
$poetry new dolphin-poetry-project

A folder will be created "rp-poetry". Poetry will normalize packages for you automatically. The Poetry file structure is formatted as below.

dolphin-poetry-project
โ”œโ”€โ”€ dolphin-poetry-project
โ”‚ โ””โ”€โ”€ __init__.py
โ”œโ”€โ”€ tests/
โ”‚ โ”œโ”€โ”€ __init__.py
โ”‚
โ”œโ”€โ”€ README.md

A toml and a lock file will be created to track all our packages, dependencies and version. See examples below.

------------------------------------------------------------------------------------------------------------
name = "dolphin-poetry-project"
version = "0.1.5"
description = "Dolphin test project"

python = "^3.7"

pytest = "^4.6"
invoke = "^1.8"
pycrypto = "^4.3"
strings = "^4.1"

remove-empty-directories = true

[build-system]
requires = ["poetry=0.12"]

run = "wsgi:main"

------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
[[package]]name = "pytest"
version = "0.17.2"
description = "Python graph [network] package"
category = "dev"
optional = false
python-versions = "*"[[package]]
name = "attrs"
version = "20.3.0"
description = ""
category = "dev"
optional = false
python-versions = "=2.7, !

pytesting = "=1.1.0"

[[package]]name = "invoke"
version = "0.17.2"
description = "Python graph [network] package"
category = "dev"
optional = false
python-versions = "*"[[package]]
name = "attrs"
version = "20.3.0"
description = ""
category = "dev"
optional = false

------------------------------------------------------------------------------------------------------------
๐Ÿ‰ โ‹† ๐Ÿซ ๐ŸŽ€ The workflow
This can be allot to take in, so lets look at the workflow.
1. Install Poetry
2. Create a Poetry package
3. Add a package
4. Update the packages
5. Track/list the packages
6. Build the package
7. Install the package

๐Ÿ‰ โ‹† ๐Ÿซ ๐ŸŽ€ Workflow specifics
1. Installing on linux
B. Check version with - poetry --version
C. Set environment variable - export PATH="$HOME/.poetry/bin:${PATH}"

2. Create a Poetry package
poetry new mypoetryproject

3. Adding packages
poetry add "package name"

4. Update the packages
Poetry update

5. Track/list the packages
poetry show --tree

6. Build the packages
Poetry build

7. Publishing Packages
poetry publish

8. Publishing Packages
poetry publish

References:

Music:- ASHUTOSH - Chile
ะ ะตะบะพะผะตะฝะดะฐั†ะธะธ ะฟะพ ั‚ะตะผะต
ะšะพะผะผะตะฝั‚ะฐั€ะธะธ
ะะฒั‚ะพั€

Informative video.
Clarity could have been improved .

yashwal