I have a python project with a pyproject.toml
file. Typically I store the project's version number in pyproject.toml
like this:
% grep version pyproject.toml
version = "0.0.2"
%
I want to get that version number into a Makefile
variable regardless of how many spaces wind up around the version terms.
What should I do to extract the pyproject.toml
version string into a Makefile
environment variable called VERSION
?
An alternative solution to parse major.minor.patch
, based on @Mike Pennington's answer:
grep -m 1 version pyproject.toml | grep -e '\d.\d.\d' -o