1

Is there an easy way in pip or conda to create a list of all stale packages in the current virtual environment?

By "stale package" I mean the following two criteria are met:

  1. There are no updates available.
  2. The last release happened >2 years ago.

I want to use this to weed out packages from my large default enviroment of projects that are no longer maintained.

Hyperplane
  • 1,422
  • 1
  • 14
  • 28

1 Answers1

1

On the Pip-side of things, the answers in this question should cover your needs.

On the Conda side, there isn't any CLI command that provides such functionality, but one can look at the timestamps on the JSON files in the conda-meta/ folder of the environment. Those get updated whenever a package is installed.

At first pass, one could list the files sorted by oldest to newest:

## environment name
env_name="foo"

## resolve its location
env_path=$(conda run -n ${env_name} echo $\{CONDA_PREFIX\})

## list files in its `conda-meta` folder
ls -lthr ${env_path}/conda-meta

Note that the history and pinned files are special and do not correspond to packages.

Otherwise, one could use find to list all files older than a given date.

merv
  • 67,214
  • 13
  • 180
  • 245
  • 1
    Oh, there is a misunderstanding. I am not interested in when I updated the file on my computer, I am interested in when the packages were released in the pypi/conda repository. Basically, from time to time I want to compile a list of packages to consider dropping from my default environment because the projects are not maintained anymore. – Hyperplane Jan 20 '22 at 01:52
  • @Hyperplane oops, sorry about that! I’m still going to leave this here, just in case someone comes across this question looking for this particular answer. – merv Feb 05 '22 at 04:10