News for hackers. Stuff that matters.
Re:Generate pip requirements.txt file based on imports of an... by remram on Monday September 30, 2024 @01:52PM (#41700014)
Can I have it find the requirements as of a specific date?

If I find a script/notebook/project with no requirements.txt, I usually know when it was created. Being able to get the versions that were selected back then on the author's machine would be great for reproducibility.

Re:Generate pip requirements.txt file based on imports of an... by matrss on Monday September 30, 2024 @02:06PM (#41700154)
For the future, please pick a package manager that can give you a lock file alongside your code, so that you have a definitive record of the dependencies.

Even if you have all versions as of the time of the last modification to the code, you don't know if the dependency resolution happened at that point in time, or if the environment was set up years prior and never updated.

Nevertheless, this is what you are looking for: https://pypi.org/project/pypi-timemachine/

Re:Generate pip requirements.txt file based on imports of an... by remram on Monday September 30, 2024 @04:03PM (#41701453)
When I said "the author" I was not trying to mean myself.

Agreed that in a perfect world I would never need this, but...

Re:Generate pip requirements.txt file based on imports of an... by d0mine on Monday September 30, 2024 @02:17PM (#41700269)
See whether “exclude-newer” uv option might help if you’ve inherited a script without a dependencies lock file https://docs.astral.sh/uv/guides/scripts/#improving-reproduc...
Re:Generate pip requirements.txt file based on imports of an... by oprypin on Monday September 30, 2024 @02:21PM (#41700319)
Re:Generate pip requirements.txt file based on imports of an... by remram on Monday September 30, 2024 @04:05PM (#41701477)
This is great!
Re:Generate pip requirements.txt file based on imports of an... by 0cf8612b2e1e on Monday September 30, 2024 @02:03PM (#41700117)
I have never realized until this moment that I want such a tool. Ideally, you would never find yourself in this position, but alas.