I’m still working on my Python packaging, and I’d ...
# general
f
I’m still working on my Python packaging, and I’d like to use calver (
YYYY.M.D
) to version my packages, instead of semver. Additionally, if this is not a release build, I would like to add the most recent git commit hash to the version, so something like
2022.8.30+gabcd123
. I see that there’s a
vcs_version
target, which uses
setuptools_scm
to pull the most recent git tag, but that doesn’t quite fit what I want to do. Is there any existing code out there to solve this? If not, I started going about this as a plugin, but I’m stuck because I don’t see how the
vcs_version
target knows that it needs to call
setuptools_scm
. I suppose the relationship is that the
generate_python_from_setuptools_scm
rule depends on a
GenerateSourcesRequest
which has the
VCSVersionDummySourceField
as its input, and the
vcs_version
target has
VCSVersionDummySourceField
as one of its required fields. What I’m not clear about is whether I should create a new field specifically for my own VCS-ish version, or if I can reuse the existing fields inside pants?
I’m also confused about how to run
git
so that it still has access to the worktree to be able to read the commit hash
I think I need to use a
Process
and I’ve copied the
maybe_git_worktree
from the
setuptools_scm
-related code, but I don’t understand how to pass the worktree to the
Process
To keep this updated, the way I have this implemented reusing the
VCSVersionDummySourceField
results in an error because it’s ambiguous which implementation of the code generator to use. So that answers that question, I suppose!