Skip to content

Improve documentation on hooks flow - specifically when and how the dynamic version is written to a file #212

@ZeeD

Description

@ZeeD

Hi.
I'm trying to wrap my head around pdm, pdm-backend and, more generally, how the hooks works and how are they actually connected.

At the moment my goal is to understand how I can leverage pdm to create a python file with the scm version. I have looked at Writing dynamic version to file and at Lifecycle and Hooks but I have some questions:

  1. let's say that I set up correctly dynamic = ["version"], source = "scm", and write_to = "foo/_version.py" in the appropriate pyproject.toml tables. What cli command(s) will trigger the creation of the file? is there an explicit way?
  2. During the initializazion, I have set distribution = false (because I'm writing a application that is meant to be used internally and deployed via dockerfile where I just copy the sources) - is this choice relevant?
  3. Can you confirm I do need to set pdm-backend as build-backend? or is it a pdm feature that may work with setuptools or any other backend?
  4. What happens if in my git repository there is no tag (at all, or that matches the tag_regex)? I haven't see any log/warning/error during my tests
  5. What is the rule to "choose" an appropriate tag, assuming there are more than one that matches?
  6. On
    def resolve_version_from_scm(
    self,
    context: Context,
    write_to: str | None = None,
    write_template: str = "{}\n",
    tag_regex: str | None = None,
    ) -> str:
    I think I've found the relevant code, and it is in a hooks.version module, but I haven't found any reference to it in the docs. Is that related to the pdm hooks?

I'm having these doubts because I have a project that I've recently migrated to pdm, and I'm new to it, and I want to be sure to understand how it works

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions