Skip to content

HowTo Create and Update Requirements File

Niels Korschinsky edited this page Aug 30, 2022 · 2 revisions

HowTo: Create and Update Requirements File

Two tools and steps are required to create the requirements file. First, the requirements file will be built based on the imports of the source code. Then, the sub-dependencies are included to allow an offline installation and make the dependencies more secure.

Building the base requirement file

The project pipreqs is used to determine all requirements of SPPMon.

  • Please install it using pip3 install pipreqs
  • Create a copy of the existing requirements file: cp ./python/requirements.txt ./python/requirements-copy.txt
  • Overwrite the existing requirements file: pipreqs --force --mode no-pin ./python/
  • Add manual requirements to the file using nano (or vim), as they are not detected automatically: nano ./python/requirements.txt Refer to the copied version if any more versions need to be added: cat ./python/requirements-copy.txt
    • pandas-stubs
    • openpyxl
    • pyxlsb
    • pip

This requirement file does not contain any version numbers.

Building the extended requirements file

The command pip-compile, supplied by the pip-tools project, is used to list all sub-requirements of the just-created requirements file.

  • Please install it using pip3 install pip-tools

  • Execute it on the existing requirements file, locking all version numbers: pip-compile -U --allow-unsafe ./python/requirements.txt

  • Add the manual requirements as a comment at the top of the file using nano (or vim): nano ./python/requirements.txt

    # manually added
    # pandas-stubs
    # openpyxl
    # pyxlsb
    # pip
    
    ####

The requirements file is now finished. Compare again if any manually added requirements are missing from the copied file: cat ./python/requirements-copy.txt
If not, delete the copied file: rm ./python/requirements-copy.txt

Clone this wiki locally