Views: 59
0 0
Read Time:1 Minute, 42 Second

This guide will show you how to convert poetry.lock file into a requirements.txt and download the packages into a specific subfolder step by step.

Poetry vs pip

Poetry is starting to be more and more popular between developers as package manager for python projects (more information here https://python-poetry.org/docs/cli/) but one of the lacking thing I see is the ability to download only the libraries/packages like pip is doing with the -t flag. With this command we can download/install all the poetry.lock packages into a specific folder.

If your projects are managed with Poetry, and you want to download locally the packages into a particular subfolder for having a deeper look at the source code before using, maybe for curiosity or maybe because the company you are looking for is strongly regulated and there are particular policies in place, or maybe you just want to run and end to end static analysis and want to get more insight these are the commands that you were looking for.

Please note that at the moment of writing this article the poetry version in use is 1.1 and this functionality is still missing so this article could be invalid in a couple of months or years depends on how much is a priority for their team this functionality.

By looking around and reading here and there I found a combination of commands that will definitely be extremely useful.

Export poetry.lock into requirements.txt

To export your poetry.lock into requirements.txt just run the below command

poetry export -f requirements.txt -o requirements.txt --without-hashes

Download packages locally using pip

Once we have the requirements.txt file we can download into the destination we prefer (in our example will be the packages folder) by running this command

mkdir packages && pip install -r requirements.txt -t ./packages

I hope that helped and if you like it please share.

cc4ae2d7d0e2367495d9f75c31beef8e?s=400&d=robohash&r=g Convert poetry.lock file into a requirements.txt and download the packages

About Post Author

brewedbrilliance.net

Experienced software architect with a spasmodic passion for tech, software, programming. With more than 20years of experience I've decided to share all my knowledge in pills through this blog. Please feel free to contact me if there is any topic that you would love to cover
happy Convert poetry.lock file into a requirements.txt and download the packages
Happy
0 %
sad Convert poetry.lock file into a requirements.txt and download the packages
Sad
0 %
excited Convert poetry.lock file into a requirements.txt and download the packages
Excited
0 %
sleepy Convert poetry.lock file into a requirements.txt and download the packages
Sleepy
0 %
angry Convert poetry.lock file into a requirements.txt and download the packages
Angry
0 %
surprise Convert poetry.lock file into a requirements.txt and download the packages
Surprise
0 %

Share this content:

By brewedbrilliance.net

Experienced software architect with a spasmodic passion for tech, software, programming. With more than 20years of experience I've decided to share all my knowledge in pills through this blog. Please feel free to contact me if there is any topic that you would love to cover

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x