I have a small repository that stores the Python coding standards adopted by the team in the pylint configuration form. Also there are instructions and requirements.txt for installation via pip:

pip install -r requirements.txt 

Obviously, requirements.txt must be pylint. But the official documentation for pylint clearly indicates that the astroid package is also required for pylint to work.

I made sure that the pip install pylint successfully installs astroid and other dependencies:

Before:

 (venv)➜ pip list pip (7.1.2) setuptools (18.2) wheel (0.24.0) 

After:

 (venv)➜ pip list astroid (1.4.6) colorama (0.3.7) lazy-object-proxy (1.2.2) pip (7.1.2) pylint (1.5.6) setuptools (18.2) six (1.10.0) wheel (0.24.0) wrapt (1.10.8) 

It seems that everything works. But the dependency is for some reason explicitly indicated in the documentation, and even a separate installation instruction is given.

Q: Should I add astroid and other dependencies to requirements.txt? Is there a standard that gives an unequivocal answer to this question?

2 answers 2

1) Could not find the PEP that regulates it.

2) But there is documentation for pip. Quote:

Silence free download . In this case, your requirement file contains a pinned version.

The dependency file is used to save the results of the pip freeze command in order to achieve the same repeated installation. In this case, everything that was received from pip freeze with explicitly specified versions is placed in the dependency file.

If you’re not so good, you’ll not be able to get it.

If you use pip freeze to generate a dependency file, then not only top level dependencies are placed there, but also dependency dependencies, etc.

That is, a dependency file is designed to collect dependencies for the whole environment, for everything. On the contrary, if you use install_requires in setup.py (that is, only for one application), then it is not recommended to specify sub-dependencies in it. Source - http://python-packaging-user-guide.readthedocs.io/en/latest/requirements/#requirements-files

  • Of the minuses of this approach - the packages get rotten with time (especially dependencies) and then the exact picture can no longer be restored - FeroxTL

No no need. If the developers of other packages have indicated dependencies (and usually this is so), then pip will install them itself.