setuptools_scm icon indicating copy to clipboard operation
setuptools_scm copied to clipboard

Customize local_scheme

Open fonspa opened this issue 1 year ago • 4 comments

Hi, I'm building a package using pyproject.toml conf for setuptools_scm and I'm trying to customize the local_scheme part of the returned version to get rid of the date and keep the node only. I tried many things but can't seem to get it to work. Callable in [tool.setuptools_scm] seems to work for version_scheme but not for local_scheme. I tried to define a custom callable for local_scheme in a setup.py like so

from setuptools import setup
from setuptools_scm.version import ScmVersion

def _get_local_node_and_dirty(version: ScmVersion) -> str:
    if version.exact or version.node is None:
        return version.format_choice("", "+dirty")
    else:
        return version.format_choice("+{node}", "+dirty")

setup(
    use_scm_version={"local_scheme": _get_local_node_and_dirty},
)

but I guess setuptools_scm reads either pyproject.toml or setup.py but can't get a mix of both so I end up with the default versioning scheme and it seems the callable in setup.py is ignored. And if I remove setuptools_scm conf in pyproject I end up with a 0.0.0.dist version.

Is there a way to customize local_scheme when using pyproject.toml ? Thank you!

fonspa avatar Mar 26 '23 11:03 fonspa

there is a bug wrt setuptools integration where option finalizaton and distribution keywords interact in a broken way

RonnyPfannschmidt avatar Mar 26 '23 12:03 RonnyPfannschmidt

Hi, is there any update?

I also want to customize the local_scheme part, to add a PyTorch-style CUDA version suffix like +cu117 to my package version.

bryandeng avatar May 29 '23 09:05 bryandeng

I have not started on the Bugfix yet

RonnyPfannschmidt avatar May 29 '23 13:05 RonnyPfannschmidt

Could we actually add the node-and-dirty-tag local scheme? It feels more explicit to me than the node-and-date scheme.

This is something I use everywhere along with a a function to parse a Git describe string from env to build Docker containers.

gcolombeau avatar Nov 22 '23 09:11 gcolombeau