Sai Karthik
Balancing the braces ...pip2poetry - A script to migrate from pip to poetry
I have recently learnt about Poetry, which is an advanced dependency management & packaging tool for python.
The features which i have found impressive is that, by default it installs the project’s dependencies in a seperate virtual environment. which is such a nice thing to have! and we can just activate the environment with command poetry shell
. we can exit the virtual environment by exit
command. This removes the need of a seperate virtual environment management software.
Also, Poetry makes it very easy to package & publishing the project to PyPi with commands poetry build
& poetry publish
respectively.
So, I tried to migrate the existing gkcore project, which uses pip & requirements file to manage it’s dependencies.
I first started the migration process. poetry init
command converted the existing project into poetry project by adding two files pyproject.toml
& poetry.lock
file with initial data. Then, i searched if poetry can import dependencies from existing requirements.txt
file & there seem to be no such built-in feature. So, i decided to write a simple script which does the job.
This script parses the requirements.txt file (optionally takes custom file name as first parameter) & then installs the packages using poetry command.
Below is the contents of the file:
|
|