4

Is there any parser out there for reading in a Pipfile and returning a list of all packages used in the Pipfile?

If not, how would one go about this? I was thinking a regular expression could do the job, but I am not sufficiently acquainted with the structure of Pipfiles to confirm that is the case.

ubadub
  • 3,571
  • 21
  • 32
  • are you asking about requirements.txt (ie `pip install -r requirements.txt`)? – Joran Beasley Oct 26 '18 at 20:16
  • No, I'm asking about a `Pipfile`, which is the new standard that replace the `requirements.txt` file @JoranBeasley – ubadub Oct 26 '18 at 20:17
  • 1
    it is not a new standard... at all ... its a 3rd party library that aims to provide an alternative package management ... that said here is the library and it includes a parser https://github.com/pypa/pipfile – Joran Beasley Oct 26 '18 at 20:26
  • 'Standard' was the wrong word, it just seems like "use pipenv" (which uses Pipfiles) is the standard advice in a lot of Python communities online. Anyways, thank you @JoranBeasley – ubadub Oct 26 '18 at 20:34
  • I think most now recommend python poetry package ... well probably 50/50 ... with another 50 just using normal requirements.txt – Joran Beasley Oct 26 '18 at 23:43

1 Answers1

7

first install pipfile pip install pipfile.

then just use the parser it provides

from pipfile import  Pipfile
parsed = Pipfile.load(filename=pipfile_path)
Joran Beasley
  • 110,522
  • 12
  • 160
  • 179