setuptools_scm
setuptools_scm copied to clipboard
Command line call does not output just version (automation unfriendly)
Current behavior of setuptools does not help with automation because it does not just retrieve the version, it can also report the guessed version.
> python3 -m setuptools_scm
Guessed Version 5.4.1.dev38+g7af3e3e.d20220218
When doing automation this detail is likely not desired and we need an option that will just retrieve the version and nothing else, so we don't need to sanitize it for use in automation.
The command line call does not even accept a --help, any arguments are just ignored.
That feature is quite important because it is supposed to be the (undocumented) replacement for python setup.py --version, for the projects that are removing setup.py.
While python3 -m setuptools_scm | sed -e 's/Guessed Version //' might look as workaround the reality is that that requires a shell so is no longer a command. Based on the place where the version is needed, that might impose additional problems, as many tools expect a command and not a shell. Adding a sh wrap command will add escaping.
Long story short, it would be far better to just make setuptools return just a version string. This can be done without breaking the current behavior as we could add a CLI switch for this.
@ssbarnea, this was actually fixed in https://github.com/pypa/setuptools_scm/commit/88efad42f90ef636443ac6ce25561b9118cd74c2, and available since 6.4.0