setuptools-scm: Don't use tag from repo for version

Hello.

Is it possible to not use version tag from repo, but instead ask setuptools_scm to use custom version (handcrafted) but apply other additions (+commit hash etc)? I’ve tried for several days but haven’t got any possible way to do this.

Reason for this question is the problem I’m facing when fork’ing another project. If I’m cloning main project (not my fork) setuptools_scm makes normal version like 0.1.8.dev50+g07021cb though when I’m cloning my fork of this project and trying to see what sort of version setuptools_scm will give me I’m getting 0.1.dev2451+g11b3f0e.d20240419. As I understand it is related to how setuptools_scm is getting the version - using version tags. But in the fork there are no tags. So I’m getting this weird stuff. So the idea was to use custom version ‘0.1.8’ for example and ask setuptools_scm to just add other stuff except version. But I wasn’t been able to do this. Anything I’m trying to add in the setup.py following your documentation is just being ignored by setuptools_scm. Or maybe I’m doing something wrong, which is possible.

I’ve also seen that there are some sort of variable SETUPTOOLS_SCM_PRETEND_VERSION which, by looking at the description, could be the thing I need, but how to change it properly using setup.py or pyproject.toml?

Anyway, thanks in advance for the answer.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

PSA the provided code is incorrect on multiple levels

It would’ve been better to just set the value directly

Instead a version scheme that completely sidesteps the tool is used

Please don’t pull this tool into that mess

The question in this issue is not about changing versioning scheme. It is about a fallback version. setuptools_scm has the fallback_version config property which used as far as I understand when executing git fails. What we need is a fallback version for the case when there are no tags in a repo.

It could be solved by asking fork owners to sync tags in forks. But on the other hand:

  • we need fallback version for the cases of running Python code without installing it first anyway
  • releases are not done from forks except testing purposes (in last case it is assumed the person who does test should understand how versioning works) thus syncing tags in forks is superfluous
  • requiring doing something manually by instruction usually means people will miss this step and raise issues with questions how to get a proper version

I have looked at the source code of setuptools_scm and I see two ways to implement the fallback on a client side:

  • providing local versioning scheme
  • overriding parse function

The question is whether there is a more straightforward way to set a fallback version for this case?

Closing this as out of scope The reasonable expectation is for basic projects maintenance to happen