FFY00 / trampolim

A modern Python build backend
https://trampolim.readthedocs.io
MIT License
43 stars 4 forks source link

Exactly sitting on a tag fails #4

Closed henryiii closed 3 years ago

henryiii commented 3 years ago

This line breaks when this matches a tag exactly (which it usually should do if you are building wheels and SDists for publication?)

https://github.com/FFY00/trampolim/blob/f3e8db8dea5607f708208b57de0d8bc49348a9d1/trampolim/_build.py#L290

$ git describe --tags
v0.1.0

You want --long to force the commits since tag and current hash. Or you should check to see if -'s are present, then assume it's exactly a release then.

$ git describe --tags --long
v0.1.0-0-g165f120

Example failure from a nox run using scikit-hep/cookie:

nox -s 'dist(trampolim)'
nox > Running session dist(trampolim)
nox > Creating virtual environment (virtualenv) using python3.9 in .nox/dist-trampolim
nox > python -m pip install cookiecutter build twine
nox > cd .nox/dist-trampolim/tmp
nox > cookiecutter --no-input /Users/henryschreiner/git/scikit-hep/cookie --config-file=input.yml
nox > cd cookie-trampolim
nox > git init -q
nox > git add .
nox > git commit -qm feat: initial version
nox > git tag v0.1.0
nox > python -m build
nox > Command python -m build failed with exit code 1:
Found existing installation: setuptools 57.0.0
Uninstalling setuptools-57.0.0:
  Successfully uninstalled setuptools-57.0.0
Collecting trampolim~=0.0.3
  Using cached trampolim-0.0.3-py3-none-any.whl (13 kB)
Collecting packaging
  Using cached packaging-21.0-py3-none-any.whl (40 kB)
Collecting toml
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Installing collected packages: pyparsing, toml, packaging, trampolim
Successfully installed packaging-21.0 pyparsing-2.4.7 toml-0.10.2 trampolim-0.0.3
Traceback (most recent call last):
  File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 280, in <module>
    main()
  File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 236, in build_sdist
    return backend.build_sdist(sdist_directory, config_settings)
  File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/__init__.py", line 44, in build_sdist
    project = trampolim._build.Project()
  File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/_build.py", line 117, in __init__
    self.version  # calculate version
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/functools.py", line 969, in __get__
    val = self.func(instance)
  File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/_build.py", line 289, in version
    tag, r, commit = subprocess.check_output([
ValueError: not enough values to unpack (expected 3, got 1)

ERROR Backend subproccess exited when trying to invoke build_sdist

This works correctly in setuptools_scm.

FFY00 commented 3 years ago

Thank you for looking into the issue and thank you for the PR. I am a bit thorn between the proposed fix and fixing the parsing. I'd probably like the tarball and github tag to generate the same version.

henryiii commented 3 years ago

Feel free to fix as you see fit. I’m rather assuming here that the git hash and revision count are removed later if the count is 0 (that might depend on how you handle dirty working trees).

FFY00 commented 3 years ago

As pointed out in https://github.com/FFY00/trampolim/pull/5#issuecomment-923372306, I will pull setuptools_scm as a dependency, which should fix this.

henryiii commented 3 years ago

Okay, let me know when there's a fix. :)