This is a copy of this <http://stackoverflow.com/questions/41649507/how-to-modify-pip-in-a-virtualenv> StackOverflow post.
I am trying to modify pip, so that after each install or uninstall, my requirements.txt will get updated. To do so, I have modified the pip file in the bin/ of my virtual env. pip: #!/Users/username/ProjectEnv/bin/python3 # -*- coding: utf-8 -*- import re import sys from pip import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) status = main() if status == 0 or status is None: sys.argv = ['pip', 'freeze', '>', '../Project/requirements.txt'] sys.exit(main()) This didn't work. I have tried printing the command line arguments and putting a breakpoint, but they didn't work as well. pip: #!/Users/username/ProjectEnv/bin/python3 # -*- coding: utf-8 -*- import re import sys import pdb pdb.set_trace() from pip import main if __name__ == '__main__': for arg in sys.argv: print(arg) sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) status = main() if status == 0 or status is None: sys.argv = ['pip', 'freeze', '>', '../Project/requirements.txt'] sys.exit(main()) What am I doing wrong here? Regards On Saturday, January 14, 2017 at 3:13:51 PM UTC+3, Utku Gültopu wrote: > > This is a copy of this > <http://stackoverflow.com/questions/41649507/how-to-modify-pip-in-a-virtualenv> > > StackOverflow post. > > > I am trying to modify pip, so that after each install or uninstall, my > requirements.txt will get updated. > > To do so, I have modified the pip file in the bin/ of my virtual env. > > pip: > > #!/Users/username/ProjectEnv/bin/python3 > > # -*- coding: utf-8 -*- > import re > import sys > > from pip import main > > if __name__ == '__main__': > sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) > status = main() > if status == 0 or status is None: > sys.argv = ['pip', 'freeze', '> ../Project/requirements.txt'] > sys.exit(main()) > > This didn't work. I have tried printing the command line arguments and > putting a breakpoint, but they didn't work as well. > > pip: > > #!/Users/username/ProjectEnv/bin/python3 > > # -*- coding: utf-8 -*- > import re > import sys > import pdb > pdb.set_trace() > > from pip import main > > if __name__ == '__main__': > for arg in sys.argv: > print(arg) > sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) > status = main() > if status == 0 or status is None: > sys.argv = ['pip', 'freeze', '> ../Project/requirements.txt'] > sys.exit(main()) > > What am I doing wrong here? > > Regards > -- You received this message because you are subscribed to the Google Groups "virtualenv" group. To unsubscribe from this group and stop receiving emails from it, send an email to python-virtualenv+unsubscr...@googlegroups.com. To post to this group, send email to python-virtualenv@googlegroups.com. Visit this group at https://groups.google.com/group/python-virtualenv. For more options, visit https://groups.google.com/d/optout.