Skip to content
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

setuptools_scm does not create a version file after 8.0.0 release #960

Closed
Mogost opened this issue Oct 18, 2023 · 10 comments · Fixed by #996
Closed

setuptools_scm does not create a version file after 8.0.0 release #960

Mogost opened this issue Oct 18, 2023 · 10 comments · Fixed by #996

Comments

@Mogost
Copy link

Mogost commented Oct 18, 2023

pyproject.toml

[project]
name = "project"
dynamic = ["version"]

[tool.setuptools_scm]
version_file = "project/version.py". # <- before 8.0.0 was write_to
version_scheme = "calver-by-date"
❯ SETUPTOOLS_SCM_DEBUG=1 python -m setuptools_scm
[10/18/23 15:06:37] DEBUG    dist name: project                                                                                            _overrides.py:40
                    DEBUG    check absolute root=. relative_to=/Users/mogost/work/project/pyproject.toml                       _config.py:60
                    DEBUG    file /Users/mogost/work/project/pyproject.toml                                                    _config.py:79
                    DEBUG    version_from_ep setuptools_scm.parse_scm in /Users/mogost/work/project                       _entrypoints.py:52
                    DEBUG    looking for ep setuptools_scm.parse_scm in /Users/mogost/work/project                            discover.py:59
                    DEBUG    found ep EntryPoint(name='.git', value='setuptools_scm.git:parse', group='setuptools_scm.parse_scm') in       discover.py:67
                             /Users/mogost/work/project                                                                                     
                    DEBUG    at .                                                                                                         _run_cmd.py:143
                                 $ git version                                                                                                           
                    DEBUG    out:                                                                                                         _run_cmd.py:163
                                 git version 2.39.3 (Apple Git-145)                                                                                      
                    DEBUG    at /Users/mogost/work/project                                                                   _run_cmd.py:143
                                 $ git --git-dir /Users/mogost/work/project/.git rev-parse --show-prefix                                    
                    DEBUG    real root /Users/mogost/work/project                                                                  git.py:87
                    DEBUG    at /Users/mogost/work/project                                                                   _run_cmd.py:143
                                 $ git --git-dir /Users/mogost/work/project/.git describe --dirty --tags --long --match                     
                             "*[0-9]*"                                                                                                                   
                    DEBUG    out:                                                                                                         _run_cmd.py:163
                                 v23.9.13.1-232-g5a2e09102c-dirty                                                                                        
                    DEBUG    tag v23.9.13.1                                                                                                 version.py:91
                    DEBUG    'v23.9.13.1' re.compile('^(?:[\\w-]+-)?(?P<version>[vV]?\\d+(?:\\.\\d+){0,2}[^\\+]*)(?:\\+.*)?$') <re.Match    version.py:54
                             object; span=(0, 10), match='v23.9.13.1'>                                                                                   
                    DEBUG    key 1 data {'version': 'v23.9.13.1'}, ('v23.9.13.1',), 'v23.9.13.1'                                            version.py:55
                    DEBUG    tag 'v23.9.13.1' parsed to {'version': 'v23.9.13.1', 'prefix': '', 'suffix': ''}                               version.py:64
                    DEBUG    version pre parse v23.9.13.1                                                                                   version.py:99
                    DEBUG    version=<Version('23.9.13.1')>                                                                                version.py:105
                    INFO     version v23.9.13.1 -> 23.9.13.1                                                                               version.py:211
                    DEBUG    at /Users/mogost/work/project                                                                   _run_cmd.py:143
                                 $ git --git-dir /Users/mogost/work/project/.git rev-parse --abbrev-ref HEAD                                
                    DEBUG    out:                                                                                                         _run_cmd.py:163
                                 dependabot/pip/develop/black-d--23.10.0                                                                                 
                    DEBUG    at /Users/mogost/work/project                                                                   _run_cmd.py:143
                                 $ git --git-dir /Users/mogost/work/project/.git -c log.showSignature=false log -n 1 HEAD                   
                             --format=%cI                                                                                                                
                    DEBUG    out:                                                                                                         _run_cmd.py:163
                                 2023-10-18T13:47:20+06:00                                                                                               
                    DEBUG    EntryPoint(name='.git', value='setuptools_scm.git:parse', group='setuptools_scm.parse_scm') found         _entrypoints.py:56
                             <ScmVersion 23.9.13.1 dist=232 node=g5a2e09102c dirty=True                                                                  
                             branch=dependabot/pip/develop/black-d--23.10.0>                                                                             
                    DEBUG    scm version <ScmVersion 23.9.13.1 dist=232 node=g5a2e09102c dirty=True                                        version.py:426
                             branch=dependabot/pip/develop/black-d--23.10.0>                                                                             
                    DEBUG    config Configuration(relative_to='/Users/mogost/work/project/pyproject.toml', root='.',          version.py:427
                             version_scheme='calver-by-date', local_scheme='node-and-date',                                                              
                             tag_regex=re.compile('^(?:[\\w-]+-)?(?P<version>[vV]?\\d+(?:\\.\\d+){0,2}[^\\+]*)(?:\\+.*)?$'),                             
                             parentdir_prefix_version=None, fallback_version=None, fallback_root='.', write_to=None,                                     
                             write_to_template=None, version_file='project/version.py', version_file_template=None, parse=None,                            
                             git_describe_command=None, dist_name='project', version_cls=<class 'packaging.version.Version'>,                              
                             search_parent_directories=False, parent=PosixPath('/Users/mogost/work/project'))                               
                    DEBUG    ep found: calver-by-date                                                                                  _entrypoints.py:71
