-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use environment variables for setuptools_scm version schemes #6
Conversation
Environment variable `SCM_LOCAL_VERSION` should have been `SCM_LOCAL_SCHEME` in release.yml.
Oddly, the workflow fails after merging this PR (and amending the typo in |
Gets it wrong on your machine, or with github actions? Works on my machine: $ SCM_LOCAL_SCHEME=no-local-version python setup.py --version
0.1.0rc4.dev8 |
Actions. It works fine on my machine (Win/Linux). |
Hm. Seems almost like the bot isn't fetching the tags. I know you have to push tags manually, I wonder if whatver "Syncing repository: rpanderson/workflow-sandbox" is doing behind the scenes is somehow failing to pull them. |
I think it's to do with the way your GitHub action workflow fetches the repository. This line suggests it is not fethcing the tags: https://github.com/rpanderson/workflow-sandbox/runs/651389010?check_suite_focus=true#step:3:31 |
It's because the repository cloned by |
If only there was a "fetch parents, taking the first parent when you hit a merge commit, and then stop when you hit a tag" option. |
There's a fetch all tags action. Discussed in setuptools_scm bug report |
Yep, I've added another workflow step which is more eager (fetch all history for all tags and branches). This worked. I'll try just the tags. |
Just the tags doesn't seem to work for me locally. [bilbo:clones]$ git clone --depth 1 https://github.com/rpanderson/workflow-sandbox/
Cloning into 'workflow-sandbox'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 18 (delta 0), reused 10 (delta 0), pack-reused 0
Receiving objects: 100% (18/18), 49.13 KiB | 2.14 MiB/s, done.
[bilbo:clones]$ cd workflow-sandbox/
[bilbo:workflow-sandbox]$ git fetch --depth=1 origin +refs/tags/*:refs/tags/*
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 19 (delta 6), reused 8 (delta 0), pack-reused 0
Unpacking objects: 100% (19/19), 3.28 KiB | 840.00 KiB/s, done.
From https://github.com/rpanderson/workflow-sandbox
* [new tag] v0.1.0rc1 -> v0.1.0rc1
* [new tag] v0.1.0rc2 -> v0.1.0rc2
* [new tag] v0.1.0rc3 -> v0.1.0rc3
[bilbo:workflow-sandbox]$ python setup.py --version
/usr/lib/python3.8/site-packages/setuptools_scm/git.py:68: UserWarning: "/home/bilbo/clones/workflow-sandbox" is shallow and may cause errors
warnings.warn('"{}" is shallow and may cause errors'.format(wd.path))
0.1.dev1 If I checkout a tag it works for that tag. But I guess with just the tagged commits git just sees these floating island commits with no way to even know what order they're in without the intervening commits. Good that all history of tags and branches works, but that's just a full depth clone, right? Shame if we can't still have it be shallower, but whatver. |
(Snap.) Fetching tags alone doesn't suffice, as it needs to parse the history to form the version properly. There's probably a shallower way to do this, but for now I'll revert to the full clone. |
This PR amends #5, by using environment variables
SCM_VERSION_SCHEME
andSCM_LOCAL_SCHEME
to setsetuptools_scm.version_scheme
andsetuptools_scm.local_scheme
, respectively. The default scheme if either environment variable is absent.This can be tested by setting either of these environment variables to something other than the default scheme and running
python setup.py --version
. For example: