requirements.txt vs setup.py

I started working with Python. I've added requirements.txt and setup.py to my project. But, I am still confused about the purpose of both files. I have read that setup.py is designed for redistributable things and that requirements.txt is designed for non-redistributable things. But I am not certain this is accurate.

How are those two files truly intended to be used?

requirements.txt

This helps you to set up your development environment. Programs like pip can be used to install all packages listed in the file in one fell swoop. After that you can start developing your python script. Especially useful if you plan to have others contribute to the development or use virtual environments. This is how you use it:

    pip install -r < requirements.txt

setup.py

This allows you to create packages that you can redistribute. This script is meant to install your package on the end user's system, not to prepare the development environment as pip install -r < requirements.txt does. See this answer for more details on setup.py.

The dependencies of your project are listed in both files.

From: stackoverflow.com/q/43658870