Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I tell pip to ignore requirements installed via `setup.py develop`?

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?"

like image 267
Wayne Werner Avatar asked Nov 11 '22 09:11

Wayne Werner


1 Answers

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.

like image 52
alecxe Avatar answered Nov 14 '22 22:11

alecxe