Consider having a python requirements.txt
file with a list of (un-versioned) dependencies (python packages). After you install them (e.g. pip install -r requirements.txt
) you can call pip freeze
and get a (versioned) list of all installed python packages.
This will be a snapshot of the python package versions (and their dependencies) available at the time. What I need to generate is this same list, but for a date in the past (let's say 2018-06-12
).
I guess technically, I only need to find the released versions for all packages contained in the requirements.txt
file.
Ideally, there would be a command pip install -r requirements.txt --before 2018-06-21
and then just call pip freeze
, but I didn't see anything like that in pip install --help
. I did see a way to specify another --index-url
and I could imagine if there was an archived index from that date, I could point pip
to that and it should work?
There is also a --constraint
option, which:
Constrain versions using the given constraints file
But I'm guessing I would already have to have the date-constraint versions in that case?
Alright, one possible answer (although not a great one) is to just manually go through each dependency in the requirements.txt
, look that package up on https://pypi.org and then visit the release history (e.g. https://pypi.org/project/requests/#history). From there it's easy enough to see which version had been released at what date (e.g. https://pypi.org/project/requests/2.19.0/ for requests
when including 2018-06-12
) and then just use that as the version (requests==2.19.0
).
A slightly better answer might be to extract that info (maybe via curl
) from pypi programmatically, extract all version info (including the dates), sort it and pick the right one.