Listreqs
is a simple requirements.txt
generator. It's an alternative to pipreqs
. Where in Pipreqs, it helps you to Generate requirements.txt file for any project based on imports, but in Listreqs you need to create a virtual environment first, and do your required installations there. And when you need to create your requirements.txt
use Listreqs.
Using shell script | Using python script |
---|---|
![]() |
- Create your virtual env,
- pip install virtualenv - mkdir TextGenEnv - virtualenv TextGenEnv - activate the env: + for cmd -> TextGenEnv\Scripts\activate + (for git bash, source ./Scripts/activate) + (for linux terminal, source TextGenEnv/bin/activate)
- do your required installations there
- And when you need to create your requirements.txt do these steps,
- activate the environment using above command
pip list > requirements.txt
-> it will put the output of thepip list
command inside therequirements.txt
python listreqs.py
and give the path of the previously createdrequirements.txt
- Boom!!!
- Create your virtual env,
- pip install virtualenv - mkdir TextGenEnv - virtualenv TextGenEnv - activate the env: + TextGenEnv\Scripts\activate + (for bash source ./Scripts/activate)
- do your required installations there
- And when you need to create your requirements.txt do these steps,
sh listreqs.sh
and pass the file namerequirements.txt
.- Boom!!!
- heads up while using the shell script,
-
Usage:
- Can pass in as a positional(command line) argument:
bash listreqs.sh reqs.txt
- Can input the file name from the prompt after running the shell script
bash listreqs.sh Enter the requirements file name : reqs.txt
- Not passing any input will lead to the creation of a default file called
requirements.txt
.
bash listreqs.sh Enter the requirements file name :
-
- Create a single shell script to get the job done.
- Use the python script to create a python library:
It should be like a shell command,like doing
Listreqs requirements.txt
after activating the virtual environment should create arequirements.txt
with all the installed package name and verison inside the current directory. - Create
requirements.txt
from a public repo whererequirements.txt
is not given. Usepython poetry
for this. - Create
requirements.txt
from base environment, using basic regex