I'm working on a Python library, which I have installed in my local virtualenv for testing. I have several dependencies installed with pip. When I do
$ pip freeze > requirements.txt
it adds my current project like so:
-e [email protected]:path/to/my/project@somehash#egg=lib-master
Which I have to manually remove - my project doesn't actually depend on itself. Is it possible to pass a parameter to pip that says, "Hey, ignore this/these kinds of packages?"
The simplest solution would be to pipe the result of pip freeze
to grep
with -v
(invert-match):
pip freeze | grep -v 'project_name' > requirements.txt
Demo:
$ mkvirtualenv test
New python executable in test/bin/python
Installing Setuptools...done.
Installing Pip...done.
(test)$ pip freeze
wsgiref==0.1.2
(test)$ pip install requests
Downloading/unpacking requests
Downloading requests-2.2.1.tar.gz (421kB): 421kB downloaded
Running setup.py egg_info for package requests
Installing collected packages: requests
Running setup.py install for requests
Successfully installed requests
Cleaning up...
(test)$ pip freeze
requests==2.2.1
wsgiref==0.1.2
(test)$ pip freeze | grep -v 'requests'
wsgiref==0.1.2
(test)$ pip freeze | grep -v 'requests' > requirements.txt
(test)$ cat requirements.txt
wsgiref==0.1.2
Also see: Negative matching using grep (match lines that do not contain foo).
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With