At Qxf2, we love Python. We use Python on multiple projects and as per our requirements, we install multiple modules. But, I found it difficult to create a requirements.txt file for specific projects manually. So I searched for a tool/technique to generate a requirement.txt file. I come across the pipreqs package, which generates a requirement.txt file based on the import statements of the project. I like it because it is helpful in maintaining the requirements file, easy to use and saves me a lot of time.
Setup:
To get setup with the pipreqs, you need to install the pipreqs package using the following command.
pip install pipreqs |
Usage:
Usage of the pipreqs is very easy. You just need to provide the root location of your project and the pipreqs automatically generate a requirements.txt file in root folder. Use the following command for usage.
pipreqs /path/to/project |
The following Fig. 1 shows a snapshot of how I generated a requirements.txt file for our Qxf2’s public POM.
The content of auto-generated requirement.txt:
requests==2.9.1 pytest==3.0.5 selenium==3.4.3 mechanize==0.2.5 python_dotenv==0.1.0 Appium_Python_Client==0.24 dotenv==0.0.5 |
Limitations:
Pipreqs uses imports of projects to generate a requirements.txt file. So, it is very important to note that, pipreqs will not include the plugins required for specific projects. You need to add plugins information manually in a requirement.txt.
In our case, I need to add pytest-xdist plugin details in a requirement.txt file manually.
If you are a startup finding it hard to hire technical QA engineers, learn more about Qxf2 Services.
I love technology and learning new things. I explore both hardware and software. I am passionate about robotics and embedded systems which motivate me to develop my software and hardware skills. I have good knowledge of Python, Selenium, Arduino, C and hardware design. I have developed several robots and participated in robotics competitions. I am constantly exploring new test ideas and test tools for software and hardware. At Qxf2, I am working on developing hardware tools for automated tests ala Tapster. Incidentally, I created Qxf2’s first robot. Besides testing, I like playing cricket, badminton and developing embedded gadget for fun.