Automating post install of python dependency from git using poetry

When working with Python, it is common to have dependencies that need to be installed. In some cases, these dependencies may be hosted on Git repositories. Manually installing these dependencies can be time-consuming and error-prone. In this article, we will explore different ways to automate the post-installation of Python dependencies from Git using Poetry.

Option 1: Using Poetry’s add command

One way to automate the installation of Python dependencies from Git using Poetry is by using the add command. This command allows you to add a dependency to your project’s pyproject.toml file. To install a dependency from a Git repository, you can specify the repository URL along with the package name.


poetry add git+https://github.com/username/repo.git

This command will add the dependency to your project’s pyproject.toml file and install it automatically. Poetry will handle the cloning and installation process for you.

Option 2: Using Poetry’s install command

Another way to automate the installation of Python dependencies from Git using Poetry is by using the install command. This command allows you to install all the dependencies listed in your project’s pyproject.toml file.


poetry install

By running this command, Poetry will read the pyproject.toml file and install all the dependencies, including those from Git repositories.

Option 3: Using a requirements.txt file

If you prefer to use a requirements.txt file to manage your dependencies, you can also automate the installation of Python dependencies from Git using Poetry. First, create a requirements.txt file and add the Git dependency in the following format:


git+https://github.com/username/repo.git

Then, run the following command to install the dependencies:


poetry install -r requirements.txt

This command will read the requirements.txt file and install all the dependencies, including those from Git repositories.

After exploring these three options, it is clear that using Poetry’s add command (Option 1) is the most straightforward and efficient way to automate the post-installation of Python dependencies from Git. It allows you to directly add the dependency to your project’s pyproject.toml file and handles the installation process for you. This approach eliminates the need for an additional requirements.txt file and simplifies the dependency management process.

Rate this post

5 Responses

    1. Nah, Option 2 is where its at! No need for unnecessary dependencies cluttering up your code. Keep it clean and lean, my friend. Efficiency is key! 💯

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents