Hello there; has anyone here succesfully used the ...
# general
a
Hello there; has anyone here succesfully used the
pdm.backend
build system with a dynamic build version from scm through
pants package ::
? On our current project, we've been trying to use git tags to automatically setup build versions, i.e. with the following tag
subproject/X.Y.Z
, PDM can automatically fetch the tag version using
pdm build
to produce the corresponding distribution
dist/subproject-X.Y.Z-py3-none-any.whl
. However, through
pants package ::
, the backend doesn't seem to have access to those git tags. Has anyone else experienced this ? Is there a way to include those tags into the packaging process ?
h
Pants runs every process in a hermetic sandbox, so it does not have access to git state unless you take steps to make that happen
There may be env vars you can set (and plumb through via
[subprocess-environment]
) that will cause PDM to find the git root?
Or does PDM insist on the cwd being the git root?
a
Hmmm, PDM allows passing the version directly as an environment variable using
PDM_BUILD_SCM_VERSION=X.Y.Z
; I'll check
[subprocess-environment]
next. Thanks for the idea !
h
Well but where would you get that VERSION from? I assume you want PDM to compute it?
If so you need to point PDM to the repo in which to compute this (since it's not the sandbox), and possibly also we'd need to make a change to expose the
git
binary in the PATH (or this may already be available, it depends)
a
Ideally, yes, the PDM backend should be able to parse the version from tags using the provided
tag_regex
( see repro ) Havent had the time to dwelve into PDM's implementation yet however so it may or may not depend on the
git tag
command; it could probably just be a simple glob search into
.git/refs/tags
folder However this backend does not requires to run PDM in the project's root folder; it does resolve the current git repository from the closest parent folder automatically.
h
Unfortunately the sandbox dirs are not under the repo
well, not "unfortunately" so much as by design, so side effects like this don't happen unintentionally