[10/18/23 15:06:38] DEBUG    version 23.10.18.0.dev232                                                                                     version.py:434
                    DEBUG    ep found: node-and-date                                                                                   _entrypoints.py:71
                    DEBUG    local_version +g5a2e09102c.d20231018                                                                          version.py:439
23.10.18.0.dev232+g5a2e09102c.d20231018

❯ ls -la project/version.py
ls: project/version.py: No such file or directory
@RonnyPfannschmidt
Copy link
Contributor

The cli is no longer accidentally overwriting files

Long term the intent is to put this into a build backend in general

@Mogost
Copy link
Author

Mogost commented Oct 18, 2023

What should I do to make this file appear?

@RonnyPfannschmidt
Copy link
Contributor

Editable installation or building a wheel make it happen

What's your use case?

@Mogost
Copy link
Author

Mogost commented Oct 18, 2023

I actually use setuptools_scm not really for setuptools.
I just have a project on Django that is not packaged and before that setuptools_scm worked fine for me and helped versioning. I was getting this file and further, it worked fine for me.
Right now it looks like the best I can get is to redirect the output to a file, which doesn't look like a good solution.

@RonnyPfannschmidt
Copy link
Contributor

In that case a opt in flag is needed

@Mogost
Copy link
Author

Mogost commented Oct 18, 2023

Do I understand correctly that currently there is no such flag in setuptools_scm?

@RonnyPfannschmidt
Copy link
Contributor

correct, the way you use it was never a officially supported way before
that's why removing the writing to version files on command running was considered a bugfix, not a breakage

@Mogost
Copy link
Author

Mogost commented Oct 18, 2023

Truth be told I was very pleased with how setuptools_scm worked in this way.
Essentially inside setuptools_scm the logic is conveniently described, you can customize the output and the tool is universal rather than exclusively for packaging with setuptools.
and I don't think my use of it was unique.

@RonnyPfannschmidt
Copy link
Contributor

i understand the sentiment on the usage, but the behavior you used as a feature was a artifact of having to work around design issues in setuptools

now that we have the use-case known explicitly, a proper command to write a version file can be added

@MHendricks
Copy link

I just ran into this issue. I definitely would like to see this added as a cli command/argument. I often find myself wanting to make sure that my version.py file is updated but don't want to spend a long time fully building a wheel, when updating the version info is much faster.

I was using python -m build --version to accomplish this when using setuptools_scm<8. I never actually read the docs for --version, and having read them I understand why this was considered a bug, but definitely would like to see a way to force it to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants