Title basically says it all. How can I tell pip freeze
to ignore certain packages, like pylint
and pep8
, and their dependencies?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
My approach is the following:
.bashrc
I create the following alias:alias pipfreezeignore='pip freeze | grep -vFxf ignore_requirements.txt'
pip install jedi flake8 importmagic autopep8 yapf
).ignore_requirements.txt
file, as inpip freeze > ignore_requirements.txt
.pip install django
)pipfreezeignore > requirements.txt
(in the same folder whereignore_requirements.txt
is) so I just get inrequirements.txt
the installed packages that are not inignore_requirements.txt
If you always want to ignore the same packages (through all your virtual environments), you might redefine the alias as in
alias pipfreezeignore='pip freeze | grep -vFxf /abs/path/to/ignore_requirements.txt'
Just make sure that no packages fromignore_requirements.txt
are not actually necessary for your project.There are few options available
Try simple ignorance
Simply do not care about these packages being present in
pip
output.Delete these lines from output
Filter the output through some
grep
filter and have the result clean.Use virtualenv and do not install unwanted packages into it
Note, that pip freeze in virtualenv does not report globally installed packages (however it typically reports
argparse
andwsgiref
for me - nothing seems to be really perfect.)Write your own
pipwarm
commandwhich would call pip freeze and modify the output as needed (removing unneeded files).
I am aware, I probably did not give you the answer you asked for, but maybe the virtualenv is close to what you need, as it allows global presence of those packages and still allow not having these packages in output of pip freeze.
Install
pep8
andpylint
as scripts but keep them away from pip visibilityIn case, you just care about having
pylint
andpep8
available as command line tools, but do not require them visible topip freeze
, there are multiple optionsInstall
pep8
andpylint
into virtualenv and copy the scripts to/usr/bin
If you install
pylint
andpep8
into separate virtualenv, find location of the executables bywhich pep8
andwhich pylint
and copy these files somewhere, where they will be visible, e.g. to/usr/bin
. The scripts you copy or move from virtualenv have hardcoded path to required python packages in the virtualenv and will safely run even when copied (just the scripts, do not touch the rest of related virtualenv). Note, that there is no need to activete given virutalenv to make that working.Install
pep8
andpylint
system wide but keep developing in virtualenvSystem wide installed command line tools are typically installed into location, which makes them globally visible. At the same time, system wide installed packages are not seen by
pip freeze
when called in virtualenv.on windows with powershell: